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; } } }
public DataSet getProfitBudgetList(T_ProfitBudgetList item) { Database db = Dao.GetDatabase(); string sql = @"SELECT * FROM [dbo].[ProfitBudgetList] WHERE sale_bill_no = @sale_bill_no AND Buy_FEntryID = @Buy_FEntryID AND buy_bill_no = @buy_bill_no"; try { using (DbConnection cn = db.CreateConnection()) { DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@Buy_FEntryID", DbType.Int32, item.BuyFentryid); db.AddInParameter(cmd, "@sale_bill_no", DbType.String, item.SaleBillNo); db.AddInParameter(cmd, "@buy_bill_no", DbType.String, item.BuyBillNo); return(db.ExecuteDataSet(cmd)); } } catch { throw new Exception("执行getProfitBudgetList出错。"); } }
protected void submit_Click(object sender, EventArgs e) { ProfitBudgetAdapter pba = new ProfitBudgetAdapter(); //收集利润核算表头信息 T_ProfitAccounting item = new T_ProfitAccounting(); item.UpdateTime = DateTime.Now; decimal extra_charges = 0; if (!string.IsNullOrEmpty(txt_extra_charges.Text.Trim())) { extra_charges += Decimal.Parse(txt_extra_charges.Text.Trim()); } if (!string.IsNullOrEmpty(txt_extra_charges_lists_all.Text.Trim())) { extra_charges += Decimal.Parse(txt_extra_charges_lists_all.Text.Trim()); } item.ExtraCharges = extra_charges; item.FInterID = finterid; item.SaleBillNo = sale_bill_no; item.AuditState = false; item.IsActualAudit = false; //收集利润核算表体信息 List <T_ProfitAccountingList> lists = new List <T_ProfitAccountingList>(); List <T_ProfitBudgetList> pbls = new List <T_ProfitBudgetList>(); for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { T_ProfitAccountingList list = new T_ProfitAccountingList(); T_ProfitBudgetList pbl = new T_ProfitBudgetList(); list.FInterID = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_finter_id")).Value); list.SaleFentryid = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_sale_fentry_id")).Value); list.BuyFentryid = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_buy_fentry_id")).Value); list.FItemID = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_fitem_id")).Value); list.SaleBillNo = sale_bill_no; list.BuyBillNo = GridView1.Rows[i].Cells[0].Text; list.FName = GridView1.Rows[i].Cells[1].Text; list.FNumber = GridView1.Rows[i].Cells[2].Text; list.DeptId = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_dept_id")).Value); list.EmpId = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_emp_id")).Value); list.SalePrice = Decimal.Parse(GridView1.Rows[i].Cells[3].Text); list.Currency = GridView1.Rows[i].Cells[4].Text; TextBox txt_exchange_rate = (TextBox)GridView1.Rows[i].Cells[5].FindControl("txt_exchange_rate"); if (string.IsNullOrEmpty(txt_exchange_rate.Text)) { list.ExchangeRate = 0; } else { list.ExchangeRate = Decimal.Parse(txt_exchange_rate.Text); } list.BuyPrice = Decimal.Parse(GridView1.Rows[i].Cells[7].Text); list.SaleQty = Decimal.Parse(GridView1.Rows[i].Cells[9].Text); list.BuyQty = Decimal.Parse(GridView1.Rows[i].Cells[10].Text); list.Accessory = (GridView1.Rows[i].Cells[11].FindControl("txt_accessory") as TextBox).Text; TextBox txt_accessory_price = GridView1.Rows[i].Cells[12].FindControl("txt_accessory_price") as TextBox; if (!String.IsNullOrEmpty(txt_accessory_price.Text)) { list.AccessoryPrice = Decimal.Parse(txt_accessory_price.Text); } else { list.AccessoryPrice = 0; } string length = (GridView1.Rows[i].Cells[13].FindControl("txt_length") as TextBox).Text; if (string.IsNullOrEmpty(length)) { list.Length = 0; } else { list.Length = Decimal.Parse(length); } string width = (GridView1.Rows[i].Cells[13].FindControl("txt_width") as TextBox).Text; if (string.IsNullOrEmpty(width)) { list.Width = 0; } else { list.Width = Decimal.Parse(width); } string height = (GridView1.Rows[i].Cells[13].FindControl("txt_height") as TextBox).Text; if (string.IsNullOrEmpty(height)) { list.Height = 0; } else { list.Height = Decimal.Parse(height); } string capacity = (GridView1.Rows[i].Cells[16].FindControl("txt_capacity") as TextBox).Text; if (string.IsNullOrEmpty(capacity)) { list.Capacity = 0; } else { list.Capacity = Decimal.Parse(capacity); } string estimate_freight_charge = (GridView1.Rows[i].Cells[15].FindControl("txt_estimate_freight_charge") as TextBox).Text; if (string.IsNullOrEmpty(estimate_freight_charge)) { list.EstimateFreightCharge = 0; } else { list.EstimateFreightCharge = Decimal.Parse(estimate_freight_charge); } string tax_rate = (GridView1.Rows[i].Cells[17].FindControl("txt_tax_rate") as TextBox).Text; if (string.IsNullOrEmpty(tax_rate)) { list.TaxRate = 0; } else { list.TaxRate = Decimal.Parse(tax_rate); } list.SaleRate = GridView1.Rows[i].Cells[6].Text == "是" ? true : false; list.BuyRate = GridView1.Rows[i].Cells[8].Text == "是" ? true : false; string profit = (GridView1.Rows[i].Cells[19].FindControl("lbl_profit") as Label).Text; if (string.IsNullOrEmpty(profit)) { list.Profit = 0; } else { list.Profit = Decimal.Parse(profit); } string volume = (GridView1.Rows[i].Cells[14].FindControl("lbl_volume") as Label).Text; if (string.IsNullOrEmpty(volume)) { list.Volume = 0; } else { list.Volume = Decimal.Parse(volume); } string return_rate = (GridView1.Rows[i].Cells[18].FindControl("txt_return_rate") as TextBox).Text; if (string.IsNullOrEmpty(return_rate)) { list.ReturnRate = 0; } else { list.ReturnRate = Decimal.Parse(return_rate); } Label lbCommission = GridView1.Rows[i].Cells[20].FindControl("lbl_commission") as Label; list.Commission = Decimal.Parse(lbCommission.Text); list.SEOrderID = GridView1.Rows[i].Cells[21].Text; lists.Add(list); pbl.BuyFentryid = list.BuyFentryid; pbl.SaleBillNo = list.SEOrderID; pbl.BuyBillNo = list.BuyBillNo; DataSet ds = pba.getProfitBudgetList(pbl); decimal un_accounting_qty = Decimal.Parse(ds.Tables[0].Rows[0]["un_accounting_qty"].ToString()); pbl.UnAccountingQty = un_accounting_qty - list.SaleQty; if (un_accounting_qty - list.SaleQty == 0) { pbl.CheckStatus = true; } else { pbl.CheckStatus = false; } pbls.Add(pbl); } try { //更新check_status字段为true,如果表体相关记录check_status字段全为true //var query1 = (from tt in pbls // where tt.CheckStatus == true // select tt.SaleBillNo).Distinct().ToList(); //var query2 = (from tt in pbls // where tt.CheckStatus == false // select tt.SaleBillNo).Distinct().ToList(); //var query = query1.Except(query2).ToList(); ProfitAccountingAdapter paa = new ProfitAccountingAdapter(); paa.addProfitBudgetHead(item); paa.addProfitBudgetList(lists); pba.updateList(pbls); Label2.Text = "保存成功!"; Label2.Visible = true; } catch (Exception ex) { Label2.Text = ex.Message; Label2.Visible = true; return; } }
protected void submit_Click(object sender, EventArgs e) { //收集利润预算表头信息 T_ProfitBudget item = new T_ProfitBudget(); item.UpdateTime = DateTime.Now; decimal extra_charges = 0; if (!string.IsNullOrEmpty(txt_extra_charges.Text.Trim())) { extra_charges = Decimal.Parse(txt_extra_charges.Text.Trim()); } item.ExtraCharges = extra_charges; item.FInterID = finterid; item.SaleBillNo = sale_bill_no; item.AuditState = false; //收集利润预算表体信息 List <T_ProfitBudgetList> lists = new List <T_ProfitBudgetList>(); for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { T_ProfitBudgetList list = new T_ProfitBudgetList(); list.FInterID = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_finter_id")).Value); list.SaleFentryid = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_sale_fentry_id")).Value); list.BuyFentryid = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_buy_fentry_id")).Value); list.FItemID = Int32.Parse(((HiddenField)GridView1.Rows[i].Cells[18].FindControl("hdf_fitem_id")).Value); list.SaleBillNo = sale_bill_no; list.BuyBillNo = GridView1.Rows[i].Cells[0].Text; list.DeptId = Int32.Parse(GridView1.Rows[i].Cells[1].Text); list.EmpId = Int32.Parse(GridView1.Rows[i].Cells[2].Text); list.SalePrice = Decimal.Parse(GridView1.Rows[i].Cells[3].Text); list.Currency = GridView1.Rows[i].Cells[4].Text; TextBox txt_exchange_rate = (TextBox)GridView1.Rows[i].Cells[5].FindControl("txt_exchange_rate"); if (string.IsNullOrEmpty(txt_exchange_rate.Text)) { list.ExchangeRate = 0; } else { list.ExchangeRate = Decimal.Parse(txt_exchange_rate.Text); } list.BuyPrice = Decimal.Parse(GridView1.Rows[i].Cells[7].Text); list.SaleQty = Decimal.Parse(GridView1.Rows[i].Cells[9].Text); list.BuyQty = Decimal.Parse(GridView1.Rows[i].Cells[10].Text); list.Accessory = (GridView1.Rows[i].Cells[11].FindControl("txt_accessory") as TextBox).Text; TextBox txt_accessory_price = GridView1.Rows[i].Cells[12].FindControl("txt_accessory_price") as TextBox; if (!String.IsNullOrEmpty(txt_accessory_price.Text)) { list.AccessoryPrice = Decimal.Parse(txt_accessory_price.Text); } else { list.AccessoryPrice = 0; } string length = (GridView1.Rows[i].Cells[13].FindControl("txt_length") as TextBox).Text; if (string.IsNullOrEmpty(length)) { list.Length = 0; } else { list.Length = Decimal.Parse(length); } string width = (GridView1.Rows[i].Cells[13].FindControl("txt_width") as TextBox).Text; if (string.IsNullOrEmpty(width)) { list.Width = 0; } else { list.Width = Decimal.Parse(width); } string height = (GridView1.Rows[i].Cells[13].FindControl("txt_height") as TextBox).Text; if (string.IsNullOrEmpty(height)) { list.Height = 0; } else { list.Height = Decimal.Parse(height); } string capacity = (GridView1.Rows[i].Cells[16].FindControl("txt_capacity") as TextBox).Text; if (string.IsNullOrEmpty(capacity)) { list.Capacity = 0; } else { list.Capacity = Decimal.Parse(capacity); } string estimate_freight_charge = (GridView1.Rows[i].Cells[15].FindControl("txt_estimate_freight_charge") as TextBox).Text; if (string.IsNullOrEmpty(estimate_freight_charge)) { list.EstimateFreightCharge = 0; } else { list.EstimateFreightCharge = Decimal.Parse(estimate_freight_charge); } string tax_rate = (GridView1.Rows[i].Cells[17].FindControl("txt_tax_rate") as TextBox).Text; if (string.IsNullOrEmpty(tax_rate)) { list.TaxRate = 0; } else { list.TaxRate = Decimal.Parse(tax_rate); } list.SaleRate = GridView1.Rows[i].Cells[6].Text == "是" ? true : false; list.BuyRate = GridView1.Rows[i].Cells[8].Text == "是" ? true : false; string profit = (GridView1.Rows[i].Cells[18].FindControl("lbl_profit") as Label).Text; if (string.IsNullOrEmpty(profit)) { list.Profit = 0; } else { list.Profit = Decimal.Parse(profit); } string volume = (GridView1.Rows[i].Cells[14].FindControl("lbl_volume") as Label).Text; if (string.IsNullOrEmpty(volume)) { list.Volume = 0; } else { list.Volume = Decimal.Parse(volume); } string return_rate = (GridView1.Rows[i].Cells[18].FindControl("txt_return_rate") as TextBox).Text; if (string.IsNullOrEmpty(return_rate)) { list.ReturnRate = 0; } else { list.ReturnRate = Decimal.Parse(return_rate); } lists.Add(list); } try { ProfitBudgetAdapter pba = new ProfitBudgetAdapter(); pba.updateProfitBudgetHead(item); pba.updateProfitBudgetList(lists); Label2.Text = "保存成功!"; Label2.Visible = true; GridViewBind(); GridView2.SelectedIndex = -1; } catch (Exception ex) { Label2.Text = ex.Message; Label2.Visible = true; return; } }
public DataSet getProfitBudgetList(T_ProfitBudgetList item) { return(Manager.getProfitBudgetList(item)); }