Exemplo n.º 1
0
        protected override void cmdAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtWWPoSerialEdit.Text))
            {
                return;
            }
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider);
            }



            BenQGuru.eMES.Domain.Warehouse.Pick p = (BenQGuru.eMES.Domain.Warehouse.Pick)_WarehouseFacade.GetPick(txtPickNoQuery.Text);


            if (p.Status != Pick_STATUS.Status_Release)
            {
                WebInfoPublish.Publish(this, p.PickNo + "拣货任务令的状态必须是初始化才能修改!", this.languageComponent1);
                return;
            }
            BenQGuru.eMES.Domain.Warehouse.PickDetail pick = new BenQGuru.eMES.Domain.Warehouse.PickDetail();

            string serialList = this.MoldidToSql(txtWWPoSerialEdit.Text);

            object[] wwpoList = _WarehouseFacade.QuerySelectedWWpoInvNo(serialList);


            #region 注释
            //pick.PickNo = txtPickNoEdit.Text;
            //pick.PickType = drpPickTypeEdit.SelectedValue;
            //pick.InvNo = txtInvNoEdit.Text;
            //pick.StorageCode = drpStorageCodeEdit.SelectedValue;
            //pick.ReceiverUser = txtReceiverUserEdit.Text;
            //pick.Receiveraddr = txtReceiverAddrEdit.Text;
            //pick.PlanDate = FormatHelper.TODateInt(txtPlanDateEdit.Text);
            //pick.Remark1 = txtREMARKEdit.Text;
            #endregion

            try
            {
                this.DataProvider.BeginTransaction();
                foreach (MesWWPOExc wwpo in wwpoList)
                {
                    //BenQGuru.eMES.Domain.MOModel.Material m = (BenQGuru.eMES.Domain.MOModel.Material)_WarehouseFacade.GetMaterialFromDQMCode(wwpo.DQMCode);
                    //if (m == null)
                    //{
                    //    this.DataProvider.RollbackTransaction();
                    //    WebInfoPublish.Publish(this, "鼎桥物料号不存在", this.languageComponent1);
                    //    return;
                    //}
                    #region add by sam Picktopo

                    PickToPo pickToPo = new PickToPo();
                    pickToPo.PickNo       = txtPickNoQuery.Text;
                    pickToPo.DQMCode      = wwpo.DQMCode; // txtDQMCodeEdit.Text;
                    pickToPo.PickLine     = (_WarehouseFacade.GetMaxLine(txtPickNoQuery.Text) + 1).ToString();
                    pickToPo.MCode        = wwpo.MCode;   // string.IsNullOrEmpty(m.MCode) ? " " : m.MCode;
                    pickToPo.MaintainDate = FormatHelper.TODateInt(DateTime.Now);
                    pickToPo.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                    pickToPo.MaintainUser = this.GetUserCode();


                    pickToPo.PoNo   = FormatHelper.CleanString(txtInvNoEidt.Text);
                    pickToPo.PoLine = wwpo.POLine.ToString();
                    _WarehouseFacade.AddPickToPo(pickToPo);

                    #endregion

                    #region add by sam 检查qty

                    //int invline = 0;
                    //if (!string.IsNullOrEmpty(txtInvLineEidt.Text))
                    //{
                    //    invline = Convert.ToInt32(txtInvLineEidt.Text);
                    //}
                    int     invline = wwpo.POLine;
                    string  mcode   = wwpo.MCode; // string.IsNullOrEmpty(m.MCode) ? " " : m.MCode;
                    string  invno   = FormatHelper.CleanString(txtInvNoEidt.Text);
                    decimal decqty  = 0;          // decimal.Parse(txtNumEdit.Text);
                    //decimal pickqty = _WarehouseFacade.GetPickDetailQty(invno, invline, mcode);
                    //decimal wwpoqty = _WarehouseFacade.GetWWPOQty(invno, invline, mcode);
                    //if (decqty + pickqty > wwpoqty)
                    //{
                    //    WebInfoPublish.Publish(this, "领料数量大于库存数量", this.languageComponent1);
                    //}
                    #endregion


                    pick.PickNo   = txtPickNoQuery.Text;
                    pick.DQMCode  = wwpo.DQMCode;// txtDQMCodeEdit.Text;
                    pick.MDesc    = wwpo.MChLongDesc;
                    pick.PickLine = (_WarehouseFacade.GetMaxLine(txtPickNoQuery.Text) + 1).ToString();
                    pick.MCode    = wwpo.MCode;// string.IsNullOrEmpty(m.MCode) ? " " : m.MCode;
                    //pick.QTY = 0; // decimal.Parse(txtNumEdit.Text);

                    pick.QTY = 0;

                    pick.MaintainDate   = FormatHelper.TODateInt(DateTime.Now);
                    pick.MaintainTime   = FormatHelper.TOTimeInt(DateTime.Now);
                    pick.MaintainUser   = this.GetUserCode();
                    pick.Status         = "Release";
                    pick.VEnderItemCode = wwpo.HWMCode;
                    pick.CDate          = FormatHelper.TODateInt(DateTime.Now);
                    pick.CTime          = FormatHelper.TOTimeInt(DateTime.Now);
                    pick.CUser          = this.GetUserCode();
                    pick.InvLine        = invline;
                    _WarehouseFacade.AddPickdetail(pick);
                }



                //if (decqty + pickqty > wwpoqty)
                //{
                //    WebInfoPublish.Publish(this, "领料数量大于库存数量", this.languageComponent1);
                //}
                //else
                //{
                //}
                this.DataProvider.CommitTransaction();
                txtWWPoSerialEdit.Text = string.Empty;
                WebInfoPublish.Publish(this, "添加成功!", this.languageComponent1);
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                WebInfoPublish.PublishInfo(this, ex.Message, this.languageComponent1);
            }


            this.gridHelper.RequestData();
            this.buttonHelper.PageActionStatusHandle(PageActionType.Add);
        }