📄 buyfrm.cs
字号:
this.textAccount.Text = "";
//
// textSupply
//
this.textSupply.Location = new System.Drawing.Point(104, 128);
this.textSupply.Name = "textSupply";
this.textSupply.Size = new System.Drawing.Size(88, 21);
this.textSupply.TabIndex = 14;
this.textSupply.Text = "";
//
// textCost
//
this.textCost.Location = new System.Drawing.Point(336, 128);
this.textCost.Name = "textCost";
this.textCost.Size = new System.Drawing.Size(88, 21);
this.textCost.TabIndex = 15;
this.textCost.Text = "";
//
// textMan
//
this.textMan.Location = new System.Drawing.Point(104, 168);
this.textMan.Name = "textMan";
this.textMan.Size = new System.Drawing.Size(88, 21);
this.textMan.TabIndex = 16;
this.textMan.Text = "";
//
// textShow
//
this.textShow.Location = new System.Drawing.Point(336, 168);
this.textShow.Name = "textShow";
this.textShow.Size = new System.Drawing.Size(88, 21);
this.textShow.TabIndex = 17;
this.textShow.Text = "";
//
// textDate
//
this.textDate.Location = new System.Drawing.Point(104, 208);
this.textDate.Name = "textDate";
this.textDate.Size = new System.Drawing.Size(320, 21);
this.textDate.TabIndex = 18;
this.textDate.Text = "";
//
// creat_button
//
this.creat_button.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.creat_button.Location = new System.Drawing.Point(104, 256);
this.creat_button.Name = "creat_button";
this.creat_button.Size = new System.Drawing.Size(72, 24);
this.creat_button.TabIndex = 19;
this.creat_button.Text = "生成";
this.creat_button.Click += new System.EventHandler(this.creat_button_Click);
//
// esc_button
//
this.esc_button.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.esc_button.Location = new System.Drawing.Point(280, 256);
this.esc_button.Name = "esc_button";
this.esc_button.Size = new System.Drawing.Size(72, 24);
this.esc_button.TabIndex = 20;
this.esc_button.Text = "退出";
this.esc_button.Click += new System.EventHandler(this.esc_button_Click);
//
// buyAdapter
//
this.buyAdapter.DeleteCommand = this.sqlDeleteCommand1;
this.buyAdapter.InsertCommand = this.sqlInsertCommand1;
this.buyAdapter.SelectCommand = this.sqlSelectCommand1;
this.buyAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "buyTable", 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("报表时间", "报表时间")})});
this.buyAdapter.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM buyTable 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) 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.DateTime, 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, 10, 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, 10, 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, 10, 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, 10, 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, 10, 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, 10, 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, 10, 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, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "购买数量", System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=727CE26111204C4;packet size=4096;user id=sa;data source=\".\";persis" +
"t security info=False;initial catalog=storage";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO buyTable(设备号, 现有库存, 最大库存, 购买数量, 供应商, 价格, 制表人, 备注, 报表时间) VALUES (@设备号," +
" @现有库存, @最大库存, @购买数量, @供应商, @价格, @制表人, @备注, @报表时间); SELECT 设备号, 现有库存, 最大库存, 购买数量" +
", 供应商, 价格, 制表人, 备注, 报表时间 FROM buyTable WHERE (报表时间 = @报表时间)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@设备号", System.Data.SqlDbType.VarChar, 10, "设备号"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@现有库存", System.Data.SqlDbType.VarChar, 10, "现有库存"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@最大库存", System.Data.SqlDbType.VarChar, 10, "最大库存"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@购买数量", System.Data.SqlDbType.VarChar, 10, "购买数量"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@供应商", System.Data.SqlDbType.VarChar, 10, "供应商"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@价格", System.Data.SqlDbType.VarChar, 10, "价格"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@制表人", System.Data.SqlDbType.VarChar, 10, "制表人"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 10, "备注"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@报表时间", System.Data.SqlDbType.DateTime, 8, "报表时间"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 设备号, 现有库存, 最大库存, 购买数量, 供应商, 价格, 制表人, 备注, 报表时间 FROM buyTable";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE buyTable 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) 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 buyTable WHERE (报表时间 = @报表时间)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@设备号", System.Data.SqlDbType.VarChar, 10, "设备号"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@现有库存", System.Data.SqlDbType.VarChar, 10, "现有库存"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@最大库存", System.Data.SqlDbType.VarChar, 10, "最大库存"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@购买数量", System.Data.SqlDbType.VarChar, 10, "购买数量"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@供应商", System.Data.SqlDbType.VarChar, 10, "供应商"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@价格", System.Data.SqlDbType.VarChar, 10, "价格"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@制表人", System.Data.SqlDbType.VarChar, 10, "制表人"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 10, "备注"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@报表时间", System.Data.SqlDbType.DateTime, 8, "报表时间"));
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, 10, 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, 10, 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, 10, 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, 10, 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, 10, 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, 10, 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, 10, 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, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "购买数量", System.Data.DataRowVersion.Original, null));
//
// buyFrm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(456, 326);
this.Controls.Add(this.esc_button);
this.Controls.Add(this.creat_button);
this.Controls.Add(this.textDate);
this.Controls.Add(this.textShow);
this.Controls.Add(this.textMan);
this.Controls.Add(this.textCost);
this.Controls.Add(this.textSupply);
this.Controls.Add(this.textAccount);
this.Controls.Add(this.textMaxNum);
this.Controls.Add(this.textNowNum);
this.Controls.Add(this.textNum);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "buyFrm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "采购计划";
this.Load += new System.EventHandler(this.buyFrm_Load);
this.ResumeLayout(false);
}
#endregion
private void buyFrm_Load(object sender, System.EventArgs e)
{
this.textNum.Focus();
this.textDate.Text=DateTime.Now.ToString();
}
private void esc_button_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void creat_button_Click(object sender, System.EventArgs e)
{
if(this.textNum.Text.Trim()==""||this.textAccount.Text.Trim()=="")
{
MessageBox.Show("设备号,购买数量不能为空");
return;
}
DataTable buyInfo=new DataTable();
buyAdapter.UpdateCommand.Connection=MyConn;
buyAdapter.InsertCommand.Connection=MyConn;
buyAdapter.SelectCommand.Connection=MyConn;
MyConn.Open();
buyAdapter.Fill(buySet);
DataRow buyInfoRow = this.buySet.Tables[0].NewRow();//建立新记录
buyInfoRow["设备号"] = this.textNum.Text.Trim();
buyInfoRow["现有库存"] = this.textNowNum.Text.Trim();
buyInfoRow["最大库存"] = this.textMaxNum.Text.Trim();
buyInfoRow["购买数量"] = this.textAccount.Text.Trim();
buyInfoRow["供应商"] = this.textSupply.Text.Trim();
buyInfoRow["价格"] = this.textCost.Text.Trim();
buyInfoRow["制表人"] = this.textMan.Text.Trim();
buyInfoRow["备注"] = this.textShow.Text.Trim();
buyInfoRow["报表时间"] = this.textDate.Text.Trim();
this.buySet.Tables[0].Rows.Add(buyInfoRow);
this.buyAdapter.Update(buySet);
MessageBox.Show("OK");
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -