Example #1
0
        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;
            LostSerial    ps;
            OperLog       ol;
            ProductFacade pf;

            DataRow[] drs;
            DataTable dtProduct = GetProduct();

            if (e.CommandName == "Delete")
            {
                strSerialNo = e.Item.Cells[0].Text;
                strGoodsID  = e.Item.Cells[1].Text;
                //strCount = e.Item.Cells[4].Text;
                drs = dtProduct.Select("cnvcInvCode='" + strGoodsID + "' and cnnLostSerialNo=" + strSerialNo);
                if (drs.Length > 0)
                {
                    dtProduct.Rows.Remove(drs[0]);
                    //drs[0]["cnnCount"] = strCount;
                }

                ps = new LostSerial();
                ps.cnnLostSerialNo = Convert.ToInt32(strSerialNo);
                ps.cnvcInvCode     = strGoodsID;

                ol              = new OperLog();
                ol.cnvcDeptID   = oper.strDeptID;
                ol.cnvcOperID   = oper.strLoginID;
                ol.cnvcOperType = "生产产品报损删除";

                pf = new ProductFacade();
                pf.AdjustProductLostSerial_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();
            }
            else if (e.CommandName == "Adjust")
            {
                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;
                string strReduceCount = ((TextBox)e.Item.Cells[6].Controls[1]).Text;

                if (strAddCount == "")
                {
                    this.Popup("请输入调增量!");
                    return;
                }
                if (!this.JudgeIsNum(strAddCount))
                {
                    this.Popup("调增量请输入数字!");
                    return;
                }
                if (Convert.ToDecimal(strAddCount) <= 0)
                {
                    this.Popup("调增量必须大于等于零!");
                    return;
                }
                if (strReduceCount == "")
                {
                    this.Popup("请输入调减量!");
                    return;
                }
                if (!this.JudgeIsNum(strReduceCount))
                {
                    this.Popup("调减量请输入数字!");
                    return;
                }
                if (Convert.ToInt32(strReduceCount) <= 0)
                {
                    this.Popup("调减量必须大于零!");
                    return;
                }

                if (Convert.ToDecimal(strCount) + Convert.ToDecimal(strAddCount) - Convert.ToDecimal(strReduceCount) <= 0)
                {
                    this.Popup("调减量必须小于报损量加调增量!");
                    return;
                }

                //				switch(e.CommandName)
                //				{
                //					case "AdjustAdd":
                drs = dtProduct.Select("cnvcInvCode='" + strGoodsID + "' and cnnLostSerialNo=" + strSerialNo);
                if (drs.Length > 0)
                {
                    drs[0]["cnnAddCount"]    = strAddCount;
                    drs[0]["cnnReduceCount"] = strReduceCount;
                    drs[0]["cnnSum"]         = Convert.ToDecimal(strCount) + Convert.ToDecimal(strAddCount) - Convert.ToDecimal(strReduceCount);
                }
                ps = new LostSerial();
                ps.cnnLostSerialNo = Convert.ToInt32(strSerialNo);
                ps.cnvcInvCode     = strGoodsID;
                ps.cnnAddCount     = Convert.ToDecimal(strAddCount);

                ol              = new OperLog();
                ol.cnvcDeptID   = oper.strDeptID;
                ol.cnvcOperID   = oper.strLoginID;
                ol.cnvcOperType = "生产产品报损调增";

                pf = new ProductFacade();
                pf.AdjustProductLostSerial_Add(ps, ol);


                SetProduct(dtProduct);
                this.Popup("调整成功!");
                BindGrid();
                //						break;
                //					case "AdjustReduce":
                //						drs = dtProduct.Select("cnvcInvCode='"+strGoodsID+"' and cnnLostSerialNo="+strSerialNo);
                //						if(drs.Length>0)
                //						{
                //							drs[0]["cnnReduceCount"] = strReduceCount;
                //							drs[0]["cnnSum"] = Convert.ToDecimal(strCount)-Convert.ToDecimal(strReduceCount);
                //						}
                //
                //						ps = new LostSerial();
                //						ps.cnnLostSerialNo = Convert.ToInt32(strSerialNo);
                //						ps.cnvcInvCode = strGoodsID;
                //						ps.cnnReduceCount = Convert.ToDecimal(strReduceCount);
                //
                //
                //						ol = new OperLog();
                //						ol.cnvcDeptID = oper.strDeptID;
                //						ol.cnvcOperID = oper.strLoginID;
                //						ol.cnvcOperType = "生产产品报损调减";
                //
                //						pf = new ProductFacade();
                //						pf.AdjustProductLostSerial_Reduce(ps,ol);
                //
                //						SetProduct(dtProduct);
                //						this.Popup("调减成功!");
                //						BindGrid();
                //						break;
            }
        }