AccountSetting.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:22k
源码类别:
企业管理
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace 财务管理系统
- {
- /// <summary>
- /// AccountSetting 的摘要说明。
- /// </summary>
- public class AccountSetting : System.Windows.Forms.Form
- {
- private 财务管理系统.DataSet2 dataSet21;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand2;
- private System.Windows.Forms.DataGrid dataGrid1;
- private System.Windows.Forms.DataGrid dataGrid2;
- private System.Data.SqlClient.SqlDataAdapter da1;
- private System.Data.SqlClient.SqlDataAdapter da2;
- private System.Windows.Forms.Button btnNewAccount;
- private System.Windows.Forms.Button btnUseAccount;
- private System.Windows.Forms.Button btnBalance;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
- private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
- private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
- private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn5;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn6;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public AccountSetting()
- {
- //
- // 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(AccountSetting));
- this.da1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
- this.dataSet21 = new 财务管理系统.DataSet2();
- this.da2 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
- this.dataGrid1 = new System.Windows.Forms.DataGrid();
- this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
- this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn6 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGrid2 = new System.Windows.Forms.DataGrid();
- this.btnNewAccount = new System.Windows.Forms.Button();
- this.btnUseAccount = new System.Windows.Forms.Button();
- this.btnBalance = new System.Windows.Forms.Button();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
- this.SuspendLayout();
- //
- // da1
- //
- this.da1.DeleteCommand = this.sqlDeleteCommand1;
- this.da1.InsertCommand = this.sqlInsertCommand1;
- this.da1.SelectCommand = this.sqlSelectCommand1;
- this.da1.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("余额方向", "余额方向")})});
- this.da1.UpdateCommand = this.sqlUpdateCommand1;
- //
- // sqlDeleteCommand1
- //
- this.sqlDeleteCommand1.CommandText = @"DELETE FROM 帐簿初始化表 WHERE (科目代码 = @Original_科目代码) AND (余额方向 = @Original_余额方向 OR @Original_余额方向 IS NULL AND 余额方向 IS NULL) AND (期初余额 = @Original_期初余额 OR @Original_期初余额 IS NULL AND 期初余额 IS NULL) AND (科目名称 = @Original_科目名称 OR @Original_科目名称 IS NULL AND 科目名称 IS NULL) AND (累计借方 = @Original_累计借方 OR @Original_累计借方 IS NULL AND 累计借方 IS NULL) AND (累计贷方 = @Original_累计贷方 OR @Original_累计贷方 IS NULL AND 累计贷方 IS NULL)";
- this.sqlDeleteCommand1.Connection = this.sqlConnection1;
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_科目代码", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "科目代码", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_余额方向", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "余额方向", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_期初余额", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "期初余额", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_科目名称", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "科目名称", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_累计借方", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "累计借方", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_累计贷方", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "累计贷方", System.Data.DataRowVersion.Original, null));
- //
- // sqlInsertCommand1
- //
- this.sqlInsertCommand1.CommandText = "INSERT INTO 帐簿初始化表(科目代码, 科目名称, 累计借方, 累计贷方, 期初余额, 余额方向) VALUES (@科目代码, @科目名称, @累计借" +
- "方, @累计贷方, @期初余额, @余额方向); SELECT 科目代码, 科目名称, 累计借方, 累计贷方, 期初余额, 余额方向 FROM 帐簿初始化表 W" +
- "HERE (科目代码 = @科目代码)";
- this.sqlInsertCommand1.Connection = this.sqlConnection1;
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@科目代码", System.Data.SqlDbType.VarChar, 20, "科目代码"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@科目名称", System.Data.SqlDbType.VarChar, 20, "科目名称"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@累计借方", System.Data.SqlDbType.Money, 8, "累计借方"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@累计贷方", System.Data.SqlDbType.Money, 8, "累计贷方"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@期初余额", System.Data.SqlDbType.Money, 8, "期初余额"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@余额方向", System.Data.SqlDbType.VarChar, 4, "余额方向"));
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT 科目代码, 科目名称, 累计借方, 累计贷方, 期初余额, 余额方向 FROM 帐簿初始化表";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- //
- // sqlUpdateCommand1
- //
- this.sqlUpdateCommand1.CommandText = @"UPDATE 帐簿初始化表 SET 科目代码 = @科目代码, 科目名称 = @科目名称, 累计借方 = @累计借方, 累计贷方 = @累计贷方, 期初余额 = @期初余额, 余额方向 = @余额方向 WHERE (科目代码 = @Original_科目代码) AND (余额方向 = @Original_余额方向 OR @Original_余额方向 IS NULL AND 余额方向 IS NULL) AND (期初余额 = @Original_期初余额 OR @Original_期初余额 IS NULL AND 期初余额 IS NULL) AND (科目名称 = @Original_科目名称 OR @Original_科目名称 IS NULL AND 科目名称 IS NULL) AND (累计借方 = @Original_累计借方 OR @Original_累计借方 IS NULL AND 累计借方 IS NULL) AND (累计贷方 = @Original_累计贷方 OR @Original_累计贷方 IS NULL AND 累计贷方 IS NULL); SELECT 科目代码, 科目名称, 累计借方, 累计贷方, 期初余额, 余额方向 FROM 帐簿初始化表 WHERE (科目代码 = @科目代码)";
- this.sqlUpdateCommand1.Connection = this.sqlConnection1;
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@科目代码", System.Data.SqlDbType.VarChar, 20, "科目代码"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@科目名称", System.Data.SqlDbType.VarChar, 20, "科目名称"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@累计借方", System.Data.SqlDbType.Money, 8, "累计借方"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@累计贷方", System.Data.SqlDbType.Money, 8, "累计贷方"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@期初余额", System.Data.SqlDbType.Money, 8, "期初余额"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@余额方向", System.Data.SqlDbType.VarChar, 4, "余额方向"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_科目代码", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "科目代码", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_余额方向", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "余额方向", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_期初余额", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "期初余额", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_科目名称", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "科目名称", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_累计借方", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "累计借方", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_累计贷方", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "累计贷方", System.Data.DataRowVersion.Original, null));
- //
- // dataSet21
- //
- this.dataSet21.DataSetName = "DataSet2";
- this.dataSet21.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // da2
- //
- this.da2.SelectCommand = this.sqlSelectCommand2;
- this.da2.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("取值", "取值")})});
- //
- // sqlSelectCommand2
- //
- this.sqlSelectCommand2.CommandText = "SELECT 编号, 参数名称, 取值 FROM 系统参数表";
- this.sqlSelectCommand2.Connection = this.sqlConnection1;
- //
- // dataGrid1
- //
- this.dataGrid1.CaptionVisible = false;
- this.dataGrid1.DataMember = "帐簿初始化表";
- this.dataGrid1.DataSource = this.dataSet21;
- this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid1.Location = new System.Drawing.Point(0, 64);
- this.dataGrid1.Name = "dataGrid1";
- this.dataGrid1.Size = new System.Drawing.Size(416, 424);
- this.dataGrid1.TabIndex = 0;
- this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
- this.dataGridTableStyle1});
- //
- // dataGridTableStyle1
- //
- this.dataGridTableStyle1.DataGrid = this.dataGrid1;
- this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
- this.dataGridTextBoxColumn1,
- this.dataGridTextBoxColumn2,
- this.dataGridTextBoxColumn3,
- this.dataGridTextBoxColumn4,
- this.dataGridTextBoxColumn5,
- this.dataGridTextBoxColumn6});
- this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGridTableStyle1.MappingName = "帐簿初始化表";
- //
- // dataGridTextBoxColumn1
- //
- this.dataGridTextBoxColumn1.Format = "";
- this.dataGridTextBoxColumn1.FormatInfo = null;
- this.dataGridTextBoxColumn1.HeaderText = "科目代码";
- this.dataGridTextBoxColumn1.MappingName = "科目代码";
- this.dataGridTextBoxColumn1.ReadOnly = true;
- this.dataGridTextBoxColumn1.Width = 75;
- //
- // dataGridTextBoxColumn2
- //
- this.dataGridTextBoxColumn2.Format = "";
- this.dataGridTextBoxColumn2.FormatInfo = null;
- this.dataGridTextBoxColumn2.HeaderText = "科目名称";
- this.dataGridTextBoxColumn2.MappingName = "科目名称";
- this.dataGridTextBoxColumn2.ReadOnly = true;
- this.dataGridTextBoxColumn2.Width = 75;
- //
- // dataGridTextBoxColumn3
- //
- this.dataGridTextBoxColumn3.Format = "";
- this.dataGridTextBoxColumn3.FormatInfo = null;
- this.dataGridTextBoxColumn3.HeaderText = "余额方向";
- this.dataGridTextBoxColumn3.MappingName = "余额方向";
- this.dataGridTextBoxColumn3.ReadOnly = true;
- this.dataGridTextBoxColumn3.Width = 75;
- //
- // dataGridTextBoxColumn4
- //
- this.dataGridTextBoxColumn4.Format = "";
- this.dataGridTextBoxColumn4.FormatInfo = null;
- this.dataGridTextBoxColumn4.HeaderText = "累计借方";
- this.dataGridTextBoxColumn4.MappingName = "累计借方";
- this.dataGridTextBoxColumn4.Width = 75;
- //
- // dataGridTextBoxColumn5
- //
- this.dataGridTextBoxColumn5.Format = "";
- this.dataGridTextBoxColumn5.FormatInfo = null;
- this.dataGridTextBoxColumn5.HeaderText = "累计借方";
- this.dataGridTextBoxColumn5.MappingName = "累计贷方";
- this.dataGridTextBoxColumn5.Width = 75;
- //
- // dataGridTextBoxColumn6
- //
- this.dataGridTextBoxColumn6.Format = "";
- this.dataGridTextBoxColumn6.FormatInfo = null;
- this.dataGridTextBoxColumn6.HeaderText = "期初余额";
- this.dataGridTextBoxColumn6.MappingName = "期初余额";
- this.dataGridTextBoxColumn6.Width = 75;
- //
- // dataGrid2
- //
- this.dataGrid2.CaptionVisible = false;
- this.dataGrid2.DataMember = "系统参数表";
- this.dataGrid2.DataSource = this.dataSet21;
- this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid2.Location = new System.Drawing.Point(424, 64);
- this.dataGrid2.Name = "dataGrid2";
- this.dataGrid2.ReadOnly = true;
- this.dataGrid2.Size = new System.Drawing.Size(264, 424);
- this.dataGrid2.TabIndex = 1;
- //
- // btnNewAccount
- //
- this.btnNewAccount.Image = ((System.Drawing.Image)(resources.GetObject("btnNewAccount.Image")));
- this.btnNewAccount.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnNewAccount.Location = new System.Drawing.Point(72, 24);
- this.btnNewAccount.Name = "btnNewAccount";
- this.btnNewAccount.Size = new System.Drawing.Size(112, 32);
- this.btnNewAccount.TabIndex = 2;
- this.btnNewAccount.Text = "建立新帐簿";
- this.btnNewAccount.Click += new System.EventHandler(this.btnNewAccount_Click);
- //
- // btnUseAccount
- //
- this.btnUseAccount.Image = ((System.Drawing.Image)(resources.GetObject("btnUseAccount.Image")));
- this.btnUseAccount.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnUseAccount.Location = new System.Drawing.Point(216, 24);
- this.btnUseAccount.Name = "btnUseAccount";
- this.btnUseAccount.Size = new System.Drawing.Size(104, 32);
- this.btnUseAccount.TabIndex = 2;
- this.btnUseAccount.Text = "启用新帐簿";
- this.btnUseAccount.Click += new System.EventHandler(this.btnUseAccount_Click);
- //
- // btnBalance
- //
- this.btnBalance.Image = ((System.Drawing.Image)(resources.GetObject("btnBalance.Image")));
- this.btnBalance.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnBalance.Location = new System.Drawing.Point(352, 24);
- this.btnBalance.Name = "btnBalance";
- this.btnBalance.Size = new System.Drawing.Size(104, 32);
- this.btnBalance.TabIndex = 2;
- this.btnBalance.Text = "试算平衡";
- this.btnBalance.Click += new System.EventHandler(this.btnBalance_Click);
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;initial catalo" +
- "g=caiwubook;persist security info=False";
- //
- // AccountSetting
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(688, 493);
- this.Controls.Add(this.btnNewAccount);
- this.Controls.Add(this.dataGrid2);
- this.Controls.Add(this.dataGrid1);
- this.Controls.Add(this.btnUseAccount);
- this.Controls.Add(this.btnBalance);
- this.Name = "AccountSetting";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【帐户设置】";
- this.Load += new System.EventHandler(this.AccountSetting_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- //------------建立新窗体时,读入所有数据-------------
- private void AccountSetting_Load(object sender, System.EventArgs e)
- {
- da1.Fill(dataSet21);
- da2.Fill(dataSet21);
- }
- //-----------建立新帐户----------
- private void btnNewAccount_Click(object sender, System.EventArgs e)
- {
- DialogResult result=MessageBox.Show("是否清除原有帐簿信息并初始化新帐簿?","警告",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
- if(result==DialogResult.OK)
- {
- string strConn = "workstation id=localhost;Integrated Security=SSPI;database=caiwubook";
- SqlConnection cn=new SqlConnection(strConn);
- cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="exec sf_初始化帐户";
- try
- {
- cmd.ExecuteNonQuery();
- dataSet21.Clear();//刷新数据集
- da1.Fill(dataSet21);
- da2.Fill(dataSet21);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"建立新帐户失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- }
- }
- //-----------启用新帐户----------
- private void btnUseAccount_Click(object sender, System.EventArgs e)
- {
- da1.Update(dataSet21);//将用户对新帐簿中数据的修改提交到数据库
- string strConn = "workstation id=localhost;Integrated Security=SSPI;database=caiwubook";
- SqlConnection cn=new SqlConnection(strConn);
- cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="select sum(累计借方) 借方,sum(累计贷方) 贷方 from 帐簿初始化表";
- SqlDataReader dr=cmd.ExecuteReader();
- dr.Read();
- if(dr.GetValue(0).ToString().Trim()!=dr.GetValue(1).ToString().Trim())//判断初始化后帐簿是否平衡
- {
- MessageBox.Show("新帐簿初始化不平衡,请检查试算平衡表后重新输入","无法启用新帐簿",MessageBoxButtons.OK,MessageBoxIcon.Error);
- return;
- }
- else
- {
- DialogResult result=MessageBox.Show("试算结果平衡,启用新帐簿将删除所有历史记录,是否继续?","确认启用新帐簿",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
- if(result==DialogResult.OK)
- {
- dr.Close();
- cmd.CommandText="exec sf_启用帐户";
- cmd.ExecuteNonQuery();
- dataSet21.Clear();//刷新数据集
- da1.Fill(dataSet21);
- da2.Fill(dataSet21);
- MessageBox.Show("新帐户启用成功!");
- }
- return;
- }
- }
- //----------新帐户的试算平衡--------
- private void btnBalance_Click(object sender, System.EventArgs e)
- {
- da1.Update(dataSet21);//将用户对新帐簿中数据的修改提交到数据库
- TrialBalance newFrm=new TrialBalance(true);
- newFrm.Text+="初始化帐户";
- newFrm.Show();
- }
- }
- }