Exemplo n.º 1
0
        private void btMod_Click(object sender, System.EventArgs e)
        {
            strLostDate = Request.Form["txtLostDate"].ToString();
            if (strLostDate == "" || strLostDate == null)
            {
                this.Popup("损耗时间不能为空,请重新选择时间!");
                return;
            }
            if (this.txtAddCount.Text.Trim() == "" || this.txtReduceCount.Text.Trim() == "")
            {
                this.Popup("调增量和调减量不能为空!");
                return;
            }
            Entity.LostSerial ls = new LostSerial();
            ls.cnnLostSerialNo = int.Parse(this.txtSerialNo.Text.Trim());
            ls.cnnAddCount     = Math.Round(decimal.Parse(this.txtAddCount.Text.Trim()), 2);
            ls.cnnReduceCount  = Math.Round(decimal.Parse(this.txtReduceCount.Text.Trim()), 2);
            ls.cndLostDate     = DateTime.Parse(strLostDate);
            ls.cnvcComments    = this.txtComments.Text.Trim();
            ls.cnvcOperID      = this.oper.strLoginID;
            if (ls.cnnLostSerialNo.ToString() == "")
            {
                this.Popup("损耗流水不正确!");
                return;
            }
            string strsql = "select count(*) from tbLostSerial a,tbCurrentStock b,tbComputationUnit c where a.cnnLostSerialNo=" + ls.cnnLostSerialNo.ToString() + " and a.cnvcInvCode=b.cnvcInvCode and a.cnvcWhCode=b.cnvcWhCode";

            strsql += " and convert(char(8),a.cndMdate,112)=convert(char(8),b.cndMdate,112) and convert(char(8),a.cndExpDate,112)=convert(char(8),b.cndExpDate,112)";
            strsql += " and a.cnvcComunitCode=c.cnvcComunitCode and a.cnnLostCount+a.cnnAddCount-a.cnnReduceCount>(b.cnnQuantity*c.cniChangRate)";
            DataTable dterrcount = Helper.Query(strsql);

            if (dterrcount.Rows.Count > 0)
            {
                this.Popup("损耗数量不能大于库存数量!");
                return;
            }

            Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog();
            ol.cnvcOperType = "修改过期损耗";
            ol.cnvcOperID   = this.oper.strLoginID;
            ol.cnvcDeptID   = this.oper.strDeptID;

            StorageFacade sto = new StorageFacade();
            int           ret = sto.UpdateLostSerial(ol, ls);

            if (ret > 0)
            {
                this.Popup("修改过期损耗成功!");
            }
            else
            {
                this.Popup("修改过期损耗失败!");
            }
        }