Example #1
0
        //Process for Running Card
        private void ProcessRcard(string rcard)
        {
            //1.Get simulation and check it
            DataCollectFacade dcf = new DataCollectFacade(DataProvider);

            //Laws Lu,2007/01/05,新增	缓解性能问题
            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            //ActionOnLineHelper onlineHelper = new ActionOnLineHelper(DataProvider);
            Domain.DataCollect.Simulation sim = (new DataCollectFacade(DataProvider)).GetSimulation(rcard)
                                                as Domain.DataCollect.Simulation;

            if (sim == null)           //rcard must exist
            {
                ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(MessageType.Error, "$NoSimulation $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);
                //txtRCard.TextFocus(true, true);
                return;
            }

            if (sim != null && sim.CartonCode != String.Empty)           //rcard must not link with any carton
            {
                ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(MessageType.Error
                                                                                                                               , "$CS_RCARD_ALREADY_BELONGTO_CARTON $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);
                //txtRCard.TextFocus(true, true);
                return;
            }

            sim.CartonCode = txtCartonNO.Value.Trim().ToUpper();

            //2.Get cartion
            int flag = 0;            //Not Need Add

            Domain.MOModel.Item item = ((new ItemFacade(DataProvider)).GetItem(sim.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Domain.MOModel.Item);
            if (_carton.CAPACITY == 0)           //Get carton capacity by item
            {
                flag = 1;

                if (item.ItemCartonQty == 0)
                {
                    ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Error
                                                                                                                                         , "$CS_PLEASE_MAINTEIN_ITEMCARTON $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);
                    //txtRCard.TextFocus(true, true);
                    return;
                }
                _carton.CAPACITY = item.ItemCartonQty;
            }

            //3.set simulation cartoncode by current carton
            DataProvider.BeginTransaction();
            try
            {
                bool isSuccessful = true;

                Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider);
                if (flag == 1)               //need add new carton and update simulation
                {
                    _carton.COLLECTED = 1;

                    if (isSuccessful)
                    {
                        //Laws Lu,2006/06/30 support memo
                        _carton.EATTRIBUTE1 = txtMemo.Value.ToUpper().Trim();

                        //更新Carton号
                        dcf.UpdateSimulation(sim);

                        //ProductInfo product = onlineHelper.GetIDInfoBySimulation(sim);
//						Domain.DataCollect.SimulationReport simReport = onlineHelper.FillSimulationReport(product);
//						dcf.UpdateSimulationReport(simReport);
                        dcf.UpdateSimulationReportCartonNo(sim.RunningCard, sim.MOCode, _carton.CARTONNO);

                        //建立新Carton
                        pf.AddCARTONINFO(_carton);
                    }
                }
                else if (_carton.CAPACITY > _carton.COLLECTED)               //just need update carton and simulation
                {
                    if (Convert.ToInt32(_carton.CAPACITY) != item.ItemCartonQty)
                    {
                        isSuccessful = false;
                        ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Error
                                                                                                                                             , "$CS_ITEMCARTON_NOT_MATCH_CARTON $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()
                                                                                                                                             + " $CS_CARTON_NO =" + _carton.CARTONNO), false);
                    }

                    if (isSuccessful)
                    {
                        //Laws Lu,2006/06/30 support memo
                        _carton.EATTRIBUTE1 = txtMemo.Value.ToUpper().Trim();
                        //更新Carton号
                        dcf.UpdateSimulation(sim);
                        //ProductInfo product = onlineHelper.GetIDInfoBySimulation(sim);
//						Domain.DataCollect.SimulationReport simReport = onlineHelper.FillSimulationReport(product);
//						dcf.UpdateSimulationReport(simReport);
                        dcf.UpdateSimulationReportCartonNo(sim.RunningCard, sim.MOCode, _carton.CARTONNO);
                        //更新Carton中数量
                        //Laws Lu,2006/06/23	modify support update memo
                        pf.UpdateCollected(_carton.CARTONNO, _carton.EATTRIBUTE1);

                        /* added by jessie lee, 2006/6/16
                         * 更新备注 */
                        //pf.UpdateCARTONINFO(_carton);
                    }
                }
                else
                {
                    isSuccessful = false;
                    ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Error
                                                                                                                                         , "$CARTON_ALREADY_FILL_OUT"), false);
                }

                if (isSuccessful)
                {
                    DataProvider.CommitTransaction();

                    ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Success
                                                                                                                                         , "$CS_RCARD_CARTON_SUCCESS $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);

                    ProcessCarton(txtCartonNO.Value.Trim().ToUpper());
//					if(_carton.COLLECTED != 1)
//					{
//						_carton.COLLECTED = _carton.COLLECTED + 1;
//					}
                    //UpdateCartonQty();
                }
                else
                {
                    DataProvider.RollbackTransaction();
                }
            }
            catch (Exception ex)
            {
                ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(ex), false);
                DataProvider.RollbackTransaction();
            }
            finally
            {
                //Laws Lu,2007/01/05,新增	缓解性能问题
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
//				(DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();

                txtRCard.TextFocus(true, true);
            }
        }
Example #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
            }
        }