Exemple #1
0
        //Process Carton NO
        private void ProcessCarton(string cartonno)
        {
            DataCollectFacade dcf     = new DataCollectFacade(DataProvider);
            string            lotCode = txtLotCode.Value.Trim().ToUpper();

            #region lotCode 从当前Carton移转到另外一个Carton
            InventoryFacade materialDCF = new InventoryFacade(DataProvider);

            if (!CheckTargetCarton(cartonno))
            {
                if (!m_NeedAddNewCarton)
                {
                    ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                    txtCartonNO.TextFocus(true, true);
                    return;
                }
            }
            object objSimulationReport = dcf.GetLastLotSimulationReport(lotCode);

            if (objSimulationReport != null)
            {
                Domain.LotDataCollect.LotSimulationReport simulationReport = objSimulationReport as Domain.LotDataCollect.LotSimulationReport;

                //simulationReport.CartonCode = cartonno.Trim().ToUpper();


                #region 移转操作
                DataProvider.BeginTransaction();
                try
                {
                    //Add By Bernard @ 2010-11-01
                    string moCode           = txtMoCode.Value.Trim().ToUpper();
                    string oldCartonno      = ucLabelComboxCurrentCarton.SelectedItemText;
                    bool   m_HasCartonAdded = false;
                    //end
                    decimal    oldCartonQty  = 0;
                    Carton2Lot oldCarton2Lot = (Carton2Lot)pf.GetCarton2Lot(oldCartonno.Trim().ToUpper(), lotCode.Trim().ToUpper());
                    if (oldCarton2Lot != null)
                    {
                        oldCartonQty = oldCarton2Lot.CartonQty;
                    }

                    int capaCity = ((new ItemFacade(DataProvider)).GetItem(simulationReport.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item).ItemCartonQty;



                    //包装箱不存在,为CartonInfo表增加一个包装箱信息
                    if (m_NeedAddNewCarton)
                    {
                        if (oldCartonQty > capaCity)
                        {
                            ucMessage.Add(new UserControl.Message(MessageType.Error
                                                                  , "$CS_CartonQty_IS_Large $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper()));
                            ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                            this.DataProvider.RollbackTransaction();
                            txtCartonNO.TextFocus(true, true);
                            return;
                        }

                        DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                        BenQGuru.eMES.Domain.Package.CARTONINFO newCarton = new BenQGuru.eMES.Domain.Package.CARTONINFO();

                        newCarton.CARTONNO    = cartonno.Trim().ToUpper();
                        newCarton.CAPACITY    = capaCity;
                        newCarton.COLLECTED   = 0;
                        newCarton.EATTRIBUTE1 = "";
                        newCarton.PKCARTONID  = System.Guid.NewGuid().ToString().ToUpper();
                        newCarton.MUSER       = ApplicationService.Current().UserCode;
                        newCarton.MDATE       = currentDateTime.DBDate;
                        newCarton.MTIME       = currentDateTime.DBTime;
                        pf.AddCARTONINFO(newCarton);

                        //0.向tblcarton2rcard表增加一个包装箱 Add By Bernard @ 2010-11-01
                        Carton2Lot newCarton2Lot = new Carton2Lot();
                        newCarton2Lot.CartonCode  = cartonno.Trim().ToUpper();
                        newCarton2Lot.LotCode     = lotCode;
                        newCarton2Lot.CartonQty   = oldCartonQty;
                        newCarton2Lot.MUser       = ApplicationService.Current().UserCode;
                        newCarton2Lot.MDate       = currentDateTime.DBDate;
                        newCarton2Lot.MTime       = currentDateTime.DBTime;
                        newCarton2Lot.Eattribute1 = "";
                        newCarton2Lot.MOCode      = moCode;

                        pf.AddCarton2Lot(newCarton2Lot);
                        m_HasCartonAdded = true;
                        //end
                    }


                    //判断箱中采集数量是否大与包装容量
                    object obj = pf.GetCARTONINFO(cartonno.Trim().ToUpper());
                    Domain.Package.CARTONINFO carton = obj as Domain.Package.CARTONINFO;
                    if ((carton.COLLECTED + oldCartonQty) > carton.CAPACITY)
                    {
                        this.DataProvider.RollbackTransaction();
                        ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_CartonQty_IS_Large $CS_CARTON_NO =" + cartonno.Trim().ToUpper()));
                        ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                        txtCartonNO.TextFocus(true, true);
                        return;
                    }


                    //1.判断新箱与旧箱内产品工单代码是否一致 Add By Bernard @ 2010-11-01
                    object oldObj = pf.GetCarton2Lot(oldCartonno, lotCode);

                    string newMOCode = moCode;
                    string oldMOCode = ((Carton2Lot)oldObj).MOCode;

                    if (oldMOCode == newMOCode)        //工单代码一致
                    {
                        if (m_HasCartonAdded == false) //箱号没有新增,则向Carton2RCard新增一条记录
                        {
                            DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                            object newObj = pf.GetCarton2Lot(cartonno, lotCode);
                            if (newObj == null)
                            {
                                Carton2Lot carton2Lot = new Carton2Lot();
                                carton2Lot.LotCode     = lotCode;
                                carton2Lot.CartonQty   = oldCartonQty;
                                carton2Lot.CartonCode  = cartonno;
                                carton2Lot.MOCode      = moCode;
                                carton2Lot.MUser       = ApplicationService.Current().UserCode;
                                carton2Lot.MDate       = currentDateTime.DBDate;
                                carton2Lot.MTime       = currentDateTime.DBTime;
                                carton2Lot.Eattribute1 = "";
                                pf.AddCarton2Lot(carton2Lot);
                            }
                            else
                            {
                                Carton2Lot carton2Lot = newObj as Carton2Lot;
                                carton2Lot.CartonQty = carton2Lot.CartonQty + oldCartonQty;
                                carton2Lot.MUser     = ApplicationService.Current().UserCode;
                                carton2Lot.MDate     = currentDateTime.DBDate;
                                carton2Lot.MTime     = currentDateTime.DBTime;
                                pf.UpdateCarton2Lot(carton2Lot);
                            }
                        }
                        //end

                        dcf.RemoveFromCarton(simulationReport.LotCode, oldCartonno, ApplicationService.Current().UserCode);

                        pf.UpdateCollected(cartonno.Trim().ToUpper(), oldCartonQty);


                        //记log
                        pf.AddCarton2LotLog(cartonno, simulationReport.LotCode, oldCartonQty, ApplicationService.Current().UserCode);
                        //end
                    }
                    else
                    {
                        DataProvider.RollbackTransaction();
                        ucMessage.Add(new UserControl.Message(MessageType.Error, "$ERROR_CARTON_MOCODE $CS_CARTON_NO =" + cartonno.Trim().ToUpper()));
                        ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                        txtCartonNO.TextFocus(true, true);
                        return;
                    }

                    //判断相中的批次是否属于同一批次
                    int mocodeCount = pf.GetMoCountByCartonNo(cartonno);
                    if (mocodeCount > 1)
                    {
                        DataProvider.RollbackTransaction();
                        ucMessage.Add(new UserControl.Message(MessageType.Error, "$ERROR_CARTON_MOCODE $CS_CARTON_NO =" + cartonno.Trim().ToUpper()));
                        ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                        txtCartonNO.TextFocus(true, true);
                        return;
                    }
                    //end


                    DataProvider.CommitTransaction();

                    ucMessage.Add(new UserControl.Message(MessageType.Success
                                                          , "$CS_LOTCODE_TRANSFER_CARTON_SUCCESS $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper()));
                    ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode"));
                    txtLotCode.TextFocus(true, true);
                    txtCartonNO.Value = String.Empty;
                    ClearLotCodeInfo();
                }
                catch (Exception ex)
                {
                    DataProvider.RollbackTransaction();
                    ucMessage.Add(new UserControl.Message(ex));

                    txtCartonNO.TextFocus(true, true);
                }
                finally
                {
                    (DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();
                }
                #endregion
            }
            else
            {
                ucMessage.Add(new UserControl.Message(MessageType.Error, "$NoSimulation $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper()));
                ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode"));
                ClearLotCodeInfo();
                txtLotCode.TextFocus(true, true);
            }

            #endregion
        }
Exemple #2
0
        //Process Carton NO
        private void ProcessCarton(string cartonno)
        {
            DataCollectFacade dcf   = new DataCollectFacade(DataProvider);
            string            rCard = txtRCard.Value.Trim().ToUpper();

            rCard = dcf.GetSourceCard(rCard, string.Empty);

            //箱号为空时,表示序列号从旧箱中移除
            if (cartonno == String.Empty)
            {
                #region RCARD 从 Carton中移出
                if (DialogResult.OK == MessageBox.Show(this, MutiLanguages.ParserString("$CS_Confirm_Transfer_1") + " " + txtRCard.Value.Trim().ToUpper() + " "
                                                       + MutiLanguages.ParserString("$CS_Confirm_Transfer_2") + txtCurrentCarton.Value.Trim().ToUpper() + " " + MutiLanguages.ParserString("$CS_Confirm_Transfer_3"), MutiLanguages.ParserString("$ShowConfirm"), MessageBoxButtons.OKCancel))
                {
                    InventoryFacade materialDCF = new InventoryFacade(DataProvider);

                    object objSimulationReport = dcf.GetLastSimulationReport(rCard);

                    //在制品存在
                    if (objSimulationReport != null)
                    {
                        Domain.DataCollect.SimulationReport sim = objSimulationReport as Domain.DataCollect.SimulationReport;

                        sim.CartonCode = String.Empty;
                        PackageFacade pf = new PackageFacade(DataProvider);

                        #region 移出操作
                        DataProvider.BeginTransaction();
                        try
                        {
                            dcf.RemoveFromCarton(sim.RunningCard, ApplicationService.Current().UserCode);
                            //dcf.RemoveFromPallet2RCard(sim.RunningCard);
                            DataProvider.CommitTransaction();

                            ucMessage.Add(new UserControl.Message(MessageType.Success
                                                                  , "$CS_RCARD_BREAK_FROM_CARTON_SUCCESS $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()));

                            txtRCard.TextFocus(true, true);
                            txtCartonNO.Value = String.Empty;
                            ClearRCardInfo();
                        }
                        catch (Exception ex)
                        {
                            DataProvider.RollbackTransaction();
                            ucMessage.Add(new UserControl.Message(ex));

                            txtCartonNO.TextFocus(true, true);
                        }
                        finally
                        {
                            (DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();
                        }
                        #endregion
                    }
                    else//在制品不存在
                    {
                        ucMessage.Add(new UserControl.Message(MessageType.Error
                                                              , "$NoSimulation $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()));

                        ClearRCardInfo();
                        txtRCard.TextFocus(true, true);
                    }
                }
                #endregion
            }
            else
            {
                #region RCARD 从当前Carton移转到另外一个Carton
                InventoryFacade materialDCF = new InventoryFacade(DataProvider);
                //ActionOnLineHelper onlineHelper = new ActionOnLineHelper(DataProvider);

                if (!CheckTargetCarton(cartonno))
                {
                    if (!m_NeedAddNewCarton)
                    {
                        txtCartonNO.TextFocus(true, true);
                        return;
                    }
                }
                string sourceCard          = dcf.GetSourceCard(txtRCard.Value.Trim().ToUpper(), string.Empty);
                object objSimulationReport = dcf.GetLastSimulationReport(sourceCard);

                if (objSimulationReport != null)
                {
                    Domain.DataCollect.SimulationReport simulationReport = objSimulationReport as Domain.DataCollect.SimulationReport;

                    simulationReport.CartonCode = cartonno.Trim().ToUpper();
                    Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider);

                    #region 移转操作
                    DataProvider.BeginTransaction();
                    try
                    {
                        //Add By Bernard @ 2010-11-01
                        string moCode           = txtMoCode.Value.Trim().ToUpper();
                        string oldCartonno      = txtCurrentCarton.Value.Trim().ToUpper();
                        bool   m_HasCartonAdded = false;
                        //end

                        //包装箱不存在,为CartonInfo表增加一个包装箱信息
                        if (m_NeedAddNewCarton)
                        {
                            DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                            BenQGuru.eMES.Domain.Package.CARTONINFO newCarton = new BenQGuru.eMES.Domain.Package.CARTONINFO();

                            newCarton.CARTONNO    = cartonno.Trim().ToUpper();
                            newCarton.CAPACITY    = ((new ItemFacade(DataProvider)).GetItem(simulationReport.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item).ItemCartonQty;
                            newCarton.COLLECTED   = 0;
                            newCarton.EATTRIBUTE1 = "";
                            newCarton.PKCARTONID  = System.Guid.NewGuid().ToString().ToUpper();
                            newCarton.MUSER       = ApplicationService.Current().UserCode;
                            newCarton.MDATE       = currentDateTime.DBDate;
                            newCarton.MTIME       = currentDateTime.DBTime;
                            pf.AddCARTONINFO(newCarton);

                            //0.向tblcarton2rcard表增加一个包装箱 Add By Bernard @ 2010-11-01
                            Carton2RCARD newCarton2RCard = new Carton2RCARD();
                            newCarton2RCard.CartonCode  = cartonno.Trim().ToUpper();
                            newCarton2RCard.Rcard       = rCard;
                            newCarton2RCard.MUser       = ApplicationService.Current().UserCode;
                            newCarton2RCard.MDate       = currentDateTime.DBDate;
                            newCarton2RCard.MTime       = currentDateTime.DBTime;
                            newCarton2RCard.Eattribute1 = "";
                            newCarton2RCard.MOCode      = moCode;
                            pf.AddCarton2RCARD(newCarton2RCard);
                            m_HasCartonAdded = true;
                            //end
                        }

                        //1.判断新箱与旧箱内产品工单代码是否一致 Add By Bernard @ 2010-11-01
                        object oldObj = pf.GetCarton2RCARD(oldCartonno, rCard);
                        //modified by lisa @20120829
                        //string newMOCode = moCode;
                        object[] newObj    = pf.GetCarton2RCARDByCartonNO(FormatHelper.CleanString(this.txtCartonNO.Value.Trim()));
                        string   newMOCode = ((Carton2RCARD)newObj[0]).MOCode;
                        //end add
                        string oldMOCode = ((Carton2RCARD)oldObj).MOCode;

                        if (oldMOCode == newMOCode)        //工单代码一致
                        {
                            if (m_HasCartonAdded == false) //箱号没有新增,则向Carton2RCard新增一条记录
                            {
                                DBDateTime   currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                                Carton2RCARD carton2rcard    = new Carton2RCARD();
                                carton2rcard.Rcard       = rCard;
                                carton2rcard.CartonCode  = cartonno;
                                carton2rcard.MOCode      = moCode;
                                carton2rcard.MUser       = ApplicationService.Current().UserCode;
                                carton2rcard.MDate       = currentDateTime.DBDate;
                                carton2rcard.MTime       = currentDateTime.DBTime;
                                carton2rcard.Eattribute1 = "";
                                pf.AddCarton2RCARD(carton2rcard);
                            }
                            //end

                            dcf.RemoveFromCarton(simulationReport.RunningCard, ApplicationService.Current().UserCode);

                            pf.UpdateCollected(cartonno.Trim().ToUpper());

                            Domain.DataCollect.Simulation simulation = (Domain.DataCollect.Simulation)dcf.GetSimulation(simulationReport.RunningCard);

                            if (simulation != null)
                            {
                                simulation.CartonCode = cartonno.Trim().ToUpper();
                                dcf.UpdateSimulation(simulation);
                            }

                            dcf.UpdateSimulationReport(simulationReport);

                            //记log
                            pf.addCarton2RCARDLog(cartonno, simulationReport.RunningCard, ApplicationService.Current().UserCode);
                            //end
                        }
                        else//新旧包装箱工单代码不一致 Add By Bernard @ 2010-11-01
                        {
                            if (m_HasCartonAdded == true)
                            {
                                //删除CartonInfo表新增加的包装箱
                                CARTONINFO cartoninfo = new CARTONINFO();
                                cartoninfo.CARTONNO = cartonno;
                                pf.DeleteCARTONINFO(cartoninfo);

                                //删除旧Carton2RCARD表新增加的箱号
                                Carton2RCARD carton2rcard = new Carton2RCARD();
                                carton2rcard.Rcard      = rCard;
                                carton2rcard.CartonCode = cartonno;
                                pf.DeleteCarton2RCARD(carton2rcard);
                            }
                            else
                            {
                                DataProvider.RollbackTransaction();
                                ucMessage.Add(new UserControl.Message(MessageType.Error,
                                                                      "$CS_CARTON_NO :" + cartonno + "$CS_Which_MOCode_With_RCard :" + rCard + "$CS_For_Carton_No's_MOCode_Is_Different"));
                                txtCartonNO.TextFocus(true, true);
                                return;
                            }
                        }
                        //end

                        DataProvider.CommitTransaction();

                        ucMessage.Add(new UserControl.Message(MessageType.Success
                                                              , "$CS_RCARD_TRANSFER_CARTON_SUCCESS $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()));

                        txtRCard.TextFocus(true, true);
                        txtCartonNO.Value = String.Empty;
                        ClearRCardInfo();
                    }
                    catch (Exception ex)
                    {
                        DataProvider.RollbackTransaction();
                        ucMessage.Add(new UserControl.Message(ex));

                        txtCartonNO.TextFocus(true, true);
                    }
                    finally
                    {
                        (DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();
                    }
                    #endregion
                }
                else
                {
                    ucMessage.Add(new UserControl.Message(MessageType.Error, "$NoSimulation $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()));

                    ClearRCardInfo();
                    txtRCard.TextFocus(true, true);
                }

                #endregion
            }
        }