?? selinstg.cs
字號:
this.InStgAdapter.DeleteCommand = this.sqlDeleteCommand1;
this.InStgAdapter.InsertCommand = this.sqlInsertCommand1;
this.InStgAdapter.SelectCommand = this.sqlSelectCommand1;
this.InStgAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "storage_In", 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.InStgAdapter.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM storage_In WHERE (設備號 = @Original_設備號) AND (價格 = @Original_價格 OR @Original_價格 IS NULL AND 價格 IS NULL) AND (供應商 = @Original_供應商) AND (供應商電話 = @Original_供應商電話 OR @Original_供應商電話 IS NULL AND 供應商電話 IS NULL) AND (入庫日期 = @Original_入庫日期 OR @Original_入庫日期 IS NULL AND 入庫日期 IS NULL) AND (數量 = @Original_數量) 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, 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.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));
//
// 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 storage_In(設備號, 入庫日期, 供應商, 供應商電話, 數量, 價格, 采購員) VALUES (@設備號, @入庫日期, @" +
"供應商, @供應商電話, @數量, @價格, @采購員); SELECT 設備號, 入庫日期, 供應商, 供應商電話, 數量, 價格, 采購員 FROM sto" +
"rage_In 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.DateTime, 8, "入庫日期"));
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, "采購員"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 設備號, 入庫日期, 供應商, 供應商電話, 數量, 價格, 采購員 FROM storage_In";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE storage_In SET 設備號 = @設備號, 入庫日期 = @入庫日期, 供應商 = @供應商, 供應商電話 = @供應商電話, 數量 = @數量, 價格 = @價格, 采購員 = @采購員 WHERE (設備號 = @Original_設備號) AND (價格 = @Original_價格 OR @Original_價格 IS NULL AND 價格 IS NULL) AND (供應商 = @Original_供應商) AND (供應商電話 = @Original_供應商電話 OR @Original_供應商電話 IS NULL AND 供應商電話 IS NULL) AND (入庫日期 = @Original_入庫日期 OR @Original_入庫日期 IS NULL AND 入庫日期 IS NULL) AND (數量 = @Original_數量) AND (采購員 = @Original_采購員 OR @Original_采購員 IS NULL AND 采購員 IS NULL); SELECT 設備號, 入庫日期, 供應商, 供應商電話, 數量, 價格, 采購員 FROM storage_In 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.DateTime, 8, "入庫日期"));
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("@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.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));
//
// SelInStg
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 318);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.groupBox1);
this.Name = "SelInStg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "入庫信息查詢";
this.Load += new System.EventHandler(this.SelInStg_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void SelInStg_Load(object sender, System.EventArgs e)
{
try
{
this.sqlConnection1.ConnectionString= "server=.;Trusted_Connection=yes;user=sa;pwd=1;database=storage";//建立連接
this.sqlConnection1.Open();
DataSet InStgSet=new DataSet();
InStgAdapter.SelectCommand.CommandText="SELECT * FROM storage_In";
InStgAdapter.SelectCommand.Connection=sqlConnection1;
InStgAdapter.Fill(InStgInfo);
DataGridTableStyle instg = new DataGridTableStyle();
instg.AlternatingBackColor = Color.Blue;//顏色設置
instg.MappingName = InStgInfo.TableName;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
}
private void sel_button1_Click(object sender, System.EventArgs e)
{
string condition = "";
if(this.textNum.Text.Trim() != "")//設置表的過濾條件
{
condition += "設備號 like '%" + textNum.Text.Trim() + "%'";
if(this.textSupply.Text.Trim() != "")
{
condition += "and 供應商 like '%" + textSupply.Text.Trim() + "%" + "'";
}
}
else
{
if(this.textSupply.Text.Trim()!="")
{
condition += "供應商 like '%" + textSupply.Text.Trim() + "%'";
}
else
{
MessageBox.Show("請輸入查詢條件");
return;
}
}
InStgInfo.DefaultView.RowFilter=condition;
this.dataGrid1.DataSource = InStgInfo.DefaultView;
if(this.dataGrid1.VisibleRowCount==1)//判斷檢索條件是否與記錄匹配
{
MessageBox.Show("對不起,入庫數據中沒有與您檢索條件相匹配的記錄!");
return;
}
this.textNum.Clear();
this.textSupply.Clear();
}
private void textNum_TextChanged(object sender, System.EventArgs e)
{
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -