📄 stockmaster.aspx.cs
字号:
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_code_value", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "code_value", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_closing", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "closing", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_closing1", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "closing", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_code_display", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "code_display", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_opening", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "opening", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_opening1", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "opening", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_rate", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "rate", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_rate1", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "rate", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_uom", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "uom", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_uom1", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "uom", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Select_code_value", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "code_value", System.Data.DataRowVersion.Current, null));
this.Add.Click += new System.EventHandler(this.Add_Click);
this.SaveNew.Click += new System.EventHandler(this.SaveNew_Click);
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.dsStock1)).EndInit();
}
#endregion
public void Bind()
{
sqlDataAdapter1.Fill(dsStock1);
DataGrid1.DataSource=dsStock1;
DataGrid1.DataBind();
if ( AddPanel.Visible==true)
{AddPanel.Visible=false;}
}
public void Grid1_Edit(Object sender, DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = e.Item.ItemIndex;
Bind();
}
public void Grid1_Cancel(Object sender, DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = -1;
Bind();
}
public void Grid1_Update(Object sender, DataGridCommandEventArgs e)
{
TextBox t;
//This is the primary key
int Key= (int)DataGrid1.DataKeys[(int)e.Item.ItemIndex];
String code_value = " code_value =" + Key.ToString() ;
t = (TextBox) e.Item.FindControl("editCode_Display");
String code_display = " code_display = '" + t.Text.Trim() + "'," ;
t = (TextBox) e.Item.FindControl("editRate");
String rate = " rate = " + t.Text.Trim() + "," ;
t = (TextBox) e.Item.FindControl("editUom");
String uom = " uom ='" + t.Text.Trim() + "'," ;
t = (TextBox) e.Item.FindControl("editOpening");
String opening = " opening = " + t.Text.Trim() ;
String s = " Update stock_master Set";
s += code_display +rate +uom ;
s += opening ;
s += " Where " + code_value;
RunSql(s);
DataGrid1.EditItemIndex = -1;
Bind();
}
public void Grid1_Delete(Object sender, DataGridCommandEventArgs e)
{
int Key= (int)DataGrid1.DataKeys[(int)e.Item.ItemIndex];
String code_value = Key.ToString() ;
String s = "Delete from stock_master";
s +=" where code_value = " + code_value;
RunSql(s);
DataGrid1.EditItemIndex = -1;
Bind();
}
public String RunSql( string vsql)
{
try
{
SqlCommand mycommand = new SqlCommand(vsql,sqlConnection1);
sqlConnection1.Open();
mycommand.ExecuteNonQuery();
sqlConnection1.Close();
}
catch(Exception e)
{
string ret = "Exception: " + e.ToString() ;
messages.Text=ret;
}
return("OK");
}
private void Add_Click(object sender, System.EventArgs e)
{
AddPanel.Visible=true;
AddCode_Display.Text= "";
AddRate.Text= "0";
AddUom.Text= "";
AddClosing.Text= "0";
}
private void SaveNew_Click(object sender, System.EventArgs e)
{
if (AddCode_Display.Text.Length == 0)
{
messages.Text="Sorry - Account Name cannot be blank";
return ;
}
if (AddRate.Text.Length == 0)
{AddRate.Text= "0";}
if (AddUom.Text.Length == 0)
{AddUom.Text= "";}
if (AddClosing.Text.Length == 0)
{AddClosing.Text= "0";}
String s = "Execute p_stock_master ";
s += " @code_value=NULL," ;
s += " @code_display = '" + AddCode_Display.Text + "',";
s += " @rate = " + AddRate.Text + ",";
s += " @uom = '" + AddUom.Text + "',";
s += " @closing = " + AddClosing.Text ;
messages.Text= "";
RunSql(s);
DataGrid1.EditItemIndex = -1;
Bind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -