protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = null; if (e.CommandName == "Delete") { string sale_bill_no = e.CommandArgument.ToString(); //获取当前行 Control cmdControl = e.CommandSource as Control; row = cmdControl.NamingContainer as GridViewRow; finterid = Int32.Parse((row.Cells[0].FindControl("hdf_finter_id") as HiddenField).Value); ProfitAccountingAdapter paa = new ProfitAccountingAdapter(); DataSet ds = paa.getProfitBudgetByID(finterid, sale_bill_no); List <T_ProfitBudgetList> lists = new List <T_ProfitBudgetList>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { T_ProfitBudgetList list = new T_ProfitBudgetList(); DataRow dr = ds.Tables[0].Rows[i]; list.BuyFentryid = Int32.Parse(dr["Buy_FEntryID"].ToString()); list.SaleBillNo = dr["SEOrderID"].ToString(); list.BuyBillNo = dr["buy_bill_no"].ToString(); list.UnAccountingQty = decimal.Parse(dr["sale_qty"].ToString()); list.CheckStatus = false; lists.Add(list); } ProfitBudgetAdapter pba = new ProfitBudgetAdapter(); try { paa.deleteBySaleBillNo(sale_bill_no); pba.AddUnAccountingQtyBecauseDelete(lists); GridViewBind(); clean(); GridView1.DataSource = ""; GridView1.DataBind(); Label2.Visible = true; Label2.Text = "删除成功"; } catch (Exception ex) { Label2.Text = ex.Message; } } }
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { string sale_bill_no = e.CommandArgument.ToString(); ProfitAccountingAdapter pba = new ProfitAccountingAdapter(); try { pba.deleteBySaleBillNo(sale_bill_no); GridViewBind(); clean(); GridView1.DataSource = ""; GridView1.DataBind(); Label2.Visible = true; Label2.Text = "删除成功"; } catch (Exception ex) { Label2.Text = ex.Message; } } }