创建表,如名称 StckDetails
在此处输入图像描述
在使用 anme sp_StckDetails1 ALTER procedure [dbo].[sp_StockDetails1] 创建过程后(
@Action varchar(20), @Branch_ID int=null, @Stock_Name varchar(50)=null, @Stock_code varchar(20)=null, @Qty int =null, @Purchase_Price decimal(18,0)=null, @Sales_Price decimal(18,0)=null, @Order_ID int=null ) 作为 BEGIN SET NOCOUNT ON; if @Action='Update' begin update StockDetails set Qty=@Qty,Purchase_Price= @Purchase_Price,Sales_price=@Sales_Price where Order_ID=@Order_ID end End
然后添加 c#code is Label lbl_id = GridView2.Rows[e.RowIndex].FindControl("Label2") as Label; TextBox txt1_qty = GridView2.Rows[e.RowIndex].FindControl("TextBox7") as TextBox; TextBox txt2_PP = GridView2.Rows[e.RowIndex].FindControl("TextBox8") as TextBox; TextBox txt3_sp = GridView2.Rows[e.RowIndex].FindControl("TextBox9") as TextBox;
SqlCommand cmd = new SqlCommand("sp_StockDetails1", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "Update");
cmd.Parameters.AddWithValue("@Order_ID", SqlDbType.Int).Value = Convert.ToInt32(lbl_id.Text);
cmd.Parameters.AddWithValue("@Qty", SqlDbType.Int).Value = Convert.ToInt32(txt1_qty.Text);
cmd.Parameters.AddWithValue("@Purchase_Price", SqlDbType.Decimal).Value = Convert.ToDecimal(txt2_PP.Text);
cmd.Parameters.AddWithValue("@Sales_Price", SqlDbType.Decimal).Value = Convert.ToDecimal(txt3_sp.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
GridView2.EditIndex = -1;
fillgrid2();
Gridview设计代码是aspx代码
'>'>'>'>'>'>'>'> '> '> ......................................................................................................................................................
试试看它会说话