?? ledgerquery.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace 財務(wù)管理系統(tǒng)
{
/// <summary>
/// LedgerQuery 的摘要說明。
/// </summary>
public class LedgerQuery : System.Windows.Forms.Form
{
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.DataView dataView1;
private 財務(wù)管理系統(tǒng).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 窗體設(shè)計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計器生成的代碼
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </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 財務(wù)管理系統(tǒng).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 = "需要查詢會計歷史區(qū)的帳簿,需要在期末結(jié)帳時將【本期匯總帳簿】表的數(shù)據(jù)導(dǎo)入歷史,實(shí)例不提供";
//
// 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 = "無發(fā)生金額不顯示";
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
//----------顯示窗口時讀入全部數(shù)據(jù)--------------
private void LedgerQuery_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.SelectCommand.Parameters[0].Value="%%";
sqlDataAdapter1.Fill(dataSet11);
}
//-----------根據(jù)有無發(fā)生金額篩選顯示的數(shù)據(jù)------------
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
if(checkBox1.Checked)
dataView1.RowFilter="余額<>0";
else
dataView1.RowFilter="";
}
//------------根據(jù)科目代碼選擇數(shù)據(jù)------------
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);
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -