private void btnAddList_Click(object sender, System.EventArgs e) { if (this.JudgeIsNull(txtCount.Text, "数量")) { return; } if (!this.JudgeIsNum(txtCount.Text, "数量")) { return; } if (decimal.Parse(txtCount.Text) <= 0) { Popup("数量必需大于零"); return; } if (this.DataGrid1.Items.Count > 0) { //放入清单 foreach (DataGridItem dgi in this.DataGrid1.Items) { OrderBookDetail productList = new OrderBookDetail(); productList.cnnOrderCount = decimal.Parse(txtCount.Text); productList.cnvcInvCode = dgi.Cells[0].Text; GetProductListTable(productList.ToTable()); } BindProduct(); } BindGrid(); this.DataGrid1.Visible = false; this.DataGrid2.Visible = true; }
private void GetProductListTable(DataTable dtOrderBookDetail) { DataTable dtProductList = null; if (Session["ProductList"] == null) { OrderBookDetail detail = new OrderBookDetail(); dtProductList = detail.ToTable().Clone(); dtProductList.Columns.Add("cnvcinvname"); dtProductList.Columns.Add("cnfretailprice"); dtProductList.Columns.Add("cnvcProduceUnitCode"); dtProductList.Columns.Add("cnvccomunitname"); dtProductList.Columns.Add("cnnsum"); } else { dtProductList = (DataTable)Session["ProductList"]; } this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnvcinvname", "tbInventory", "cnvcinvcode", "cnvcinvname", ""); this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnfretailprice", "tbInventory", "cnvcinvcode", "cnfretailprice", ""); this.DataTableConvert(dtOrderBookDetail, "cnvcinvcode", "cnvcProduceUnitCode", "tbInventory", "cnvcinvcode", "cnvcProduceUnitCode", ""); this.DataTableConvert(dtOrderBookDetail, "cnvcProduceUnitCode", "cnvccomunitname", "tbComputationUnit", "cnvccomunitcode", "cnvccomunitname", ""); object[] oArray = new object[dtOrderBookDetail.Columns.Count]; dtOrderBookDetail.Rows[0].ItemArray.CopyTo(oArray, 0); dtProductList.Rows.Add(oArray); foreach (DataRow dr in dtProductList.Rows) { //Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(dr); double sum = Convert.ToDouble(dr["cnnordercount"].ToString()) * Convert.ToDouble(dr["cnfretailprice"].ToString()); dr["cnnsum"] = sum; } Session["ProductList"] = dtProductList; }
private void btnBatchAddList_Click(object sender, System.EventArgs e) { //批量放入清单 try { if (this.DataGrid1.Items.Count > 0) { //放入清单 foreach (DataGridItem dgi in this.DataGrid1.Items) { string strCount = ((TextBox)dgi.Cells[4].Controls[1]).Text; if (this.JudgeIsNull(strCount)) { continue; } if (!this.JudgeIsNum(strCount, "数量")) { return; } if (decimal.Parse(strCount) <= 0) { Popup("数量必需大于零"); return; } OrderBookDetail productList = new OrderBookDetail(); productList.cnnOrderCount = decimal.Parse(strCount); productList.cnvcInvCode = dgi.Cells[0].Text; this.GetProductListTable(productList.ToTable()); } BindProduct(); } if ((DataGrid1.CurrentPageIndex == DataGrid1.PageCount - 1) && DataGrid1.Items.Count == 1) { if (DataGrid1.CurrentPageIndex - 1 > 1) { DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex - 1; } else { DataGrid1.CurrentPageIndex = 0; } } BindGrid(); this.DataGrid1.Visible = false; this.DataGrid2.Visible = true; } catch (Exception ex) { Popup(ex.Message); } }
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "putin") { //放入清单 string strCount = ((TextBox)e.Item.Cells[4].Controls[1]).Text; if (this.JudgeIsNull(strCount, "数量")) { return; } if (!this.JudgeIsNum(strCount, "数量")) { return; } if (decimal.Parse(strCount) <= 0) { Popup("数量必需大于零"); return; } OrderBookDetail productList = new OrderBookDetail(); productList.cnnOrderCount = decimal.Parse(((TextBox)e.Item.Cells[4].Controls[1]).Text); productList.cnvcInvCode = e.Item.Cells[0].Text; GetProductListTable(productList.ToTable()); if ((DataGrid1.CurrentPageIndex == DataGrid1.PageCount - 1) && DataGrid1.Items.Count == 1) { if (DataGrid1.CurrentPageIndex - 1 > 1) { DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex - 1; } else { DataGrid1.CurrentPageIndex = 0; } } BindProduct(); } }