ActiveReport Tutorials For 2.0J(二)--Event

 
相关链接
使用ActiveReport for .net 进行报表开发(七)--事件 By Cure


Event UnBoundReport
ConditionalFormat(Report里的逻辑处理)

 ActiveReport Tutorials For 2.0J(二)--Event_第1张图片

 PowerTools ActiveReports for .NET 2.0J 
キーワード:イベント
 

UnBoundReport
  ActiveReport Tutorials For 2.0J(二)--Event_第2张图片

 

 1
 2          private   void  rptUnbound_DataInitialize( object  sender, System.EventArgs eArgs)
 3          {
 4            Fields.Add("CategoryName");
 5            Fields.Add("ProductName");
 6            Fields.Add("UnitsInStock");
 7            Fields.Add("Description");
 8        }

 9
10          private   void  rptUnbound_FetchData( object  sender, DataDynamics.ActiveReports.ActiveReport.FetchEventArgs eArgs)
11          {
12            try
13            {
14                m_reader.Read();
15                Fields["CategoryName"].Value = m_reader["CategoryName"].ToString();
16                Fields["ProductName"].Value = m_reader["ProductName"].ToString();
17                Fields["UnitsInStock"].Value = m_reader["UnitsInStock"].ToString();
18                Fields["Description"].Value = m_reader["Description"].ToString();
19                eArgs.EOF = false;
20            }

21            catch
22            {
23                eArgs.EOF = true;
24            }

25        }

26          private   static  OleDbConnection m_cnn;
27          private   static  OleDbDataReader  m_reader;
28
29          private   void  rptUnbound_ReportStart( object  sender, System.EventArgs eArgs)
30          {
31            string m_cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
32                + @"..\..\..\..\..\Data\NWIND.MDB;Persist Security Info=False";
33            string sqlString = "SELECT * FROM categories INNER JOIN products"
34                + " ON categories.categoryid = products.categoryid"
35                + " ORDER BY products.categoryid, products.productid";
36            m_cnn = new OleDbConnection(m_cnnString);
37            OleDbCommand m_Cmd = new OleDbCommand(sqlString,m_cnn);
38            if(m_cnn.State == ConnectionState.Closed)
39            {
40                m_cnn.Open();
41            }

42            m_reader = m_Cmd.ExecuteReader();
43        }

44

        キーワード: アンバウンドレポートの作成方法を知りたい
          不设置DataSource
Return




ConditionalFormat(Report里的逻辑处理)
ActiveReport Tutorials For 2.0J(二)--Event_第3张图片 
ActiveReport Tutorials For 2.0J(二)--Event_第4张图片

 1          int  m_uis;
 2          int  m_rl;
 3          int  m_uoo;
 4          bool  m_dis;
 5
 6          private   void  Detail_Format( object  sender, System.EventArgs eArgs)
 7          {
 8            if(m_uis < m_rl)
 9            {
10                if(m_uoo == 0)
11                {
12                    txtWarning.Text= "Time To Reorder";
13                    txtWarning.ForeColor = System.Drawing.Color.Red;
14                }

15                else
16                {
17                    txtWarning.Text = "There are " + m_uoo.ToString() + " units on order";                    
18                    txtWarning.ForeColor = System.Drawing.Color.DarkGreen;
19                }

20            }

21            else
22            {
23                txtWarning.Text ="";    
24                txtWarning.ForeColor = System.Drawing.Color.Black;
25            }

26            if(m_dis)
27            {
28                this.txtInStock.ForeColor = System.Drawing.Color.LightGray;
29                this.txtProductName.ForeColor = System.Drawing.Color.LightGray;
30                this.txtQuantityPerUnit.ForeColor = System.Drawing.Color.LightGray;
31                this.txtUnitPrice.ForeColor = System.Drawing.Color.LightGray;
32                this.txtWarning.ForeColor = System.Drawing.Color.LightGray;
33                this.txtWarning.Text = "Discontinued";
34            }

35            else
36            {
37                this.txtInStock.ForeColor = System.Drawing.Color.Black;
38                this.txtProductName.ForeColor = System.Drawing.Color.Black;
39                this.txtQuantityPerUnit.ForeColor = System.Drawing.Color.Black;
40                this.txtUnitPrice.ForeColor = System.Drawing.Color.Black;
41            }

42
43        }

44
45          private   void  rptConFormat_FetchData( object  sender, DataDynamics.ActiveReports.ActiveReport.FetchEventArgs eArgs)
46          {
47            m_uis = (System.Int16)Fields["UnitsInStock"].Value;
48            m_rl = (System.Int16)Fields["ReorderLevel"].Value;
49            m_uoo = (System.Int16)Fields["UnitsOnOrder"].Value;
50            m_dis = (System.Boolean)Fields["Discontinued"].Value;
51
52        }

Report里的逻辑处理
根据DataSource的数据,对页面Layout进行设置。

CR的Layout逻辑处理是写在各自控件的Script里面的而AR是统一集中在Event里处理,不像CR那样界面化,由于代码与表现分离,对于喜欢copy代码的人来说,是件好事,当然工作效率也高了。
       
Return




你可能感兴趣的:(Active)