LedgerQuery.cs
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:10k
源码类别:

企业管理

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace 财务管理系统
  7. {
  8. /// <summary>
  9. /// LedgerQuery 的摘要说明。
  10. /// </summary>
  11. public class LedgerQuery : System.Windows.Forms.Form
  12. {
  13. private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
  14. private System.Data.DataView dataView1;
  15. private 财务管理系统.DataSet1 dataSet11;
  16. private System.Windows.Forms.GroupBox groupBox1;
  17. private System.Windows.Forms.DataGrid dataGrid1;
  18. private System.Windows.Forms.GroupBox groupBox2;
  19. private System.Windows.Forms.Button btnSearch;
  20. private System.Windows.Forms.TextBox txt1;
  21. private System.Windows.Forms.Label label2;
  22. private System.Windows.Forms.CheckBox checkBox1;
  23. private System.Windows.Forms.Label label1;
  24. private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
  25. private System.Data.SqlClient.SqlConnection sqlConnection1;
  26. private System.ComponentModel.IContainer components;
  27. public LedgerQuery()
  28. {
  29. //
  30. // Windows 窗体设计器支持所必需的
  31. //
  32. InitializeComponent();
  33. //
  34. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  35. //
  36. }
  37. /// <summary>
  38. /// 清理所有正在使用的资源。
  39. /// </summary>
  40. protected override void Dispose( bool disposing )
  41. {
  42. if( disposing )
  43. {
  44. if(components != null)
  45. {
  46. components.Dispose();
  47. }
  48. }
  49. base.Dispose( disposing );
  50. }
  51. #region Windows 窗体设计器生成的代码
  52. /// <summary>
  53. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  54. /// 此方法的内容。
  55. /// </summary>
  56. private void InitializeComponent()
  57. {
  58. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(LedgerQuery));
  59. this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
  60. this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
  61. this.dataView1 = new System.Data.DataView();
  62. this.dataSet11 = new 财务管理系统.DataSet1();
  63. this.groupBox1 = new System.Windows.Forms.GroupBox();
  64. this.btnSearch = new System.Windows.Forms.Button();
  65. this.txt1 = new System.Windows.Forms.TextBox();
  66. this.label2 = new System.Windows.Forms.Label();
  67. this.dataGrid1 = new System.Windows.Forms.DataGrid();
  68. this.groupBox2 = new System.Windows.Forms.GroupBox();
  69. this.label1 = new System.Windows.Forms.Label();
  70. this.checkBox1 = new System.Windows.Forms.CheckBox();
  71. this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
  72. ((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
  73. ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
  74. this.groupBox1.SuspendLayout();
  75. ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
  76. this.groupBox2.SuspendLayout();
  77. this.SuspendLayout();
  78. // 
  79. // sqlDataAdapter1
  80. // 
  81. this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
  82. this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
  83.   new System.Data.Common.DataTableMapping("Table", "本期汇总账簿", new System.Data.Common.DataColumnMapping[] {
  84. new System.Data.Common.DataColumnMapping("科目名称", "科目名称"),
  85. new System.Data.Common.DataColumnMapping("科目代码", "科目代码"),
  86. new System.Data.Common.DataColumnMapping("会计期间", "会计期间"),
  87. new System.Data.Common.DataColumnMapping("期初余额", "期初余额"),
  88. new System.Data.Common.DataColumnMapping("本期借方合计", "本期借方合计"),
  89. new System.Data.Common.DataColumnMapping("本期贷方合计", "本期贷方合计"),
  90. new System.Data.Common.DataColumnMapping("本年借方累计", "本年借方累计"),
  91. new System.Data.Common.DataColumnMapping("本年贷方累计", "本年贷方累计"),
  92. new System.Data.Common.DataColumnMapping("余额", "余额"),
  93. new System.Data.Common.DataColumnMapping("余额方向", "余额方向")})});
  94. // 
  95. // sqlSelectCommand1
  96. // 
  97. this.sqlSelectCommand1.CommandText = "SELECT b.科目名称, a.科目代码, a.会计期间, a.期初余额, a.本期借方合计, a.本期贷方合计, a.本年借方累计, a.本年贷方累计, a." +
  98. "余额, a.余额方向 FROM 本期汇总账簿 a INNER JOIN 科目表 b ON a.科目代码 = b.科目代码 WHERE (a.科目代码 LIKE " +
  99. "@Param4)";
  100. this.sqlSelectCommand1.Connection = this.sqlConnection1;
  101. this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.VarChar, 20, "科目代码"));
  102. // 
  103. // dataView1
  104. // 
  105. this.dataView1.Table = this.dataSet11.本期汇总账簿;
  106. // 
  107. // dataSet11
  108. // 
  109. this.dataSet11.DataSetName = "DataSet1";
  110. this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
  111. // 
  112. // groupBox1
  113. // 
  114. this.groupBox1.Controls.Add(this.btnSearch);
  115. this.groupBox1.Controls.Add(this.txt1);
  116. this.groupBox1.Controls.Add(this.label2);
  117. this.groupBox1.Location = new System.Drawing.Point(0, 0);
  118. this.groupBox1.Name = "groupBox1";
  119. this.groupBox1.Size = new System.Drawing.Size(720, 64);
  120. this.groupBox1.TabIndex = 0;
  121. this.groupBox1.TabStop = false;
  122. // 
  123. // btnSearch
  124. // 
  125. this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
  126. this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  127. this.btnSearch.Location = new System.Drawing.Point(72, 28);
  128. this.btnSearch.Name = "btnSearch";
  129. this.btnSearch.Size = new System.Drawing.Size(72, 23);
  130. this.btnSearch.TabIndex = 6;
  131. this.btnSearch.Text = " 搜索";
  132. this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
  133. // 
  134. // txt1
  135. // 
  136. this.txt1.Location = new System.Drawing.Point(264, 28);
  137. this.txt1.Name = "txt1";
  138. this.txt1.TabIndex = 8;
  139. this.txt1.Text = "";
  140. // 
  141. // label2
  142. // 
  143. this.label2.Location = new System.Drawing.Point(208, 32);
  144. this.label2.Name = "label2";
  145. this.label2.Size = new System.Drawing.Size(56, 16);
  146. this.label2.TabIndex = 7;
  147. this.label2.Text = "凭证编号";
  148. // 
  149. // dataGrid1
  150. // 
  151. this.dataGrid1.CaptionVisible = false;
  152. this.dataGrid1.DataMember = "";
  153. this.dataGrid1.DataSource = this.dataView1;
  154. this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
  155. this.dataGrid1.Location = new System.Drawing.Point(0, 136);
  156. this.dataGrid1.Name = "dataGrid1";
  157. this.dataGrid1.ReadOnly = true;
  158. this.dataGrid1.Size = new System.Drawing.Size(720, 352);
  159. this.dataGrid1.TabIndex = 1;
  160. // 
  161. // groupBox2
  162. // 
  163. this.groupBox2.Controls.Add(this.label1);
  164. this.groupBox2.Controls.Add(this.checkBox1);
  165. this.groupBox2.Location = new System.Drawing.Point(0, 64);
  166. this.groupBox2.Name = "groupBox2";
  167. this.groupBox2.Size = new System.Drawing.Size(720, 72);
  168. this.groupBox2.TabIndex = 31;
  169. this.groupBox2.TabStop = false;
  170. // 
  171. // label1
  172. // 
  173. this.label1.Location = new System.Drawing.Point(272, 32);
  174. this.label1.Name = "label1";
  175. this.label1.Size = new System.Drawing.Size(344, 32);
  176. this.label1.TabIndex = 1;
  177. this.label1.Text = "需要查询会计历史区的帐簿,需要在期末结帐时将【本期汇总帐簿】表的数据导入历史,实例不提供";
  178. // 
  179. // checkBox1
  180. // 
  181. this.checkBox1.Location = new System.Drawing.Point(72, 32);
  182. this.checkBox1.Name = "checkBox1";
  183. this.checkBox1.Size = new System.Drawing.Size(152, 32);
  184. this.checkBox1.TabIndex = 0;
  185. this.checkBox1.Text = "无发生金额不显示";
  186. this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  187. // 
  188. // sqlConnection1
  189. // 
  190. this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;initial catalo" +
  191. "g=caiwubook;persist security info=False";
  192. // 
  193. // LedgerQuery
  194. // 
  195. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  196. this.ClientSize = new System.Drawing.Size(720, 485);
  197. this.Controls.Add(this.groupBox2);
  198. this.Controls.Add(this.dataGrid1);
  199. this.Controls.Add(this.groupBox1);
  200. this.Name = "LedgerQuery";
  201. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  202. this.Text = "【总分类帐查询】";
  203. this.Load += new System.EventHandler(this.LedgerQuery_Load);
  204. ((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
  205. ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
  206. this.groupBox1.ResumeLayout(false);
  207. ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
  208. this.groupBox2.ResumeLayout(false);
  209. this.ResumeLayout(false);
  210. }
  211. #endregion
  212. //----------显示窗口时读入全部数据--------------
  213. private void LedgerQuery_Load(object sender, System.EventArgs e)
  214. {
  215. sqlDataAdapter1.SelectCommand.Parameters[0].Value="%%";
  216. sqlDataAdapter1.Fill(dataSet11);
  217. }
  218. //-----------根据有无发生金额筛选显示的数据------------
  219. private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
  220. {
  221. if(checkBox1.Checked)
  222. dataView1.RowFilter="余额<>0";
  223. else
  224. dataView1.RowFilter="";
  225. }
  226. //------------根据科目代码选择数据------------
  227. private void btnSearch_Click(object sender, System.EventArgs e)
  228. {
  229. sqlDataAdapter1.SelectCommand.Parameters[0].Value="%%";
  230. if(txt1.Text.Trim()!=null)
  231. {
  232. sqlDataAdapter1.SelectCommand.Parameters[0].Value="%"+txt1.Text.Trim()+"%";
  233. dataSet11.Clear();
  234. sqlDataAdapter1.Fill(dataSet11);
  235. }
  236. }
  237. }
  238. }