private void MyDataGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { string strSerialNo; // = e.Item.Cells[0].Text; string strGoodsID; // = e.Item.Cells[1].Text; string strCount; // = e.Item.Cells[4].Text; ProductSerial ps; OperLog ol; ProductFacade pf; DataRow[] drs; DataTable dtProduct = GetProduct(); switch (e.CommandName) { case "AdjustAdd": strSerialNo = e.Item.Cells[0].Text; strGoodsID = e.Item.Cells[1].Text; strCount = e.Item.Cells[4].Text; string strAddCount = ((TextBox)e.Item.Cells[5].Controls[1]).Text; if (strAddCount == "") { this.Popup("请输入调增量!"); return; } if (!this.JudgeIsNum(strAddCount)) { this.Popup("请输入数字!"); return; } if (Convert.ToInt32(strAddCount) <= 0) { this.Popup("调增量必须大于零!"); return; } drs = dtProduct.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo); if (drs.Length > 0) { drs[0]["cnnAddCount"] = strAddCount; drs[0]["cnnSum"] = Convert.ToInt32(strCount) + Convert.ToInt32(strAddCount); } ps = new ProductSerial(); ps.cnnSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcCode = strGoodsID; ps.cnnAddCount = Convert.ToInt32(strAddCount); ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "生产产品调增"; pf = new ProductFacade(); pf.AdjustProductSerial_Add(ps, ol); SetProduct(dtProduct); this.Popup("调增成功!"); BindGrid(); break; case "AdjustReduce": strSerialNo = e.Item.Cells[0].Text; strGoodsID = e.Item.Cells[1].Text; strCount = e.Item.Cells[4].Text; string strReduceCount = ((TextBox)e.Item.Cells[6].Controls[1]).Text; if (strReduceCount == "") { this.Popup("请输入调减量!"); return; } if (!this.JudgeIsNum(strReduceCount)) { this.Popup("请输入数字!"); return; } if (Convert.ToInt32(strReduceCount) <= 0) { this.Popup("调减量必须大于零!"); return; } if (Convert.ToInt32(strCount) - Convert.ToInt32(strReduceCount) <= 0) { this.Popup("调减量必须小于生产量!"); return; } drs = dtProduct.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo); if (drs.Length > 0) { drs[0]["cnnReduceCount"] = strReduceCount; drs[0]["cnnSum"] = Convert.ToInt32(strCount) - Convert.ToInt32(strReduceCount); } ps = new ProductSerial(); ps.cnnSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcCode = strGoodsID; ps.cnnReduceCount = Convert.ToInt32(strReduceCount); ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "生产产品调减"; pf = new ProductFacade(); pf.AdjustProductSerial_Reduce(ps, ol); SetProduct(dtProduct); this.Popup("调减成功!"); BindGrid(); break; case "Delete": strSerialNo = e.Item.Cells[0].Text; strGoodsID = e.Item.Cells[1].Text; //strCount = e.Item.Cells[4].Text; drs = dtProduct.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo); if (drs.Length > 0) { dtProduct.Rows.Remove(drs[0]); //drs[0]["cnnCount"] = strCount; } ps = new ProductSerial(); ps.cnnSerialNo = Convert.ToInt32(strSerialNo); ps.cnvcCode = strGoodsID; ol = new OperLog(); ol.cnvcDeptID = oper.strDeptID; ol.cnvcOperID = oper.strLoginID; ol.cnvcOperType = "生产产品删除"; pf = new ProductFacade(); pf.AdjustProductSerial_Delete(ps, ol); SetProduct(dtProduct); this.Popup("生产产品删除成功!"); if ((this.MyDataGrid.CurrentPageIndex == MyDataGrid.PageCount - 1) && MyDataGrid.Items.Count == 1) { if (MyDataGrid.CurrentPageIndex - 1 > 1) { MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex - 1; } else { MyDataGrid.CurrentPageIndex = 0; } } BindGrid(); break; } }