📄 ledgerquery.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace 财务管理系统
{
/// <summary>
/// LedgerQuery 的摘要说明。
/// </summary>
public class LedgerQuery : System.Windows.Forms.Form
{
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.DataView dataView1;
private 财务管理系统.DataSet1 dataSet11;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.TextBox txt1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label label1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.ComponentModel.IContainer components;
public LedgerQuery()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(LedgerQuery));
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.dataView1 = new System.Data.DataView();
this.dataSet11 = new 财务管理系统.DataSet1();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnSearch = new System.Windows.Forms.Button();
this.txt1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "本期汇总账簿", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("科目名称", "科目名称"),
new System.Data.Common.DataColumnMapping("科目代码", "科目代码"),
new System.Data.Common.DataColumnMapping("会计期间", "会计期间"),
new System.Data.Common.DataColumnMapping("期初余额", "期初余额"),
new System.Data.Common.DataColumnMapping("本期借方合计", "本期借方合计"),
new System.Data.Common.DataColumnMapping("本期贷方合计", "本期贷方合计"),
new System.Data.Common.DataColumnMapping("本年借方累计", "本年借方累计"),
new System.Data.Common.DataColumnMapping("本年贷方累计", "本年贷方累计"),
new System.Data.Common.DataColumnMapping("余额", "余额"),
new System.Data.Common.DataColumnMapping("余额方向", "余额方向")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT b.科目名称, a.科目代码, a.会计期间, a.期初余额, a.本期借方合计, a.本期贷方合计, a.本年借方累计, a.本年贷方累计, a." +
"余额, a.余额方向 FROM 本期汇总账簿 a INNER JOIN 科目表 b ON a.科目代码 = b.科目代码 WHERE (a.科目代码 LIKE " +
"@Param4)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.VarChar, 20, "科目代码"));
//
// dataView1
//
this.dataView1.Table = this.dataSet11.本期汇总账簿;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnSearch);
this.groupBox1.Controls.Add(this.txt1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(720, 64);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// btnSearch
//
this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnSearch.Location = new System.Drawing.Point(72, 28);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(72, 23);
this.btnSearch.TabIndex = 6;
this.btnSearch.Text = " 搜索";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// txt1
//
this.txt1.Location = new System.Drawing.Point(264, 28);
this.txt1.Name = "txt1";
this.txt1.TabIndex = 8;
this.txt1.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(208, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 7;
this.label2.Text = "凭证编号";
//
// dataGrid1
//
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataView1;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 136);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(720, 352);
this.dataGrid1.TabIndex = 1;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.checkBox1);
this.groupBox2.Location = new System.Drawing.Point(0, 64);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(720, 72);
this.groupBox2.TabIndex = 31;
this.groupBox2.TabStop = false;
//
// label1
//
this.label1.Location = new System.Drawing.Point(272, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(344, 32);
this.label1.TabIndex = 1;
this.label1.Text = "需要查询会计历史区的帐簿,需要在期末结帐时将【本期汇总帐簿】表的数据导入历史,实例不提供";
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(72, 32);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(152, 32);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "无发生金额不显示";
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;initial catalo" +
"g=caiwubook;persist security info=False";
//
// LedgerQuery
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(720, 485);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.groupBox1);
this.Name = "LedgerQuery";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "【总分类帐查询】";
this.Load += new System.EventHandler(this.LedgerQuery_Load);
((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
//----------显示窗口时读入全部数据--------------
private void LedgerQuery_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.SelectCommand.Parameters[0].Value="%%";
sqlDataAdapter1.Fill(dataSet11);
}
//-----------根据有无发生金额筛选显示的数据------------
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
if(checkBox1.Checked)
dataView1.RowFilter="余额<>0";
else
dataView1.RowFilter="";
}
//------------根据科目代码选择数据------------
private void btnSearch_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.SelectCommand.Parameters[0].Value="%%";
if(txt1.Text.Trim()!=null)
{
sqlDataAdapter1.SelectCommand.Parameters[0].Value="%"+txt1.Text.Trim()+"%";
dataSet11.Clear();
sqlDataAdapter1.Fill(dataSet11);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -