Ejemplo n.º 1
0
        //保存
        protected override void UpdateDomainObject(object domainObject)
        {
            if (_InventoryFacade == null)
            {
                _InventoryFacade = new InventoryFacade(base.DataProvider);
            }
            WarehouseFacade facade = new WarehouseFacade(base.DataProvider);

            if (_IsAdd)
            {
                #region 在invinouttrans表中增加一条数据
                ASN           asn    = (ASN)domainObject;
                DBDateTime    dbTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                InvInOutTrans trans  = facade.CreateNewInvInOutTrans();
                trans.CartonNO        = string.Empty;
                trans.DqMCode         = string.Empty;
                trans.FacCode         = asn.FacCode;
                trans.FromFacCode     = asn.FromFacCode;
                trans.FromStorageCode = asn.FromStorageCode;
                trans.InvNO           = asn.InvNo;
                trans.InvType         = asn.StType;
                trans.LotNo           = string.Empty;
                trans.MaintainDate    = dbTime.DBDate;
                trans.MaintainTime    = dbTime.DBTime;
                trans.MaintainUser    = this.GetUserCode();
                trans.MCode           = string.Empty;
                trans.ProductionDate  = 0;
                trans.Qty             = 0;
                trans.Serial          = 0;
                trans.StorageAgeDate  = 0;
                trans.StorageCode     = asn.StorageCode;
                trans.SupplierLotNo   = string.Empty;
                trans.TransNO         = asn.StNo;
                trans.TransType       = "IN";
                trans.Unit            = string.Empty;
                trans.ProcessType     = "ASN";
                facade.AddInvInOutTrans(trans);
                #endregion
                this._InventoryFacade.AddASN((ASN)domainObject);
            }
            else
            {
                this._InventoryFacade.UpdateASN((ASN)domainObject);
            }
        }
        private string autoCreateASNFromCheckoutInfo(string invNo, Pick pick)
        {
            try
            {
                InvoicesDetail   invD   = (InvoicesDetail)_InventoryFacade.GetInvoicesDetail(invNo);
                CARTONINVOICES[] cartos = _warehouseFacade.GetGrossAndWeight(pick.PickNo);
                string           stno   = CreateStNO();
                Asn asn = new Asn();
                asn.Stno    = stno;
                asn.StType  = "UB";
                asn.CDate   = FormatHelper.TODateInt(DateTime.Now);
                asn.CTime   = FormatHelper.TOTimeInt(DateTime.Now);
                asn.CUser   = GetUserCode();
                asn.Status  = "Release";
                asn.Invno   = invNo;
                asn.FacCode = pick.FacCode;
                if (cartos.Length > 0)
                {
                    asn.Gross_weight = (decimal)cartos[0].GROSS_WEIGHT;
                    asn.Volume       = cartos[0].VOLUME;
                }
                asn.StorageCode  = invD.StorageCode ?? " ";
                asn.MaintainUser = GetUserCode();
                asn.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                asn.MaintainDate = FormatHelper.TODateInt(DateTime.Now);
                CartonInvDetailMaterial[] cartonMs    = _warehouseFacade.GetCartonInvDetailMaterial(pick.PickNo);
                MOModel.ItemFacade        _itemfacade = new BenQGuru.eMES.MOModel.ItemFacade(this.DataProvider);

                int i = 1;

                this.DataProvider.BeginTransaction();
                foreach (CartonInvDetailMaterial m in cartonMs)
                {
                    object materobj = _itemfacade.GetMaterial(m.MCODE);
                    Domain.MOModel.Material mater = materobj as Domain.MOModel.Material;
                    if (materobj == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        throw new Exception("物料表没有物料:" + m.MCODE);
                    }
                    string custMCode = _warehouseFacade.GetCustMCodeForUB(pick.PickNo, m.DQMCODE);
                    if (mater.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_KEYPARTS)
                    {
                        ASNDetail asnd = new ASNDetail();
                        asnd.ActQty = 0;
                        //asnd.CartonNo = " ";
                        asnd.DQMCode      = m.DQMCODE;
                        asnd.Qty          = (int)m.QTY;
                        asnd.StLine       = i.ToString();
                        asnd.CustMCode    = custMCode;
                        asnd.MCode        = m.MCODE;
                        asnd.Status       = "Release";
                        asnd.StNo         = stno;
                        asnd.MDesc        = mater.MchshortDesc;
                        asnd.Unit         = m.UNIT;
                        asnd.CDate        = FormatHelper.TODateInt(DateTime.Now);
                        asnd.CTime        = FormatHelper.TOTimeInt(DateTime.Now);
                        asnd.CUser        = GetUserCode();
                        asnd.MaintainDate = FormatHelper.TODateInt(DateTime.Now);
                        asnd.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                        asnd.MaintainUser = GetUserCode();
                        asnd.LotNo        = " ";
                        CARTONINVDETAILSN[] sns    = _warehouseFacade.GetCartonInvDetailSn(m.CARTONNO, pick.PickNo);
                        List <string>       snList = new List <string>();
                        if (sns.Length > 0)
                        {
                            foreach (CARTONINVDETAILSN sn in sns)
                            {
                                snList.Add(sn.SN);
                            }
                            Asndetail detail = _warehouseFacade.GetFirstCheckInAsnDetail(snList);
                            if (detail != null)
                            {
                                asnd.ProductionDate = detail.Production_Date;
                                asnd.SupplierLotNo  = detail.Supplier_lotno;
                                asnd.LotNo          = detail.Lotno;
                                asnd.StorageAgeDate = detail.StorageageDate;
                            }
                        }
                        DBDateTime    dbTime     = FormatHelper.GetNowDBDateTime(this.DataProvider);
                        Asndetailitem detailitem = _warehouseFacade.CreateNewAsndetailitem();
                        detailitem.CDate        = dbTime.DBDate;
                        detailitem.CTime        = dbTime.DBTime;
                        detailitem.CUser        = this.GetUserCode();
                        detailitem.MaintainDate = dbTime.DBDate;
                        detailitem.MaintainTime = dbTime.DBTime;
                        detailitem.MaintainUser = this.GetUserCode();
                        detailitem.Stline       = i.ToString();
                        detailitem.Stno         = asn.Stno;
                        detailitem.MCode        = asnd.MCode;
                        detailitem.DqmCode      = asnd.DQMCode;

                        //查找对应的SAP单
                        object[] qtyobjs = _warehouseFacade.GetSAPNOandLinebyMCODE(asn.Invno, asnd.MCode, asnd.DQMCode);
                        if (qtyobjs == null)
                        {
                            this.DataProvider.RollbackTransaction();
                            throw new Exception("入库需求" + asn.Invno + " 没有相关物料" + asnd.MCode + "," + asnd.DQMCode + "或者此行已被取消!");
                        }
                        decimal sub = asnd.Qty;
                        for (int k = 0; k < qtyobjs.Length; k++)
                        {
                            InvoicesDetail invdetail       = qtyobjs[k] as InvoicesDetail;
                            decimal        subNeed         = 0;
                            object         findNeedQTY_old = _warehouseFacade.GetNeedImportQtyOLD(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少
                            Asndetailitem  subItemOld      = findNeedQTY_old as Asndetailitem;
                            object         findNeedQTY_now = _warehouseFacade.GetNeedImportQtyNow(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少
                            Asndetailitem  subItemNow      = findNeedQTY_now as Asndetailitem;

                            subNeed = invdetail.PlanQty - subItemOld.Qty + (subItemOld.Qty - subItemOld.ReceiveQty) + (subItemOld.ReceiveQty - subItemOld.QcpassQty);
                            subNeed = subNeed - subItemNow.Qty;

                            if (subNeed == 0)
                            {
                                continue;
                            }

                            //如果箱数量大于需求数量差---进行拆分
                            if (sub > subNeed)
                            {
                                sub                   = sub - subNeed; //  sub是剩余的
                                detailitem.Qty        = subNeed;
                                detailitem.Invline    = invdetail.InvLine.ToString();
                                detailitem.Invno      = invdetail.InvNo;
                                detailitem.ActQty     = detailitem.Qty;
                                detailitem.QcpassQty  = detailitem.Qty;
                                detailitem.ReceiveQty = detailitem.Qty;
                                _warehouseFacade.AddAsndetailitem(detailitem);
                            }

                            //如果箱单数量小于等于需求数量差--直接填入
                            else
                            {
                                detailitem.Qty        = sub;
                                detailitem.Invline    = invdetail.InvLine.ToString();
                                detailitem.Invno      = invdetail.InvNo;
                                detailitem.ActQty     = detailitem.Qty;
                                detailitem.QcpassQty  = detailitem.Qty;
                                detailitem.ReceiveQty = detailitem.Qty;
                                _warehouseFacade.AddAsndetailitem(detailitem);
                                sub = 0;
                            }
                            if (sub == 0)
                            {
                                break;
                            }
                        }
                        //如果sub>0,说明导入数量过多,报错
                        if (sub > 0)
                        {
                            this.DataProvider.RollbackTransaction();

                            throw new Exception("箱单导入数量与需求数量不符!");
                        }

                        foreach (CARTONINVDETAILSN sn in sns)
                        {
                            Asndetailsn asnSN = new Asndetailsn();

                            asnSN.CDate        = FormatHelper.TODateInt(DateTime.Now);
                            asnSN.CTime        = FormatHelper.TOTimeInt(DateTime.Now);
                            asnSN.CUser        = GetUserCode();
                            asnSN.MaintainDate = FormatHelper.TODateInt(DateTime.Now);
                            asnSN.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                            asnSN.MaintainUser = GetUserCode();
                            asnSN.Sn           = sn.SN;
                            asnSN.Stline       = i.ToString();
                            asnSN.Stno         = stno;
                            _warehouseFacade.AddAsndetailsn(asnSN);
                        }
                        _InventoryFacade.AddASNDetail(asnd);
                    }
                    else if (mater.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_LOT || mater.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_NOCONTROL)
                    {
                        ASNDetail asnd = new ASNDetail();
                        asnd.ActQty       = 0;
                        asnd.CustMCode    = custMCode;
                        asnd.DQMCode      = m.DQMCODE;
                        asnd.Qty          = (int)m.QTY;
                        asnd.StLine       = i.ToString();
                        asnd.MCode        = m.MCODE;
                        asnd.StNo         = stno;
                        asnd.Status       = "Release";
                        asnd.MDesc        = mater.MchshortDesc;
                        asnd.Unit         = m.UNIT;
                        asnd.CDate        = FormatHelper.TODateInt(DateTime.Now);
                        asnd.CTime        = FormatHelper.TOTimeInt(DateTime.Now);
                        asnd.CUser        = GetUserCode();
                        asnd.MaintainDate = FormatHelper.TODateInt(DateTime.Now);
                        asnd.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                        asnd.MaintainUser = GetUserCode();
                        asnd.LotNo        = " ";
                        Pickdetailmaterial pickMaterial = (Pickdetailmaterial)_warehouseFacade.GetLotNOInformationFromDQMCODE(m.DQMCODE, pick.PickNo);

                        if (pickMaterial != null)
                        {
                            asnd.ProductionDate = pickMaterial.Production_Date;
                            asnd.SupplierLotNo  = pickMaterial.Supplier_lotno;
                            asnd.LotNo          = pickMaterial.Lotno;
                            asnd.StorageAgeDate = pickMaterial.StorageageDate;
                        }
                        else
                        {
                            throw new Exception(pick.PickNo + "没有找到检料信息!");
                        }
                        _InventoryFacade.AddASNDetail(asnd);

                        DBDateTime    dbTime     = FormatHelper.GetNowDBDateTime(this.DataProvider);
                        Asndetailitem detailitem = _warehouseFacade.CreateNewAsndetailitem();
                        detailitem.CDate        = dbTime.DBDate;
                        detailitem.CTime        = dbTime.DBTime;
                        detailitem.CUser        = this.GetUserCode();
                        detailitem.MaintainDate = dbTime.DBDate;
                        detailitem.MaintainTime = dbTime.DBTime;
                        detailitem.MaintainUser = this.GetUserCode();
                        detailitem.Stline       = i.ToString();
                        detailitem.Stno         = asn.Stno;
                        detailitem.MCode        = asnd.MCode;
                        detailitem.DqmCode      = asnd.DQMCode;

                        //查找对应的SAP单
                        object[] qtyobjs = _warehouseFacade.GetSAPNOandLinebyMCODE(asn.Invno, asnd.MCode, asnd.DQMCode);
                        if (qtyobjs == null)
                        {
                            this.DataProvider.RollbackTransaction();
                            throw new Exception("箱单导入数量与需求数量不符!");
                        }
                        decimal sub = asnd.Qty;
                        for (int k = 0; k < qtyobjs.Length; k++)
                        {
                            InvoicesDetail invdetail       = qtyobjs[k] as InvoicesDetail;
                            decimal        subNeed         = 0;
                            object         findNeedQTY_old = _warehouseFacade.GetNeedImportQtyOLD(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少
                            Asndetailitem  subItemOld      = findNeedQTY_old as Asndetailitem;
                            object         findNeedQTY_now = _warehouseFacade.GetNeedImportQtyNow(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少
                            Asndetailitem  subItemNow      = findNeedQTY_now as Asndetailitem;

                            subNeed = invdetail.PlanQty - subItemOld.Qty + (subItemOld.Qty - subItemOld.ReceiveQty) + (subItemOld.ReceiveQty - subItemOld.QcpassQty);
                            subNeed = subNeed - subItemNow.Qty;

                            if (subNeed == 0)
                            {
                                continue;
                            }

                            //如果箱数量大于需求数量差---进行拆分
                            if (sub > subNeed)
                            {
                                sub                   = sub - subNeed; //  sub是剩余的
                                detailitem.Qty        = subNeed;
                                detailitem.Invline    = invdetail.InvLine.ToString();
                                detailitem.Invno      = invdetail.InvNo;
                                detailitem.ActQty     = detailitem.Qty;
                                detailitem.QcpassQty  = detailitem.Qty;
                                detailitem.ReceiveQty = detailitem.Qty;
                                _warehouseFacade.AddAsndetailitem(detailitem);
                            }

                            //如果箱单数量小于等于需求数量差--直接填入
                            else
                            {
                                detailitem.Qty        = sub;
                                detailitem.Invline    = invdetail.InvLine.ToString();
                                detailitem.Invno      = invdetail.InvNo;
                                detailitem.ActQty     = detailitem.Qty;
                                detailitem.QcpassQty  = detailitem.Qty;
                                detailitem.ReceiveQty = detailitem.Qty;
                                _warehouseFacade.AddAsndetailitem(detailitem);
                                sub = 0;
                            }
                            if (sub == 0)
                            {
                                break;
                            }
                        }
                        //如果sub>0,说明导入数量过多,报错
                        if (sub > 0)
                        {
                            this.DataProvider.RollbackTransaction();

                            throw new Exception("箱单导入数量与需求数量不符!");
                        }
                    }
                    i++;
                }
                _warehouseFacade.AddAsn(asn);
                WarehouseFacade facade = new WarehouseFacade(base.DataProvider);
                #region 在invinouttrans表中增加一条数据
                //ASN asn = (ASN)domainObject;
                DBDateTime    dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider);
                InvInOutTrans trans   = facade.CreateNewInvInOutTrans();
                trans.CartonNO        = string.Empty;
                trans.DqMCode         = string.Empty;
                trans.FacCode         = asn.FacCode;
                trans.FromFacCode     = asn.FromfacCode;
                trans.FromStorageCode = asn.FromstorageCode;
                trans.InvNO           = asn.Invno;
                trans.InvType         = asn.StType;
                trans.LotNo           = string.Empty;
                trans.MaintainDate    = dbTime1.DBDate;
                trans.MaintainTime    = dbTime1.DBTime;
                trans.MaintainUser    = this.GetUserCode();
                trans.MCode           = string.Empty;
                trans.ProductionDate  = 0;
                trans.Qty             = 0;
                trans.Serial          = 0;
                trans.StorageAgeDate  = 0;
                trans.StorageCode     = asn.StorageCode;
                trans.SupplierLotNo   = string.Empty;
                trans.TransNO         = asn.Stno;
                trans.TransType       = "IN";
                trans.Unit            = string.Empty;
                trans.ProcessType     = "UBCreateASN";
                facade.AddInvInOutTrans(trans);
                #endregion
                this.DataProvider.CommitTransaction();
                return(stno);
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                throw ex;
            }
        }
Ejemplo n.º 3
0
        private void ToSTS(string oqcNo)
        {
            if (_OQCFacade == null)
            {
                _OQCFacade = new OQCFacade(base.DataProvider);
            }
            _InventoryFacade = new InventoryFacade(base.DataProvider);
            WarehouseFacade _WarehouseFacade = new WarehouseFacade(base.DataProvider);

            //1、更新OQC单表(TBLOQC)
            _OQCFacade.UpdateOQC(OQCType.OQCType_ExemptCheck, OQCStatus.OQCStatus_OQCClose, "Y", oqcNo);

            //2、更新OQC单明细表(TBLOQCDETAIL)
            _OQCFacade.UpdateOQCDetail("Y", oqcNo);

            //3、更新OQC单明细SN信息表(TBLOQCDETAILSN)
            _OQCFacade.UpdateOQCDetailSN("Y", oqcNo);

            //4、更新发货箱单头信息表(TBLCartonInvoices)
            Pick pick = (Pick)_InventoryFacade.GetPickByOqcNo(oqcNo);

            if (pick != null)
            {
                //if (pick.GFFlag == "X")
                //{
                //    if (CheckAllOQCStatusIsOQCClose(oqcNo))
                //    {
                //        CARTONINVOICES cartonInvoices = (CARTONINVOICES)_WarehouseFacade.GetCartoninvoicesByOqcNo(oqcNo);
                //        if (cartonInvoices != null)
                //        {
                //            cartonInvoices.STATUS = CartonInvoices_STATUS.Status_OQCClose;
                //            _WarehouseFacade.UpdateCartoninvoices(cartonInvoices);
                //        }
                //    }
                //    else
                //    {
                //        throw new Exception("OQC单号" + oqcNo + "没有全部检验完成");
                //    }
                //}
                //else
                //{


                if (_OQCFacade.IsOQCFinish(pick.PickNo))
                {
                    pick.Status = PickHeadStatus.PickHeadStatus_PackingListing;
                    _WarehouseFacade.UpdatePick(pick);
                }
                CARTONINVOICES cartonInvoices = (CARTONINVOICES)_WarehouseFacade.GetCartoninvoicesByOqcNo(oqcNo);
                if (cartonInvoices != null)
                {
                    cartonInvoices.STATUS = CartonInvoices_STATUS.Status_OQCClose;
                    _WarehouseFacade.UpdateCartoninvoices(cartonInvoices);
                }

                //}

                #region 在invinouttrans表中增加一条数据
                WarehouseFacade facade  = new WarehouseFacade(base.DataProvider);
                DBDateTime      dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider);

                InvInOutTrans trans1 = facade.CreateNewInvInOutTrans();
                trans1.CartonNO        = string.Empty;
                trans1.DqMCode         = string.Empty;
                trans1.FacCode         = string.Empty;
                trans1.FromFacCode     = string.Empty;
                trans1.FromStorageCode = string.Empty;
                trans1.InvNO           = pick.InvNo;//.InvNo;
                trans1.InvType         = pick.PickType;
                trans1.LotNo           = string.Empty;
                trans1.MaintainDate    = dbTime1.DBDate;
                trans1.MaintainTime    = dbTime1.DBTime;
                trans1.MaintainUser    = this.GetUserCode();
                trans1.MCode           = string.Empty;
                trans1.ProductionDate  = 0;
                trans1.Qty             = 0;
                trans1.Serial          = 0;
                trans1.StorageAgeDate  = 0;
                trans1.StorageCode     = string.Empty;
                trans1.SupplierLotNo   = string.Empty;
                trans1.TransNO         = pick.PickNo;// asnIqc.IqcNo;
                trans1.TransType       = "OUT";
                trans1.Unit            = string.Empty;
                trans1.ProcessType     = "OQC";
                facade.AddInvInOutTrans(trans1);


                Domain.OQC.OQC asnIqcHead     = (Domain.OQC.OQC)_OQCFacade.GetOQC(oqcNo);
                object[]       objs_oqcDetail = _OQCFacade.GetOQCDetailByOqcNo(oqcNo);
                if (objs_oqcDetail != null)
                {
                    foreach (OQCDetail asnIqc in objs_oqcDetail)
                    {
                        InvInOutTrans trans = facade.CreateNewInvInOutTrans();
                        trans.CartonNO        = string.Empty;
                        trans.DqMCode         = asnIqc.DQMCode;
                        trans.FacCode         = string.Empty;
                        trans.FromFacCode     = string.Empty;
                        trans.FromStorageCode = string.Empty;
                        trans.InvNO           = asnIqc.CarInvNo;//.InvNo;
                        trans.InvType         = asnIqcHead.OqcType;
                        trans.LotNo           = string.Empty;
                        trans.MaintainDate    = dbTime1.DBDate;
                        trans.MaintainTime    = dbTime1.DBTime;
                        trans.MaintainUser    = this.GetUserCode();
                        trans.MCode           = asnIqc.MCode;
                        trans.ProductionDate  = 0;
                        trans.Qty             = asnIqc.Qty;
                        trans.Serial          = 0;
                        trans.StorageAgeDate  = 0;
                        trans.StorageCode     = string.Empty;
                        trans.SupplierLotNo   = string.Empty;
                        trans.TransNO         = oqcNo;// asnIqc.IqcNo;
                        trans.TransType       = "OUT";
                        trans.Unit            = string.Empty;
                        trans.ProcessType     = "OQC";
                        facade.AddInvInOutTrans(trans);
                    }
                }
                #endregion
            }
        }
Ejemplo n.º 4
0
        public string OnShelves(DataTable dt, string cartonNO, string UserCode)
        {
            WarehouseFacade facade       = null;
            InventoryFacade _Invenfacade = null;
            DBDateTime      dbTime       = FormatHelper.GetNowDBDateTime(DataProvider);
            object          obj          = null;

            if (facade == null)
            {
                facade = new WarehouseFacade(DataProvider);
            }
            if (_Invenfacade == null)
            {
                _Invenfacade = new InventoryFacade(DataProvider);
            }
            this.DataProvider.BeginTransaction();
            try
            {
                string Stno = string.Empty;
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    obj = facade.GetAsndetail(int.Parse(dt.Rows[j]["stline"].ToString()), dt.Rows[j]["stno"].ToString());
                    if (obj != null)
                    {
                        Stno = (obj as Asndetail).Stno;
                        #region 更新asndetail表 更新actqty和状态
                        //update actqty and status
                        Asndetail asndetail = obj as Asndetail;
                        asndetail.ActQty       = asndetail.QcpassQty;
                        asndetail.Status       = ASNDetail_STATUS.ASNDetail_Close;
                        asndetail.MaintainDate = dbTime.DBDate;
                        asndetail.MaintainTime = dbTime.DBTime;
                        asndetail.MaintainUser = UserCode;
                        facade.UpdateAsndetail(asndetail);
                        #endregion
                        #region 更新asndetailitem表 更新 actqty 和更新invoicedetail表,更新actqty
                        object[] itemobjs = facade.GetASNDetailItembyStnoAndStline(asndetail.Stno, asndetail.Stline.ToString());
                        if (itemobjs != null)
                        {
                            for (int i = 0; i < itemobjs.Length; i++)
                            {
                                Asndetailitem asnitem = itemobjs[i] as Asndetailitem;
                                asnitem.ActQty       = asnitem.QcpassQty;
                                asnitem.MaintainDate = dbTime.DBDate;
                                asnitem.MaintainTime = dbTime.DBTime;
                                asnitem.MaintainUser = UserCode;
                                facade.UpdateAsndetailitem(asnitem);

                                object         invoiobj = _Invenfacade.GetInvoicesDetail(asnitem.Invno, int.Parse(asnitem.Invline));
                                InvoicesDetail inv      = invoiobj as InvoicesDetail;
                                inv.ActQty      += Convert.ToInt32(asnitem.QcpassQty);
                                inv.MaintainDate = dbTime.DBDate;
                                inv.MaintainTime = dbTime.DBTime;
                                inv.MaintainUser = UserCode;

                                _Invenfacade.UpdateInvoicesDetail(inv);
                            }
                        }
                        #endregion

                        //新增数据tblstoragedetail
                        object asnobj = facade.GetAsn(asndetail.Stno);
                        if (asnobj == null)
                        {
                            this.DataProvider.RollbackTransaction();
                            // WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1);

                            return("ASN 中没有数据:" + asndetail.Stno);
                        }
                        Asn asn = asnobj as Asn;
                        #region 在storagedetail表中增加一条数据
                        StorageDetail stordetail = _Invenfacade.CreateNewStorageDetail();
                        stordetail.AvailableQty       = asndetail.ActQty;
                        stordetail.CartonNo           = asndetail.Cartonno;
                        stordetail.CDate              = dbTime.DBDate;
                        stordetail.CTime              = dbTime.DBTime;
                        stordetail.CUser              = UserCode;
                        stordetail.DQMCode            = asndetail.DqmCode;
                        stordetail.FacCode            = (asnobj as Asn).FacCode;
                        stordetail.FreezeQty          = 0;
                        stordetail.LastStorageAgeDate = dbTime.DBDate;

                        stordetail.LocationCode   = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(cartonNO));
                        stordetail.Lotno          = asndetail.Lotno;
                        stordetail.MaintainDate   = dbTime.DBDate;
                        stordetail.MaintainTime   = dbTime.DBTime;
                        stordetail.MaintainUser   = UserCode;
                        stordetail.MCode          = asndetail.MCode;
                        stordetail.MDesc          = asndetail.MDesc;
                        stordetail.ProductionDate = asndetail.Production_Date;

                        stordetail.ReworkApplyUser = (asnobj as Asn).ReworkapplyUser;
                        stordetail.StorageAgeDate  = string.IsNullOrEmpty(asndetail.StorageageDate.ToString()) ? dbTime.DBDate : int.Parse(asndetail.StorageageDate);
                        stordetail.StorageCode     = (asnobj as Asn).StorageCode;
                        stordetail.StorageQty      = asndetail.ActQty;
                        stordetail.SupplierLotNo   = asndetail.Supplier_lotno;
                        stordetail.Unit            = asndetail.Unit;

                        _Invenfacade.AddStorageDetail(stordetail);
                        #endregion
                        #region 在StorageDetailSN表中增加数据
                        //新增数据tblStorageDetailSN

                        object[] snobj = facade.GetASNDetailSNbyStnoandStline(asndetail.Stno, asndetail.Stline.ToString());
                        if (snobj == null)
                        {
                            this.DataProvider.RollbackTransaction();
                            // WebInfoPublish.Publish(this, "$Error_ASNDetail_NO_DATA", this.languageComponent1);

                            return("ASNDetail表中没有数据:" + asndetail.Stno + "/" + asndetail.Stline.ToString());
                        }
                        for (int i = 0; i < snobj.Length; i++)
                        {
                            StorageDetailSN storDetailSN = _Invenfacade.CreateNewStorageDetailSN();
                            Asndetailsn     detailSN     = snobj[i] as Asndetailsn;
                            storDetailSN.CartonNo     = detailSN.Cartonno;
                            storDetailSN.CDate        = dbTime.DBDate;
                            storDetailSN.CTime        = dbTime.DBTime;
                            storDetailSN.CUser        = UserCode;
                            storDetailSN.MaintainDate = dbTime.DBDate;
                            storDetailSN.MaintainTime = dbTime.DBTime;
                            storDetailSN.MaintainUser = UserCode;
                            storDetailSN.PickBlock    = "N";
                            storDetailSN.SN           = detailSN.Sn;

                            _Invenfacade.AddStorageDetailSN(storDetailSN);
                        }
                        #endregion
                        #region 在invinouttrans表中增加一条数据
                        InvInOutTrans trans = facade.CreateNewInvInOutTrans();
                        trans.CartonNO        = asndetail.Cartonno;
                        trans.DqMCode         = asndetail.DqmCode;
                        trans.FacCode         = asn.FacCode;
                        trans.FromFacCode     = asn.FromfacCode;
                        trans.FromStorageCode = asn.FromstorageCode;
                        trans.InvNO           = asn.Invno;
                        trans.InvType         = asn.StType;
                        trans.LotNo           = asndetail.Lotno;
                        trans.MaintainDate    = dbTime.DBDate;
                        trans.MaintainTime    = dbTime.DBTime;
                        trans.MaintainUser    = UserCode;
                        trans.MCode           = asndetail.MCode;
                        trans.ProductionDate  = asndetail.Production_Date;
                        trans.Qty             = asndetail.ActQty;
                        trans.Serial          = 0;
                        trans.StorageAgeDate  = int.Parse(asndetail.StorageageDate);
                        trans.StorageCode     = asn.StorageCode;
                        trans.SupplierLotNo   = asndetail.Supplier_lotno;
                        trans.TransNO         = asn.Stno;
                        trans.TransType       = "IN";
                        trans.Unit            = asndetail.Unit;
                        facade.AddInvInOutTrans(trans);
                        #endregion
                    }
                }
                #region   架完成后,检查这个stno在asndetail中的状态是否都是close,cancel,如果是将asn表的状态更新为close,cancel
                if (facade.JudgeASNDetailStatus(Stno, ASNDetail_STATUS.ASNDetail_Close))
                {
                    object asnobj = facade.GetAsn(Stno);
                    if (asnobj == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        //WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1);

                        return("ASN 中没有数据:" + Stno);
                    }
                    Asn asn = asnobj as Asn;
                    asn.Status       = ASN_STATUS.ASN_Close;
                    asn.MaintainDate = dbTime.DBDate;
                    asn.MaintainTime = dbTime.DBTime;
                    asn.MaintainUser = UserCode;

                    facade.UpdateAsn(asn);
                }
                if (facade.JudgeASNDetailStatus(Stno, ASNDetail_STATUS.ASNDetail_Cancel))
                {
                    object asnobj = facade.GetAsn(Stno);
                    if (asnobj == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        //WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1);

                        return("ASN中没有数据:" + Stno);
                    }
                    Asn asn = asnobj as Asn;
                    asn.Status       = ASN_STATUS.ASN_Cancel;
                    asn.MaintainDate = dbTime.DBDate;
                    asn.MaintainTime = dbTime.DBTime;
                    asn.MaintainUser = UserCode;

                    facade.UpdateAsn(asn);
                }
                #endregion
                #region  通过入库指令号,查找invno,检查actqty是否等于planqty,如果等于将finishflag=Y
                object asnobj1 = facade.GetAsn(Stno);
                if (asnobj1 == null)
                {
                    this.DataProvider.RollbackTransaction();
                    //WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1);

                    return("ASN中没有数据:" + Stno);
                }
                Asn asn1 = asnobj1 as Asn;
                if (facade.JudgeInvoiceDetailStatus(asn1.Invno))
                {
                    object invobj = _Invenfacade.GetInvoices(asn1.Invno);
                    if (invobj == null)
                    {
                        this.DataProvider.RollbackTransaction();
                        //WebInfoPublish.Publish(this, "$Error_INV_NO_DATA", this.languageComponent1);

                        return("INV中没有数据:" + asn1.Invno);
                    }
                    Invoices inv = invobj as Invoices;
                    inv.FinishFlag   = "Y";
                    inv.MaintainDate = dbTime.DBDate;
                    inv.MaintainTime = dbTime.DBTime;
                    inv.MaintainUser = UserCode;
                    _Invenfacade.UpdateInvoices(inv);
                }
                #endregion

                this.DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
            }

            return("上架成功");
        }
Ejemplo n.º 5
0
        private void ToSTS(string iqcNo, string userCode)
        {
            IQCFacade _IQCFacade = new IQCFacade(DataProvider);

            InventoryFacade _InventoryFacade = new InventoryFacade(DataProvider);

            //1、更新送检单TBLASNIQC
            AsnIQC asnIqc = (AsnIQC)_IQCFacade.GetAsnIQC(iqcNo);

            if (asnIqc != null)
            {
                asnIqc.IqcType  = "ExemptCheck";
                asnIqc.Status   = IQCStatus.IQCStatus_IQCClose;
                asnIqc.QcStatus = "Y";
                _IQCFacade.UpdateAsnIQC(asnIqc);

                #region 在invinouttrans表中增加一条数据
                WarehouseFacade facade = new WarehouseFacade(DataProvider);

                //ASN asn = (ASN)domainObject;
                DBDateTime    dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider);
                InvInOutTrans trans   = facade.CreateNewInvInOutTrans();
                trans.CartonNO        = string.Empty;
                trans.DqMCode         = asnIqc.DQMCode;
                trans.FacCode         = string.Empty;
                trans.FromFacCode     = string.Empty;
                trans.FromStorageCode = string.Empty;
                trans.InvNO           = asnIqc.InvNo;
                trans.InvType         = asnIqc.IqcType;
                trans.LotNo           = string.Empty;
                trans.MaintainDate    = dbTime1.DBDate;
                trans.MaintainTime    = dbTime1.DBTime;
                trans.MaintainUser    = userCode;
                trans.MCode           = asnIqc.MCode;
                trans.ProductionDate  = 0;
                trans.Qty             = asnIqc.Qty;
                trans.Serial          = 0;
                trans.StorageAgeDate  = 0;
                trans.StorageCode     = string.Empty;
                trans.SupplierLotNo   = string.Empty;
                trans.TransNO         = asnIqc.IqcNo;
                trans.TransType       = "IN";
                trans.Unit            = string.Empty;
                trans.ProcessType     = "IQC";
                facade.AddInvInOutTrans(trans);
                #endregion
            }

            object[] objAsnIqcDetail = _IQCFacade.GetAsnIQCDetailByIqcNo(iqcNo);
            if (objAsnIqcDetail != null)
            {
                foreach (AsnIQCDetail asnIqcDetail in objAsnIqcDetail)
                {
                    //2、更新送检单明细TBLASNIQCDETAIL
                    asnIqcDetail.QcPassQty = asnIqcDetail.Qty;
                    asnIqcDetail.QcStatus  = "Y";
                    _IQCFacade.UpdateAsnIQCDetail(asnIqcDetail);


                    //4、更新ASN明细TBLASNDETAIL
                    ASNDetail asnDetail = (ASNDetail)_InventoryFacade.GetASNDetail(Convert.ToInt32(asnIqcDetail.StLine), asnIqcDetail.StNo);
                    if (asnDetail != null)
                    {
                        asnDetail.QcPassQty = asnDetail.ReceiveQty;
                        asnDetail.Status    = IQCStatus.IQCStatus_IQCClose;
                        _InventoryFacade.UpdateASNDetail(asnDetail);
                    }

                    //5、更新ASN明细对应单据行明细TBLASNDETAILITEM
                    object[] objAsnDetaileItem = _InventoryFacade.GetAsnDetailItem(asnIqcDetail.StNo, Convert.ToInt32(asnIqcDetail.StLine));
                    if (objAsnDetaileItem != null)
                    {
                        foreach (Asndetailitem asnDetaileItem in objAsnDetaileItem)
                        {
                            asnDetaileItem.QcpassQty = asnDetaileItem.ReceiveQty;
                            _InventoryFacade.UpdateAsndetailitem(asnDetaileItem);
                        }
                    }
                }
            }

            object[] objAsnIqcDetailSN = _IQCFacade.GetAsnIqcDetailSNByIqcNo(iqcNo);
            if (objAsnIqcDetailSN != null)
            {
                foreach (AsnIqcDetailSN asnIqcDetailSN in objAsnIqcDetailSN)
                {
                    //3、更新送检单明细SNTBLASNIQCDETAILSN
                    asnIqcDetailSN.QcStatus = "Y";
                    _IQCFacade.UpdateAsnIqcDetailSN(asnIqcDetailSN);

                    //6、更新ASN明细SN TBLASNDETAILSN
                    Asndetailsn asnDetailSn = (Asndetailsn)_InventoryFacade.GetAsndetailsn(asnIqcDetailSN.Sn, asnIqcDetailSN.StNo, Convert.ToInt32(asnIqcDetailSN.StLine));
                    if (asnDetailSn != null)
                    {
                        asnDetailSn.QcStatus = "Y";
                        _InventoryFacade.UpdateAsndetailsn(asnDetailSn);
                    }
                }
            }

            //7、以上表数据更新完成后检查ASN明细表(TBLASNDETAIL)所有行记录状态为:IQCClose:IQC完成 or OnLocation:上架 or Close:入库 or Cancel:取消时,
            //   更新ASN主表(TBLASN)状态(TBLASN.STATUS)为:OnLocation:上架
            bool isAllIQCClose   = CheckAllASNDetailIsIQCClose(iqcNo);
            bool isAllOnLocation = CheckAllASNDetailIsOnLocation(iqcNo);
            bool isAllClose      = CheckAllASNDetailIsClose(iqcNo);
            bool isAllCancel     = CheckAllASNDetailIsCancel(iqcNo);

            if (isAllIQCClose || isAllOnLocation ||
                isAllClose || isAllCancel
                )
            {
                ASN asn = (ASN)_InventoryFacade.GetASN(asnIqc.StNo);
                if (asn != null)
                {
                    asn.Status = ASNHeadStatus.OnLocation;
                    _InventoryFacade.UpdateASN(asn);
                }
            }
        }
Ejemplo n.º 6
0
        public bool FirstCheckWithUser(string[] asns, string userCode, out string message)
        {
            try
            {
                WarehouseFacade facade  = new WarehouseFacade(DataProvider);
                InventoryFacade facade1 = new InventoryFacade(DataProvider);
                message = string.Empty;
                Asn asn = (Asn)facade.GetAsn(asns[0]);

                if (asn.Direct_flag.ToUpper() == "Y")
                {
                    message = "该入库指令是供应商直发,不能做以下操作[取消下发][初检][申请IQC]";
                    return(false);
                }

                if (asn.Status == ASNHeadStatus.WaitReceive)
                {
                    this.DataProvider.BeginTransaction();

                    string stNo = string.Format("'{0}'", asn.Stno);

                    facade1.UpdateASNStatusByStNo(ASNHeadStatus.Receive, stNo);
                    facade1.UpdateASNDetailStatusByStNo(ASNHeadStatus.Receive, stNo);
                    DBDateTime      dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    WarehouseFacade _wa     = new WarehouseFacade(DataProvider);
                    InvInOutTrans   trans   = _wa.CreateNewInvInOutTrans();
                    trans.CartonNO        = string.Empty;
                    trans.DqMCode         = " ";
                    trans.FacCode         = asn.FacCode;
                    trans.FromFacCode     = string.Empty;
                    trans.FromStorageCode = string.Empty;
                    trans.InvNO           = asn.Invno;
                    trans.InvType         = asn.StType;
                    trans.LotNo           = string.Empty;
                    trans.MaintainDate    = dbTime1.DBDate;
                    trans.MaintainTime    = FormatHelper.TOTimeInt(DateTime.Now);
                    trans.MaintainUser    = userCode;
                    trans.MCode           = " ";
                    trans.ProductionDate  = 0;
                    trans.Qty             = 0;
                    trans.Serial          = 0;
                    trans.StorageAgeDate  = 0;
                    trans.StorageCode     = asn.StorageCode;
                    trans.SupplierLotNo   = string.Empty;
                    trans.TransNO         = asn.Stno;
                    trans.TransType       = "IN";
                    trans.Unit            = string.Empty;
                    trans.ProcessType     = "RECEIVEBEGIN";
                    _wa.AddInvInOutTrans(trans);


                    this.DataProvider.CommitTransaction();
                    message = "初检成功";
                    return(true);
                }
                else if (asn.Status == ASNHeadStatus.Receive)
                {
                    message = "初检成功";
                    return(true);
                }
                else
                {
                    message = "状态必须是初见签收中或者待收货!";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                DataProvider.RollbackTransaction();
                BenQGuru.eMES.Common.Log.Error(ex.StackTrace);
                throw ex;
            }
        }
Ejemplo n.º 7
0
        protected void CmdConfirmOweQtyObjects(object[] pickList)
        {
            // 点击该按钮,初始TBLPICKDETAIL. OweQTY为空or零,
            //点击该按钮后保存TBLPICKDETAIL. OweQTY= TBLPICKDETAIL. SQTY
            //注:只有状态为:Owe:欠料的物料行可以执行此按钮,确认后该行更新状态为ClosePick:拣料完成
            if (facade == null)
            {
                facade = new InventoryFacade(base.DataProvider);
            }
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new WarehouseFacade(base.DataProvider);
            }
            DBDateTime dbTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

            try
            {
                this.DataProvider.BeginTransaction();
                foreach (PickDetail pickdetail in pickList)
                {
                    if (pickdetail.Status == PickDetail_STATUS.Status_Owe)
                    {
                        if (pickdetail.OweQTY == 0 || string.IsNullOrEmpty(pickdetail.OweQTY.ToString()))
                        {
                            PickDetail oldpickdetail = (PickDetail)facade.GetPickDetail(pickdetail.PickNo, pickdetail.PickLine);
                            oldpickdetail.OweQTY = oldpickdetail.SQTY;
                            oldpickdetail.Status = PickDetail_STATUS.Status_ClosePick;
                            facade.UpdatePickDetail(oldpickdetail);
                        }
                        else
                        {
                            WebInfoPublish.Publish(this, "已申请欠料发货!", this.languageComponent1);
                            return;
                        }
                    }
                    else
                    {
                        WebInfoPublish.Publish(this, "只有状态为欠料的物料行可以执行此按钮", this.languageComponent1);
                        return;
                    }
                }

                #region 在invinouttrans表中增加一条数据 箱单完成日期
                WarehouseFacade wfacade = new WarehouseFacade(base.DataProvider);
                DBDateTime      dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider);
                foreach (PickDetail pickDetail in pickList)
                {
                    Pick          pick  = facade.GetPick(pickDetail.PickNo) as Pick;
                    InvInOutTrans trans = wfacade.CreateNewInvInOutTrans();
                    trans.CartonNO        = string.Empty;
                    trans.DqMCode         = pickDetail.DQMCode;
                    trans.FacCode         = string.Empty;
                    trans.FromFacCode     = string.Empty;
                    trans.FromStorageCode = string.Empty;
                    trans.InvNO           = pick.InvNo;//.InvNo;
                    trans.InvType         = pick.PickType;
                    trans.LotNo           = string.Empty;
                    trans.MaintainDate    = dbTime1.DBDate;
                    trans.MaintainTime    = dbTime1.DBTime;
                    trans.MaintainUser    = this.GetUserCode();
                    trans.MCode           = pickDetail.MCode;
                    trans.ProductionDate  = 0;
                    trans.Qty             = pickDetail.QTY;
                    trans.Serial          = 0;
                    trans.StorageAgeDate  = 0;
                    trans.StorageCode     = string.Empty;
                    trans.SupplierLotNo   = string.Empty;
                    trans.TransNO         = pickDetail.PickNo;
                    trans.TransType       = "OUT";
                    trans.Unit            = string.Empty;
                    trans.ProcessType     = "ClosePick";
                    wfacade.AddInvInOutTrans(trans);
                }

                #endregion

                string pickno       = FormatHelper.CleanString(this.txtPickNoQuery.Text);
                bool   isUpdatePick = facade.QueryPickDetailCount(pickno, PickDetail_STATUS.Status_ClosePick) == 0;
                if (isUpdatePick)
                {
                    facade.UpdatePickStatusByPickno(pickno, PickHeadStatus.PickHeadStatus_MakePackingList);
                }
                #region  创建发货箱单

                string carInvNo = string.Empty;
                object obj      = _WarehouseFacade.GetCartonInvoices(pickno);
                if (obj == null)
                {
                    CARTONINVOICES CartonH = _WarehouseFacade.CreateNewCartoninvoices();
                    object         objLot  = _WarehouseFacade.GetNewLotNO("K", dbTime.DBDate.ToString().Substring(2, 6).ToString());
                    Serialbook     serbook = _WarehouseFacade.CreateNewSerialbook();
                    if (objLot == null)
                    {
                        #region
                        CartonH.CARINVNO = "K" + dbTime.DBDate.ToString().Substring(2, 6).ToString() + "001";
                        CartonH.PICKNO   = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtPickNoQuery.Text));
                        CartonH.STATUS   = CartonInvoices_STATUS.Status_Release;
                        CartonH.CDATE    = dbTime.DBDate;
                        CartonH.CTIME    = dbTime.DBTime;
                        CartonH.CUSER    = this.GetUserCode();
                        CartonH.MDATE    = dbTime.DBDate;
                        CartonH.MTIME    = dbTime.DBTime;
                        CartonH.MUSER    = this.GetUserCode();
                        _WarehouseFacade.AddCartoninvoices(CartonH);

                        serbook.SNprefix  = "K" + dbTime.DBDate.ToString().Substring(2, 6).ToString();
                        serbook.MAXSerial = "2";
                        serbook.MUser     = this.GetUserCode();
                        serbook.MDate     = dbTime.DBDate;
                        serbook.MTime     = dbTime.DBTime;

                        _WarehouseFacade.AddSerialbook(serbook);
                        #endregion
                    }
                    else
                    {
                        #region
                        string MAXNO = (objLot as Serialbook).MAXSerial;
                        string SNNO  = (objLot as Serialbook).SNprefix;
                        CartonH.CARINVNO = SNNO + Convert.ToString(MAXNO).PadLeft(3, '0');
                        CartonH.PICKNO   = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtPickNoQuery.Text));
                        CartonH.STATUS   = CartonInvoices_STATUS.Status_Release;
                        CartonH.CDATE    = dbTime.DBDate;
                        CartonH.CTIME    = dbTime.DBTime;
                        CartonH.CUSER    = this.GetUserCode();
                        CartonH.MDATE    = dbTime.DBDate;
                        CartonH.MTIME    = dbTime.DBTime;
                        CartonH.MUSER    = this.GetUserCode();
                        _WarehouseFacade.AddCartoninvoices(CartonH);

                        //更新tblserialbook
                        serbook.SNprefix  = SNNO;
                        serbook.MAXSerial = Convert.ToString((int.Parse(MAXNO) + 1));
                        serbook.MUser     = this.GetUserCode();
                        serbook.MDate     = dbTime.DBDate;
                        serbook.MTime     = dbTime.DBTime;
                        _WarehouseFacade.UpdateSerialbook(serbook);
                        #endregion
                    }
                }
                # endregion
                this.DataProvider.CommitTransaction();
                WebInfoPublish.Publish(this, "确认欠料发货数量成功", this.languageComponent1);
            }
Ejemplo n.º 8
0
        public string Commit_Click(string userCode, string statusList, string transNo, string tLocationCode, string fromCarton, string tcarton, string inputsn, string inputqty)
        {
            string msg;

            #region facade

            InventoryFacade facade = new InventoryFacade(this.DataProvider);
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new WarehouseFacade(this.DataProvider);
            }
            ItemFacade itemFacade = new ItemFacade();
            DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
            #endregion

            #region check
            if (string.IsNullOrEmpty(transNo))
            {
                msg = "移转单号不能为空";
                return(msg);
            }
            StorageDetail storageCarton = (StorageDetail)facade.GetStorageDetail(fromCarton);
            if (storageCarton == null)
            {  //A 根据原箱号和数量操作。根据原箱号(cartonno)到TBLStorageDetail中查找数据。没有报错。
                msg = "转储单中没有对应的原箱号";
                return(msg);
            }

            if (string.IsNullOrEmpty(tLocationCode))
            {
                msg = "目标货位不能为空";
                return(msg);
            }
            if (string.IsNullOrEmpty(tcarton))
            {
                msg = "目标箱号不能为空";
                return(msg);
            }

            Storloctrans storloctrans = (Storloctrans)_WarehouseFacade.GetStorloctrans(transNo);
            if (storloctrans == null)
            {
                msg = "移转单号不存在";
                return(msg);
            }
            #endregion
            string msgsn = "";


            StorageDetail fromStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(fromCarton);
            StorageDetail toStorageDetail   = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton);
            if (fromStorageDetail == null)
            {
                return("原箱号在库存中不存在!");
            }
            StorloctransDetail storloctransdetailObj = (StorloctransDetail)_WarehouseFacade.GetStorloctransdetail(transNo, fromStorageDetail.MCode);
            if (storloctransdetailObj == null)
            {
                return("转储单中没有对应的物料号");
            }

            Location tLocation = (Location)facade.GetLocation(tLocationCode, 1);
            if (fromStorageDetail.StorageCode != tLocation.StorageCode)
            {
                return("原货位的库位必须与目标货位的库位一致!");
            }
            if (toStorageDetail != null && toStorageDetail.StorageCode != fromStorageDetail.StorageCode)
            {
                return("目标箱号的库位必须原箱号的库位一样!");
            }

            if (tcarton != fromCarton && toStorageDetail != null && toStorageDetail.LocationCode != tLocation.LocationCode)
            {
                return("目标箱号的货位必须与填写的目标货位一致!");
            }

            if (toStorageDetail != null && toStorageDetail.DQMCode != fromStorageDetail.DQMCode)
            {
                return("目标箱号的物料必须与原箱号的物料一致!");
            }
            if ((statusList == CartonType.CartonType_SplitCarton) && (tcarton == fromCarton))
            {
                return("拆箱必须原箱号和目标箱号不同!");
            }
            try
            {
                this.DataProvider.BeginTransaction();


                InvInOutTrans trans = _WarehouseFacade.CreateNewInvInOutTrans();
                trans.CartonNO        = tcarton;
                trans.DqMCode         = fromStorageDetail.DQMCode;
                trans.FacCode         = fromStorageDetail.FacCode;
                trans.FromFacCode     = fromStorageDetail.FacCode;
                trans.FromStorageCode = fromStorageDetail.StorageCode;
                trans.InvNO           = " ";
                trans.InvType         = " ";
                trans.LotNo           = " ";
                trans.MaintainDate    = dbDateTime.DBDate;
                trans.MaintainTime    = dbDateTime.DBTime;
                trans.MaintainUser    = userCode;
                trans.MCode           = fromStorageDetail.MCode;
                trans.ProductionDate  = fromStorageDetail.ProductionDate;
                trans.Qty             = fromStorageDetail.StorageQty;
                trans.Serial          = 0;
                trans.StorageAgeDate  = fromStorageDetail.StorageAgeDate;
                trans.StorageCode     = fromStorageDetail.StorageCode;
                trans.SupplierLotNo   = fromStorageDetail.SupplierLotNo;
                trans.TransNO         = transNo;
                trans.TransType       = "IN";
                trans.ProcessType     = "LocationTrans";
                trans.Unit            = fromStorageDetail.Unit;
                _WarehouseFacade.AddInvInOutTrans(trans);


                #region【整箱】:
                if (statusList == CartonType.CartonType_AllCarton)
                {
                    msgsn = "箱号:" + fromCarton;

                    if (fromStorageDetail.FreezeQty > 0)
                    {
                        return("此箱号以被占用不能移动");
                    }

                    if (_WarehouseFacade.GetStorageDetailSNPickBlockCount(fromCarton) > 0)
                    {
                        return("此箱号SN已被被占用不能移动");
                    }
                    if (_WarehouseFacade.GetStorloctransdetailcarton(transNo, fromCarton,
                                                                     tcarton) != null)
                    {
                        return(transNo + "此单下已存在" + fromCarton + "移动到" + tcarton + ",请另行创建单据!");
                    }


                    facade.DeleteStorageDetail(fromStorageDetail);
                    toStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton);
                    if (toStorageDetail == null)
                    {
                        toStorageDetail = new StorageDetail();
                        toStorageDetail.AvailableQty       = 0;
                        toStorageDetail.CartonNo           = tcarton;
                        toStorageDetail.CDate              = FormatHelper.TODateInt(DateTime.Now);
                        toStorageDetail.CTime              = FormatHelper.TOTimeInt(DateTime.Now);
                        toStorageDetail.CUser              = userCode;
                        toStorageDetail.DQMCode            = fromStorageDetail.DQMCode;
                        toStorageDetail.FacCode            = fromStorageDetail.FacCode;
                        toStorageDetail.FreezeQty          = 0;
                        toStorageDetail.LastStorageAgeDate = fromStorageDetail.LastStorageAgeDate;
                        toStorageDetail.LocationCode       = tLocationCode;
                        toStorageDetail.Lotno              = fromStorageDetail.Lotno;
                        toStorageDetail.MaintainDate       = FormatHelper.TODateInt(DateTime.Now);
                        toStorageDetail.MaintainTime       = FormatHelper.TOTimeInt(DateTime.Now);
                        toStorageDetail.MaintainUser       = userCode;
                        toStorageDetail.MCode              = fromStorageDetail.MCode;
                        toStorageDetail.MDesc              = fromStorageDetail.MDesc;
                        toStorageDetail.ProductionDate     = fromStorageDetail.ProductionDate;
                        toStorageDetail.ReworkApplyUser    = fromStorageDetail.ReworkApplyUser;
                        toStorageDetail.StorageAgeDate     = fromStorageDetail.StorageAgeDate;
                        toStorageDetail.StorageCode        = fromStorageDetail.StorageCode;
                        toStorageDetail.StorageQty         = 0;
                        toStorageDetail.SupplierLotNo      = fromStorageDetail.SupplierLotNo;
                        toStorageDetail.Unit           = fromStorageDetail.Unit;
                        toStorageDetail.ValidStartDate = fromStorageDetail.ValidStartDate;
                        facade.AddStorageDetail(toStorageDetail);
                    }

                    toStorageDetail.StorageQty   += fromStorageDetail.StorageQty;
                    toStorageDetail.AvailableQty += fromStorageDetail.AvailableQty;



                    facade.UpdateStorageDetail(toStorageDetail);

                    StorloctransDetail storloctransDetail = (StorloctransDetail)_WarehouseFacade.GetStorloctransdetail(transNo, fromStorageDetail.MCode);
                    storloctransDetail.Qty += fromStorageDetail.AvailableQty;
                    _WarehouseFacade.UpdateStorloctransdetail(storloctransDetail);

                    #region 4,	向TBLStorLocTransDetailCarton插入一笔数据。
                    StorloctransDetailCarton newstorlocDetailCarton = new StorloctransDetailCarton();
                    newstorlocDetailCarton.Transno          = transNo;                 //storlocDetailCarton.Transno = StorLocTransDetail.TransNo;
                    newstorlocDetailCarton.MCode            = fromStorageDetail.MCode; //MCODE:TBLStorLocTransDetail.MCODE
                    newstorlocDetailCarton.DqmCode          = fromStorageDetail.DQMCode;
                    newstorlocDetailCarton.FacCode          = "10Y2";
                    newstorlocDetailCarton.Qty              = fromStorageDetail.StorageQty;   //QTY: TBLStorageDetail. storageQTY
                    newstorlocDetailCarton.LocationCode     = tLocationCode;                  //LocationCode: TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找)
                    newstorlocDetailCarton.Cartonno         = tcarton;                        //CARTONNO:PDA页面的目标箱号 txtTLocationCartonEdit
                    newstorlocDetailCarton.FromlocationCode = fromStorageDetail.LocationCode; //FromLocationCode:TBLStorageDetail.LocationCode
                    newstorlocDetailCarton.Fromcartonno     = fromStorageDetail.CartonNo;     //FromCARTONNO:TBLStorageDetail. CARTONNO
                    newstorlocDetailCarton.Lotno            = fromStorageDetail.Lotno;        //LotNo:TBLStorageDetail. LotNo
                    newstorlocDetailCarton.CUser            = userCode;                       //	CUSER
                    newstorlocDetailCarton.CDate            = dbDateTime.DBDate;              //	CDATE
                    newstorlocDetailCarton.CTime            = dbDateTime.DBTime;              //	CTIME
                    newstorlocDetailCarton.MaintainDate     = dbDateTime.DBDate;              //	MDATE
                    newstorlocDetailCarton.MaintainTime     = dbDateTime.DBTime;              //	MTIME
                    newstorlocDetailCarton.MaintainUser     = userCode;
                    _WarehouseFacade.AddStorloctransdetailcarton(newstorlocDetailCarton);
                    #endregion
                    //5,	如果原箱号在TBLStorageDetailSN有SN信息,将SN信息插入到TBLStorLocTransDetailSN表
                    object[] storageDetailSnlist = facade.GetStorageDetailSnbyCarton(fromCarton);
                    if (storageDetailSnlist != null)
                    {
                        foreach (StorageDetailSN newStorageDetailSn in storageDetailSnlist)
                        {
                            #region add TBLStorageDetailSN
                            StorloctransDetailSN newStorloctransDetailSn = new StorloctransDetailSN();
                            newStorloctransDetailSn.Sn           = newStorageDetailSn.SN; //SN:TBLStorageDetailSN.SN
                            newStorloctransDetailSn.Transno      = transNo;               // TBLStorLocTransDetail. TransNo
                            newStorloctransDetailSn.Fromcartonno = fromCarton;            //FromCARTONNO:TBLStorageDetail.LocationCode
                            newStorloctransDetailSn.Cartonno     = tcarton;               //FormatHelper.CleanString(txtTLocationCodeEdit.Text);//CARTONNO:TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找)
                            newStorloctransDetailSn.MaintainDate = dbDateTime.DBDate;     //	MDATE
                            newStorloctransDetailSn.MaintainTime = dbDateTime.DBTime;     //	MTIME
                            newStorloctransDetailSn.MaintainUser = userCode;
                            _WarehouseFacade.AddStorloctransdetailsn(newStorloctransDetailSn);

                            newStorageDetailSn.CartonNo     = tcarton;
                            newStorageDetailSn.MaintainDate = FormatHelper.TODateInt(DateTime.Now);
                            newStorageDetailSn.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now);
                            newStorageDetailSn.MaintainUser = userCode;
                            facade.UpdateStorageDetailSN(newStorageDetailSn);
                            #endregion
                        }
                    }
                }
                #endregion

                #region【拆箱】:
                else if (statusList == CartonType.CartonType_SplitCarton)
                {
                    Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(storageCarton.MCode);
                    if (material != null)
                    {
                        //2单件管控IsInt
                        if (material.MCONTROLTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
                        {
                            #region     单件管控:

                            msgsn = "SN:" + inputsn;
                            if (string.IsNullOrEmpty(inputsn))
                            {
                                msg = "此箱为单件管控,请输入SN。";
                                return(msg);
                            }


                            StorageDetailSN storageDetailSn = (StorageDetailSN)facade.GetStorageDetailSN(inputsn);

                            if (storageDetailSn == null)
                            {
                                return("此SN不存在!");
                            }
                            if (storageDetailSn.CartonNo != fromCarton)
                            {
                                return("原箱中不存在此SN!");
                            }



                            decimal storageQTY = fromStorageDetail.StorageQty - fromStorageDetail.FreezeQty;
                            if (storageQTY <= 0)
                            {
                                return("原箱号的库存数量不足:" + storageQTY);
                            }



                            if (toStorageDetail == null)
                            {
                                toStorageDetail = new StorageDetail();
                                toStorageDetail.AvailableQty       = 0;
                                toStorageDetail.CartonNo           = tcarton;
                                toStorageDetail.CDate              = FormatHelper.TODateInt(DateTime.Now);
                                toStorageDetail.CTime              = FormatHelper.TOTimeInt(DateTime.Now);
                                toStorageDetail.CUser              = userCode;
                                toStorageDetail.DQMCode            = fromStorageDetail.DQMCode;
                                toStorageDetail.FacCode            = fromStorageDetail.FacCode;
                                toStorageDetail.FreezeQty          = 0;
                                toStorageDetail.LastStorageAgeDate = fromStorageDetail.LastStorageAgeDate;
                                toStorageDetail.LocationCode       = tLocationCode;
                                toStorageDetail.Lotno              = fromStorageDetail.Lotno;
                                toStorageDetail.MaintainDate       = FormatHelper.TODateInt(DateTime.Now);
                                toStorageDetail.MaintainTime       = FormatHelper.TOTimeInt(DateTime.Now);
                                toStorageDetail.MaintainUser       = userCode;
                                toStorageDetail.MCode              = fromStorageDetail.MCode;
                                toStorageDetail.MDesc              = fromStorageDetail.MDesc;
                                toStorageDetail.ProductionDate     = fromStorageDetail.ProductionDate;
                                toStorageDetail.ReworkApplyUser    = fromStorageDetail.ReworkApplyUser;
                                toStorageDetail.StorageAgeDate     = fromStorageDetail.StorageAgeDate;
                                toStorageDetail.StorageCode        = fromStorageDetail.StorageCode;
                                toStorageDetail.StorageQty         = 0;
                                toStorageDetail.SupplierLotNo      = fromStorageDetail.SupplierLotNo;
                                toStorageDetail.Unit           = fromStorageDetail.Unit;
                                toStorageDetail.ValidStartDate = fromStorageDetail.ValidStartDate;
                                facade.AddStorageDetail(toStorageDetail);
                            }


                            #region add by sam 2016年4月27日
                            storageDetailSn.CartonNo = tcarton;
                            facade.UpdateStorageDetailSN(storageDetailSn);

                            fromStorageDetail.StorageQty   -= 1;
                            fromStorageDetail.AvailableQty -= 1;
                            facade.UpdateStorageDetail(fromStorageDetail);

                            toStorageDetail               = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton);
                            toStorageDetail.StorageQty   += 1;
                            toStorageDetail.AvailableQty += 1;
                            facade.UpdateStorageDetail(toStorageDetail);
                            #endregion


                            StorloctransDetail storloctransDetail = (StorloctransDetail)_WarehouseFacade.GetStorloctransdetail(transNo, fromStorageDetail.MCode);
                            storloctransDetail.Qty += fromStorageDetail.AvailableQty;
                            _WarehouseFacade.UpdateStorloctransdetail(storloctransDetail);
                            StorloctransDetailCarton storloctransDetailCarton =
                                (StorloctransDetailCarton)
                                _WarehouseFacade.GetStorloctransdetailcarton(transNo, fromCarton,
                                                                             tcarton);
                            if (storloctransDetailCarton != null)
                            {// 如果有: 更新TBLStorLocTransDetailCarton.QTY+ PDA页面填的数量,MDate,MTime,MUser。
                                storloctransDetailCarton.Qty         += 1;
                                storloctransDetailCarton.MaintainDate = dbDateTime.DBDate;
                                storloctransDetailCarton.MaintainTime = dbDateTime.DBTime;
                                storloctransDetailCarton.MaintainUser = userCode;
                                _WarehouseFacade.UpdateStorloctransdetailcarton(storloctransDetailCarton);
                            }
                            else
                            {
                                #region 4,	向TBLStorLocTransDetailCarton插入一笔数据。


                                StorloctransDetailCarton newstorlocDetailCarton = new StorloctransDetailCarton();
                                newstorlocDetailCarton.Transno          = transNo;// storloctransdetailObj.Transno;   //storlocDetailCarton.Transno = StorLocTransDetail.TransNo;
                                newstorlocDetailCarton.DqmCode          = storloctransdetailObj.DqmCode;
                                newstorlocDetailCarton.FacCode          = "10Y2";
                                newstorlocDetailCarton.MCode            = storloctransdetailObj.MCode;    //MCODE:TBLStorLocTransDetail.MCODE
                                newstorlocDetailCarton.Qty              = 1;                              //   //QTY: 1
                                newstorlocDetailCarton.LocationCode     = tLocationCode;                  // FormatHelper.CleanString(txtTLocationCodeEdit.Text);//LocationCode: TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找)
                                newstorlocDetailCarton.Cartonno         = tcarton;                        // FormatHelper.CleanString(txtTLocationCartonEdit.Text);//CARTONNO:PDA页面的目标箱号 txtTLocationCartonEdit
                                newstorlocDetailCarton.FromlocationCode = fromStorageDetail.LocationCode; //FromLocationCode:TBLStorageDetail.LocationCode
                                newstorlocDetailCarton.Fromcartonno     = fromCarton;                     // rageDetail.CartonNo; //FromCARTONNO:TBLStorageDetail. CARTONNO
                                newstorlocDetailCarton.Lotno            = fromStorageDetail.Lotno;        //LotNo:TBLStorageDetail. LotNo
                                newstorlocDetailCarton.CUser            = userCode;                       //	CUSER
                                newstorlocDetailCarton.CDate            = dbDateTime.DBDate;              //	CDATE
                                newstorlocDetailCarton.CTime            = dbDateTime.DBTime;              //	CTIME
                                newstorlocDetailCarton.MaintainDate     = dbDateTime.DBDate;              //	MDATE
                                newstorlocDetailCarton.MaintainTime     = dbDateTime.DBTime;              //	MTIME
                                newstorlocDetailCarton.MaintainUser     = userCode;
                                _WarehouseFacade.AddStorloctransdetailcarton(newstorlocDetailCarton);
                                #endregion

                                //说明:表中没有的字段来自TBLStorageDetail中对应字段
                                //F  向表TBLStorLocTransDetailSN插入一条数据。


                                StorloctransDetailSN newStorloctransDetailSn = new StorloctransDetailSN();
                                newStorloctransDetailSn.Sn           = inputsn;                       //SN:TBLStorageDetailSN.SN
                                newStorloctransDetailSn.Transno      = storloctransdetailObj.Transno; // TBLStorLocTransDetail. TransNo
                                newStorloctransDetailSn.Fromcartonno = fromCarton;                    //TBLStorageDetail.LocationCode
                                newStorloctransDetailSn.Cartonno     = tcarton;                       // FormatHelper.CleanString(txtTLocationCodeEdit.Text);//CARTONNO:TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找)
                                newStorloctransDetailSn.MaintainDate = dbDateTime.DBDate;             //	MDATE
                                newStorloctransDetailSn.MaintainTime = dbDateTime.DBTime;             //	MTIME
                                newStorloctransDetailSn.MaintainUser = userCode;
                                _WarehouseFacade.AddStorloctransdetailsn(newStorloctransDetailSn);
                            }
                            #endregion
                        }
                        else
                        {
                            #region 和非单件管控


                            //B 检查TBLStorageDetail. AvailableQTY>PDA页面填的数量。如果否,提示:输入的数量大于库存可用数量。
                            #region Check 数量
                            int qty;
                            if (!string.IsNullOrEmpty(inputqty))
                            {
                                try
                                {
                                    qty = Int32.Parse(inputqty);
                                }
                                catch (Exception ex)
                                {
                                    msg = "数量只能输入大于0的数字";
                                    return(msg);
                                }
                                if (qty <= 0)
                                {
                                    msg = "数量只能输入大于0的数字";
                                    return(msg);
                                }
                            }
                            else
                            {
                                msg = "数量不能为空";
                                return(msg);
                            }
                            #endregion

                            decimal stroageQTY = fromStorageDetail.StorageQty - fromStorageDetail.FreezeQty;

                            if (stroageQTY < qty)
                            {
                                msg = "输入的数量大于库存可用数量";
                                return(msg);
                            }

                            fromStorageDetail.AvailableQty -= qty;
                            fromStorageDetail.StorageQty   -= qty;
                            facade.UpdateStorageDetail(fromStorageDetail);



                            if (toStorageDetail == null)
                            {
                                toStorageDetail = new StorageDetail();
                                toStorageDetail.AvailableQty       = 0;
                                toStorageDetail.CartonNo           = tcarton;
                                toStorageDetail.CDate              = FormatHelper.TODateInt(DateTime.Now);
                                toStorageDetail.CTime              = FormatHelper.TOTimeInt(DateTime.Now);
                                toStorageDetail.CUser              = userCode;
                                toStorageDetail.DQMCode            = fromStorageDetail.DQMCode;
                                toStorageDetail.FacCode            = fromStorageDetail.FacCode;
                                toStorageDetail.FreezeQty          = 0;
                                toStorageDetail.LastStorageAgeDate = fromStorageDetail.LastStorageAgeDate;
                                toStorageDetail.LocationCode       = tLocationCode;
                                toStorageDetail.Lotno              = fromStorageDetail.Lotno;
                                toStorageDetail.MaintainDate       = FormatHelper.TODateInt(DateTime.Now);
                                toStorageDetail.MaintainTime       = FormatHelper.TOTimeInt(DateTime.Now);
                                toStorageDetail.MaintainUser       = userCode;
                                toStorageDetail.MCode              = fromStorageDetail.MCode;
                                toStorageDetail.MDesc              = fromStorageDetail.MDesc;
                                toStorageDetail.ProductionDate     = fromStorageDetail.ProductionDate;
                                toStorageDetail.ReworkApplyUser    = fromStorageDetail.ReworkApplyUser;
                                toStorageDetail.StorageAgeDate     = fromStorageDetail.StorageAgeDate;
                                toStorageDetail.StorageCode        = fromStorageDetail.StorageCode;
                                toStorageDetail.StorageQty         = 0;
                                toStorageDetail.SupplierLotNo      = fromStorageDetail.SupplierLotNo;
                                toStorageDetail.Unit           = fromStorageDetail.Unit;
                                toStorageDetail.ValidStartDate = fromStorageDetail.ValidStartDate;
                                facade.AddStorageDetail(toStorageDetail);
                            }

                            toStorageDetail               = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton);
                            toStorageDetail.StorageQty   += qty;
                            toStorageDetail.AvailableQty += qty;

                            facade.UpdateStorageDetail(toStorageDetail);

                            StorloctransDetailCarton storloctransDetailCarton =
                                (StorloctransDetailCarton)
                                _WarehouseFacade.GetStorloctransdetailcarton(transNo, fromCarton,
                                                                             tcarton);
                            if (storloctransDetailCarton != null)
                            {                                                // 如果有: 更新TBLStorLocTransDetailCarton.QTY+ PDA页面填的数量,MDate,MTime,MUser。
                                storloctransDetailCarton.Qty         += qty; // int.Parse(txtNumEdit.Text);
                                storloctransDetailCarton.MaintainDate = dbDateTime.DBDate;
                                storloctransDetailCarton.MaintainTime = dbDateTime.DBTime;
                                storloctransDetailCarton.MaintainUser = userCode;
                                _WarehouseFacade.UpdateStorloctransdetailcarton(storloctransDetailCarton);
                            }
                            else
                            {
                                #region 如果没有:插入一条数据     向TBLStorLocTransDetailCarton插入一笔数据。
                                StorloctransDetailCarton newstorlocDetailCarton = new StorloctransDetailCarton();
                                newstorlocDetailCarton.Transno          = transNo;                        // storloctransdetailObj.Transno;
                                newstorlocDetailCarton.DqmCode          = fromStorageDetail.DQMCode;      // storloctransdetailObj.DqmCode;
                                newstorlocDetailCarton.FacCode          = fromStorageDetail.FacCode;
                                newstorlocDetailCarton.MCode            = storageCarton.MCode;            // storloctransdetailObj.MCode;//MCODE:TBLStorLocTransDetail.MCODE
                                newstorlocDetailCarton.Qty              = qty;                            //QTY: 1
                                newstorlocDetailCarton.LocationCode     = tLocationCode;                  //FormatHelper.CleanString(txtTLocationCodeEdit.Text);//LocationCode: TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找)
                                newstorlocDetailCarton.Cartonno         = tcarton;                        // FormatHelper.CleanString(txtTLocationCartonEdit.Text);//CARTONNO:PDA页面的目标箱号 txtTLocationCartonEdit
                                newstorlocDetailCarton.FromlocationCode = fromStorageDetail.LocationCode; //FromLocationCode:TBLStorageDetail.LocationCode
                                newstorlocDetailCarton.Fromcartonno     = fromCarton;                     // storageDetail.CartonNo; //FromCARTONNO:TBLStorageDetail. CARTONNO
                                newstorlocDetailCarton.Lotno            = storageCarton.Lotno;            //LotNo:TBLStorageDetail. LotNo
                                newstorlocDetailCarton.CUser            = userCode;                       //	CUSER
                                newstorlocDetailCarton.CDate            = dbDateTime.DBDate;              //	CDATE
                                newstorlocDetailCarton.CTime            = dbDateTime.DBTime;              //	CTIME
                                newstorlocDetailCarton.MaintainDate     = dbDateTime.DBDate;              //	MDATE
                                newstorlocDetailCarton.MaintainTime     = dbDateTime.DBTime;              //	MTIME
                                newstorlocDetailCarton.MaintainUser     = userCode;
                                _WarehouseFacade.AddStorloctransdetailcarton(newstorlocDetailCarton);
                                #endregion
                            }
                            #endregion
                        }
                    }
                }
                #endregion



                fromStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(fromCarton);
                if (fromStorageDetail != null && fromStorageDetail.StorageQty == 0)
                {
                    _WarehouseFacade.DeleteStorageDetail(fromStorageDetail);
                }



                string documentno = CreateAutoDocmentsNo();
                SaveDocmentsNo(documentno, userCode);

                this.DataProvider.CommitTransaction();
                msg = "提交成功";
                return(msg);
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                msg = ex.Message;
                return(msg);
            }
        }
Ejemplo n.º 9
0
        protected void InitialObjects(object[] asnList)
        {
            //1>	入库指令号状态为:WaitReceive:待收货,则修改入库指令号(TBLASN、TBLASNDETAIL)状态为:Release:初始化
            //2>	入库指令号状态不为:WaitReceive:待收货,则报错提示当前入库指令号不能取消下发

            try
            {
                InventoryFacade facade = new InventoryFacade(base.DataProvider);

                WarehouseFacade _wa = new WarehouseFacade(DataProvider);
                //foreach (ASN asn in asnList)
                // {
                ASN asn = (ASN)asnList[0];

                if (asn.Status != "Release" && asn.Status != "Receive" && asn.Status != "WaitReceive")
                {
                    WebInfoPublish.Publish(this, asn.StNo + "入库指令号不能取消下发,状态必须是到货初检中才能取消下发", this.languageComponent1);
                    return;
                }

                this.DataProvider.BeginTransaction();

                _wa.UpdateASNForCancelDown(new string[] { asn.StNo }, "Release");

                facade.UpdateASNDetail(asn.StNo, ASNHeadStatus.Release);
                facade.UpdateASNDetailSN(asn.StNo);
                //facade.UpdateASNDetailItem(asn.StNo);


                DBDateTime dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider);

                InvInOutTrans trans = _wa.CreateNewInvInOutTrans();
                trans.CartonNO        = string.Empty;
                trans.DqMCode         = " ";
                trans.FacCode         = asn.FacCode;
                trans.FromFacCode     = string.Empty;
                trans.FromStorageCode = string.Empty;
                trans.InvNO           = asn.InvNo;
                trans.InvType         = asn.StType;
                trans.LotNo           = string.Empty;
                trans.MaintainDate    = dbTime1.DBDate;
                trans.MaintainTime    = FormatHelper.TOTimeInt(DateTime.Now);
                trans.MaintainUser    = this.GetUserCode();
                trans.MCode           = " ";
                trans.ProductionDate  = 0;
                trans.Qty             = 0;
                trans.Serial          = 0;
                trans.StorageAgeDate  = 0;
                trans.StorageCode     = asn.StorageCode;
                trans.SupplierLotNo   = string.Empty;
                trans.TransNO         = asn.StNo;
                trans.TransType       = "IN";
                trans.Unit            = string.Empty;
                trans.ProcessType     = "CANCELISSUE";
                _wa.AddInvInOutTrans(trans);


                this.DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                throw ex;
            }
        }
Ejemplo n.º 10
0
        //protected override void gridWebGrid_ItemCommand(GridRecord row, string commandName)
        //{
        //    if (commandName == "Edit")
        //    {
        //        object obj = this.GetEditObject(row);
        //        if (obj != null)
        //        {
        //            this.SetEditObject(obj);
        //            this.buttonHelper.PageActionStatusHandle(PageActionType.Update);
        //        }
        //    }
        //    else if (commandName == "LinkDetail")
        //    {
        //        string pickNo = row.Items.FindItemByKey("PickNo").Text.Trim();
        //        //string storageOut = row.Items.FindItemByKey("StorageOut").Text.Trim();
        //        Response.Redirect(this.MakeRedirectUrl("FCreatePickLineMP.aspx", new string[] { "ACT", "PickNo" }, new string[] { "LinkDetail", pickNo }));
        //    }
        //}



        protected override void cmdExport_Click(object sender, EventArgs e)
        {
            BenQGuru.eMES.Material.WarehouseFacade _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider);

            List <string> ca = new List <string>();

            XlsPackage xls  = new XlsPackage();
            IFont      font = xls.Black;

            font.FontHeightInPoints = 10;
            ICellStyle style = xls.Normal;

            style.SetFont(font);

            xls.CreateSheet("IQC明细表");
            xls.NewRow(0);
            xls.Cell(0, "IQC单号", style);
            xls.Cell(1, "SAP单据号", style);
            //xls.Cell(2, "SAP单据号", style);
            xls.Cell(2, "入库类型", style);
            xls.Cell(3, "库位", style);
            xls.Cell(4, "供应商代码", style);
            xls.Cell(5, "供应商名称", style);
            xls.Cell(6, "鼎桥物料编码", style);
            xls.Cell(7, "供应商物料编码", style);
            xls.Cell(8, "鼎桥物料描述", style);
            xls.Cell(9, "检验方式", style);
            xls.Cell(10, "AQL标准", style);
            xls.Cell(11, "来料数量", style);
            xls.Cell(12, "样本数量", style);
            xls.Cell(13, "缺陷品数", style);
            xls.Cell(14, "退换货数量", style);
            xls.Cell(15, "现场整改数量", style);
            xls.Cell(16, "让步接收数量", style);
            xls.Cell(17, "特采放行数量", style);
            int cellNum = 18;
            SystemSettingFacade _SystemSettingFacade = new SystemSettingFacade(base.DataProvider);

            object[] objs = _SystemSettingFacade.GetErrorGroupcode();
            if (objs != null && objs.Length > 0)
            {
                foreach (ErrorCodeGroupA ecg in objs)
                {
                    xls.Cell(cellNum, ecg.ErrorCodeGroupDescription, style);
                    cellNum++;
                }
            }

            xls.Cell(cellNum++, "创建时间", style);

            xls.Cell(cellNum++, "QC检验完成时间", style);
            xls.Cell(cellNum++, "SQE判定完成时间", style);
            xls.Cell(cellNum++, "IQC检验完成时间", style);
            xls.Cell(cellNum++, "QC检验执行时间", style);
            xls.Cell(cellNum++, "SQE判定执行时间", style);
            xls.Cell(cellNum++, "IQC检验执行时间", style);



            int rowNum = 1;

            IQCDetailRecord[] iqcs = _WarehouseFacade.QueryIQCs(this.txtStorageCodeQuery.Text,
                                                                this.txtVendorCodeQuery.Text, this.drpStorageInTypeQuery.SelectedValue,
                                                                FormatHelper.TODateInt(dateInDateFromQuery.Text),
                                                                FormatHelper.TODateInt(dateInDateToQuery.Text));

            InventoryFacade _InventoryFacade = new InventoryFacade(base.DataProvider);


            for (int i = 0; i < iqcs.Length; i++)
            {
                xls.NewRow(rowNum);
                string iqcNO = iqcs[i].IQCNO;
                xls.Cell(0, iqcNO, style);
                string invNo = iqcs[i].INVNO;
                xls.Cell(1, invNo, style);
                string stType = iqcs[i].STTYPE;
                xls.Cell(2, stType, style);
                string StorageCode = iqcs[i].StorageCode;
                xls.Cell(3, StorageCode, style);
                string VENDORCODE = iqcs[i].VENDORCODE;
                xls.Cell(4, VENDORCODE, style);
                string VendorName = iqcs[i].VendorName;
                xls.Cell(5, VendorName, style);
                string DQMCODE = iqcs[i].DQMCODE;
                xls.Cell(6, DQMCODE, style);
                string VENDORMCODE = iqcs[i].VENDORMCODE;
                xls.Cell(7, VENDORMCODE, style);

                Domain.MOModel.Material m = (Domain.MOModel.Material)_InventoryFacade.GetMaterialByDQMCode(iqcs[i].DQMCODE);

                string MDESC = m.MchlongDesc;
                xls.Cell(8, MDESC, style);
                string IQCTYPE = iqcs[i].IQCTYPE;
                xls.Cell(9, IQCTYPE, style);
                string AQLLEVEL = iqcs[i].AQLLEVEL;
                xls.Cell(10, AQLLEVEL, style);
                string QTY = iqcs[i].QTY.ToString();
                xls.Cell(11, QTY, style);
                string IQCQTY = iqcs[i].SAMPLESIZE.ToString();
                xls.Cell(12, IQCQTY, style);
                string NGQTY = iqcs[i].NGQTY.ToString();
                xls.Cell(13, NGQTY, style);
                string RETURNQTY = iqcs[i].RETURNQTY.ToString();
                xls.Cell(14, RETURNQTY, style);
                string ReformQTY = iqcs[i].ReformQTY.ToString();
                xls.Cell(15, ReformQTY, style);
                string GiveQTY = iqcs[i].GiveQTY.ToString();
                xls.Cell(16, GiveQTY, style);
                string AcceptQTY = iqcs[i].AcceptQTY.ToString();
                xls.Cell(17, AcceptQTY, style);
                int cellNum2 = 18;
                if (objs != null && objs.Length > 0)
                {
                    foreach (ErrorCodeGroupA ecg in objs)
                    {
                        int num = _WarehouseFacade.GetErrorGroupNum(iqcs[i].IQCNO, ecg.ErrorCodeGroup);
                        xls.Cell(cellNum2, num, style);
                        cellNum2++;
                    }
                }
                string CDATE = iqcs[i].CDATE.ToString();
                xls.Cell(cellNum2++, CDATE, style);


                InvInOutTrans OCFinishInv  = _WarehouseFacade.QCFinishDateTimeTrans(iqcs[i].IQCNO);
                InvInOutTrans SQEFinishInv = _WarehouseFacade.SQEFinishDateTimeTrans(iqcs[i].IQCNO);
                InvInOutTrans IQCFinishInv = SQEFinishInv ?? (OCFinishInv ?? null);

                string QCFINISHDATEStr = OCFinishInv != null?FormatHelper.ToDateString(OCFinishInv.MaintainDate) : string.Empty;

                string SEQFINISHDATEStr = SQEFinishInv != null?FormatHelper.ToDateString(SQEFinishInv.MaintainDate) : string.Empty;

                string IQCFINISHDATEStr = IQCFinishInv != null?FormatHelper.ToDateString(IQCFinishInv.MaintainDate) : string.Empty;

                decimal QCDATERANGE = OCFinishInv != null?Common.Totalday(OCFinishInv.MaintainDate, OCFinishInv.MaintainTime, iqcs[i].CDATE, iqcs[i].CTIME) : (decimal)0;

                string IQCSEQDATERANGE = string.Empty;
                string IQCDATERANGEStr = string.Empty;
                if (OCFinishInv != null && SQEFinishInv != null)
                {
                    IQCSEQDATERANGE = Common.Totalday(SQEFinishInv.MaintainDate, SQEFinishInv.MaintainTime, OCFinishInv.MaintainDate, OCFinishInv.MaintainTime).ToString();
                }


                if (IQCFinishInv != null)
                {
                    IQCDATERANGEStr = Common.Totalday(IQCFinishInv.MaintainDate, IQCFinishInv.MaintainTime, iqcs[i].CDATE, iqcs[i].CTIME).ToString();
                }



                xls.Cell(cellNum2++, QCFINISHDATEStr, style);


                xls.Cell(cellNum2++, SEQFINISHDATEStr, style);


                xls.Cell(cellNum2++, IQCFINISHDATEStr, style);



                xls.Cell(cellNum2++, QCDATERANGE.ToString(), style);


                xls.Cell(cellNum2++, IQCSEQDATERANGE, style);


                xls.Cell(cellNum2++, IQCDATERANGEStr, style);

                rowNum++;
            }



            string filename = string.Format("Export_{0}_{1}.{2}", FormatHelper.TODateInt(System.DateTime.Now).ToString(), FormatHelper.TOTimeInt(System.DateTime.Now).ToString(), "xls");
            string filepath = string.Format(@"{0}{1}", this.DownloadPhysicalPath, filename);



            FileStream file = new FileStream(filepath, FileMode.Create, FileAccess.ReadWrite);

            xls.Save(file);
            file.Close();

            DownLoadFile1(filename);
        }
Ejemplo n.º 11
0
        protected override DataRow GetGridRow(object obj)
        {
            if (facade == null)
            {
                facade = new WarehouseFacade(base.DataProvider);
            }
            DataRow         row = this.DtSource.NewRow();
            IQCDetailRecord s   = (IQCDetailRecord)obj;

            InventoryFacade _InventoryFacade = new InventoryFacade(base.DataProvider);

            Domain.MOModel.Material m = (Domain.MOModel.Material)_InventoryFacade.GetMaterialByDQMCode(s.DQMCODE);

            row["IQCNO"]       = s.IQCNO;
            row["INVNO"]       = s.INVNO;
            row["STTYPE"]      = this.GetInvInName(s.STTYPE);
            row["StorageCode"] = s.StorageCode;
            row["VENDORCODE"]  = s.VENDORCODE;
            row["VendorName"]  = s.VendorName;
            row["DQMCODE"]     = s.DQMCODE;
            row["VENDORMCODE"] = s.VENDORMCODE;
            row["MDESC1111"]   = m.MchlongDesc;
            row["IQCTYPE"]     = s.IQCTYPE;
            row["AQLLEVEL"]    = s.AQLLEVEL;
            row["QTY"]         = s.QTY;


            row["IQCQTY"]    = s.SAMPLESIZE;
            row["NGQTY"]     = s.NGQTY;
            row["RETURNQTY"] = s.RETURNQTY;
            row["ReformQTY"] = s.ReformQTY;
            row["GiveQTY"]   = s.GiveQTY;
            row["AcceptQTY"] = s.AcceptQTY;

            SystemSettingFacade _SystemSettingFacade = new SystemSettingFacade(base.DataProvider);

            object[] objs = _SystemSettingFacade.GetErrorGroupcode();
            if (objs != null && objs.Length > 0)
            {
                foreach (ErrorCodeGroupA ecg in objs)
                {
                    row[ecg.ErrorCodeGroup] = facade.GetErrorGroupNum(s.IQCNO, ecg.ErrorCodeGroup);
                }
            }
            row["CDATE"] = FormatHelper.ToDateString(s.CDATE);

            InvInOutTrans OCFinishInv  = facade.QCFinishDateTimeTrans(s.IQCNO);
            InvInOutTrans SQEFinishInv = facade.SQEFinishDateTimeTrans(s.IQCNO);
            InvInOutTrans IQCFinishInv = SQEFinishInv ?? (OCFinishInv ?? null);

            row["QCFINISHDATE"] = OCFinishInv != null?FormatHelper.ToDateString(OCFinishInv.MaintainDate) : string.Empty;

            row["SEQFINISHDATE"] = SQEFinishInv != null?FormatHelper.ToDateString(SQEFinishInv.MaintainDate) : string.Empty;

            row["IQCFINISHDATE"] = IQCFinishInv != null?FormatHelper.ToDateString(IQCFinishInv.MaintainDate) : string.Empty;

            row["QCDATERANGE"] = OCFinishInv != null?Common.Totalday(OCFinishInv.MaintainDate, OCFinishInv.MaintainTime, s.CDATE, s.CTIME) : 0;

            if (OCFinishInv != null && SQEFinishInv != null)
            {
                row["IQCSEQDATERANGE"] = Common.Totalday(SQEFinishInv.MaintainDate, SQEFinishInv.MaintainTime, OCFinishInv.MaintainDate, OCFinishInv.MaintainTime);
            }
            else
            {
                row["IQCSEQDATERANGE"] = string.Empty;
            }

            if (IQCFinishInv != null)
            {
                row["IQCDATERANGE"] = Common.Totalday(IQCFinishInv.MaintainDate, IQCFinishInv.MaintainTime, s.CDATE, s.CTIME);
            }
            else
            {
                row["IQCDATERANGE"] = string.Empty;
            }
            return(row);
        }