📄 收费管理.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 + -