?? 收費管理.cs
字號:
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE 收費流水表 SET 時間 = @時間, 條形碼 = @條形碼, 值班教師 = @值班教師, 收費 = @收費, 充值 = @充值 WHERE (ID = @Original_ID) 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 ID, 時間, 條形碼, 值班教師, 收費, 充值 FROM 收費流水表 WHERE (ID = @ID)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@時間", System.Data.SqlDbType.DateTime, 8, "時間"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@條形碼", System.Data.SqlDbType.VarChar, 50, "條形碼"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@值班教師", System.Data.SqlDbType.VarChar, 50, "值班教師"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@收費", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(5)), ((System.Byte)(2)), "收費", System.Data.DataRowVersion.Current, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@充值", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(5)), ((System.Byte)(2)), "充值", System.Data.DataRowVersion.Current, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_值班教師", System.Data.SqlDbType.VarChar, 50, 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.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(5)), ((System.Byte)(2)), "充值", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_收費", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(5)), ((System.Byte)(2)), "收費", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_時間", System.Data.SqlDbType.DateTime, 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, 50, 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("@ID", System.Data.SqlDbType.BigInt, 8, "ID"));
//
// button1
//
this.button1.Location = new System.Drawing.Point(560, 376);
this.button1.Name = "button1";
this.button1.TabIndex = 3;
this.button1.Text = "提交修改";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand2;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand2;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand2;
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("ID", "ID"),
new System.Data.Common.DataColumnMapping("姓名", "姓名"),
new System.Data.Common.DataColumnMapping("密碼", "密碼"),
new System.Data.Common.DataColumnMapping("權限", "權限")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand2;
//
// sqlDeleteCommand2
//
this.sqlDeleteCommand2.CommandText = "DELETE FROM 操作員表 WHERE (ID = @Original_ID) AND (姓名 = @Original_姓名 OR @Original_姓名" +
" IS NULL AND 姓名 IS NULL) AND (密碼 = @Original_密碼 OR @Original_密碼 IS NULL AND 密碼 I" +
"S NULL) AND (權限 = @Original_權限 OR @Original_權限 IS NULL AND 權限 IS NULL)";
this.sqlDeleteCommand2.Connection = this.sqlConnection1;
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_密碼", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "密碼", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_權限", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "權限", System.Data.DataRowVersion.Original, null));
//
// sqlInsertCommand2
//
this.sqlInsertCommand2.CommandText = "INSERT INTO 操作員表(姓名, 密碼, 權限) VALUES (@姓名, @密碼, @權限); SELECT ID, 姓名, 密碼, 權限 FROM 操" +
"作員表 WHERE (ID = @@IDENTITY)";
this.sqlInsertCommand2.Connection = this.sqlConnection1;
this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 50, "姓名"));
this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@密碼", System.Data.SqlDbType.VarChar, 50, "密碼"));
this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@權限", System.Data.SqlDbType.VarChar, 50, "權限"));
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "SELECT ID, 姓名, 密碼, 權限 FROM 操作員表";
this.sqlSelectCommand2.Connection = this.sqlConnection1;
//
// sqlUpdateCommand2
//
this.sqlUpdateCommand2.CommandText = @"UPDATE 操作員表 SET 姓名 = @姓名, 密碼 = @密碼, 權限 = @權限 WHERE (ID = @Original_ID) 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 ID, 姓名, 密碼, 權限 FROM 操作員表 WHERE (ID = @ID)";
this.sqlUpdateCommand2.Connection = this.sqlConnection1;
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 50, "姓名"));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@密碼", System.Data.SqlDbType.VarChar, 50, "密碼"));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@權限", System.Data.SqlDbType.VarChar, 50, "權限"));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_密碼", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "密碼", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_權限", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "權限", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.Int, 4, "ID"));
//
// 收費管理
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(692, 416);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.dataGrid3);
this.Font = new System.Drawing.Font("宋體", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.Name = "收費管理";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "收費管理";
this.Load += new System.EventHandler(this.收費管理_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid3)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void 收費管理_Load(object sender, System.EventArgs e)
{
this.sqlDataAdapter3.SelectCommand.CommandText="select * from 收費流水表 where 值班教師='"+ frmMain.strTeacher +"'";
this.sqlDataAdapter3.Fill(sds,"收費流水表");
this.dataGrid3.SetDataBinding(this.sds,"收費流水表");
this.dataGrid3.Refresh();
DataSet dsTeacher=new DataSet();
this.sqlDataAdapter1.Fill(dsTeacher,"操作員表");
this.comboBox1.DataSource=dsTeacher.Tables["操作員表"];
DataRow myRow;
myRow = dsTeacher.Tables["操作員表"].NewRow();
// Then add the new row to the collection.
myRow["ID"] = "100";
myRow["姓名"] = "所有人";
dsTeacher.Tables["操作員表"].Rows.Add(myRow);
this.comboBox1.DisplayMember="姓名";
this.comboBox1.SelectedIndex=this.comboBox1.Items.Count-1;
}
private void comboBox1_Click(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
this.sqlDataAdapter3.Update(sds,"收費流水表");
MessageBox.Show("修改成功!","系統維護",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(SqlException)
{
MessageBox.Show("修改無效,請檢查輸入!","系統維護",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
finally
{
//this.sqlConnection2.Close();
}
this.dataGrid3.Refresh();
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.comboBox1.Text=="所有人")
{
sds.Tables["收費流水表"].Clear();
string sql="select * from 收費流水表";
this.sqlDataAdapter3.SelectCommand.CommandText=sql;
this.sqlDataAdapter3.Fill(sds,"收費流水表");
this.dataGrid3.SetDataBinding(sds,"收費流水表");
this.dataGrid3.Refresh();
}
else
{
sds.Tables["收費流水表"].Clear();
string sql="select * from 收費流水表 where 值班教師='"+ this.comboBox1.Text +"'";
this.sqlDataAdapter3.SelectCommand.CommandText=sql;
this.sqlDataAdapter3.Fill(sds,"收費流水表");
this.dataGrid3.SetDataBinding(sds,"收費流水表");
this.dataGrid3.Refresh();
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -