Beispiel #1
0
        private Messages CheckINNO(object act)
        {
            Messages msg = new Messages();

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;
            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()
                                 as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }
            string         strInno  = act.ToString().ToUpper();
            MaterialFacade material = new MaterialFacade(domainProvider);

            object[] objsInno = material.GetLastMINNOs(strInno);
            if (objsInno == null)
            {
                msg.Add(new Message(MessageType.Error, "$CS_INNO_NOT_EXIST"));
                return(msg);
            }
            return(msg);
        }
Beispiel #2
0
        protected void Button4_Click(object sender, System.EventArgs e)
        {
            //刷新数据
            try
            {
                if (this.Label3.Text == "销售差异汇总表")
                {
                    DataTable dt = Helper.QueryLongTrans("Get_Dept_Dif '" + txtBeginDate.Text + "','" + txtEndDate.Text + "','" + ddlDept.SelectedValue + "'");

                    if (dt.Rows.Count > 0)
                    {
                        AMSApp.zhenghua.Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog();
                        MaterialFacade mf = new MaterialFacade();
                        mf.BatchDifference(dt, ol);
                    }
                }
                else
                {
                    DataTable dt = Helper.QueryLongTrans("Get_Oper_Dif '" + txtBeginDate.Text + "','" + txtEndDate.Text + "','" + ddlDept.SelectedValue + "'");

                    if (dt.Rows.Count > 0)
                    {
                        AMSApp.zhenghua.Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog();
                        MaterialFacade mf = new MaterialFacade();
                        mf.BatchDifference(dt, ol);
                    }
                }
                this.Popup("刷新数据成功!");
                Button3_Click(null, null);
            }
            catch (Exception ex)
            {
                this.Popup(ex.Message);
            }
        }
        private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            //更新
            try
            {
                //if(!JudgeIsCode())
                Material mat = new Material();
                mat.cnvcMaterialCode = ((TextBox)e.Item.Cells[0].Controls[1]).Text;


                mat.cnvcMaterialName = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
                mat.cnvcLeastUnit    = ((DropDownList)e.Item.Cells[2].Controls[1]).SelectedValue;
                mat.cnnPrice         = decimal.Parse(((TextBox)e.Item.Cells[3].Controls[0]).Text);
                mat.cnvcProductType  = ((DropDownList)e.Item.Cells[4].Controls[1]).SelectedValue;
                mat.cnnConversion    = decimal.Parse(((TextBox)e.Item.Cells[6].Controls[0]).Text);
                mat.cnvcUnit         = ((TextBox)e.Item.Cells[7].Controls[0]).Text;
                mat.cnvcStandardUnit = ((TextBox)e.Item.Cells[8].Controls[0]).Text;
                mat.cnnStatdardCount = decimal.Parse(((TextBox)e.Item.Cells[9].Controls[0]).Text);

                mat.cnvcProductClass = ((DropDownList)e.Item.Cells[5].Controls[1]).SelectedValue;

                if (!JudgeIsCode(mat.cnvcProductType, mat.cnvcProductClass, mat.cnvcMaterialCode))
                {
                    //Popup("编码错误");
                    //return;
                    throw new Exception("编码错误");
                }

                string strOldMaterialCode = e.Item.Cells[11].Text;

                if (strOldMaterialCode != mat.cnvcMaterialCode)
                {
                    string    strSql     = "select * from tbMaterial where cnvcMaterialCode='" + mat.cnvcMaterialCode + "'";
                    DataTable dtMaterial = Helper.Query(strSql);
                    if (dtMaterial.Rows.Count > 0)
                    {
                        //throw new Exception("相同编码原料材料已存在");
                        Popup("相同编码原料材料已存在");
                        return;
                    }
                }

                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "修改原料材料";

                MaterialFacade mf = new MaterialFacade();
                mf.UpdateMaterial(mat, strOldMaterialCode, operLog);
                this.DataGrid1.EditItemIndex = -1;
                BindMaterial();
                Popup("更新成功!");
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
                return;
            }
        }
Beispiel #4
0
        public Messages DropRCard(ProductInfo Product, string usercode, string rescode)
        {
            Messages msg = new Messages();

            this._rescode  = rescode;
            this._usercode = usercode;

            if (Product != null && Product.LastSimulation != null)
            {
                if (Product.LastSimulation.ProductStatus != ProductStatus.NG)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_NG"));
                    return(msg);
                }

                MaterialFacade mfacade = new MaterialFacade(this.DataProvider);
                OnWIPItem[]    items   = mfacade.QueryLoadedKeyPartByRCard(Product.LastSimulation.RunningCard, Product.LastSimulation.MOCode);
                if (items == null || items.Length == 0)
                {
                    //msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_No_KeyPart"));
                    return(msg);
                }
                this.LastRCardOnWIPItem = items;

                msg.AddMessages(BuildOPBomKeyPartsByOnWIPItem(Product.LastSimulation.RunningCard, Product, items));

                if (msg.IsSuccess())
                {
                    for (int i = 0; i < items.Length; i++)
                    {
                        string keyPart = items[i].MCARD;
                        //增加KeyParts
                        msg.AddMessages(AddKeyPart(keyPart, Product.LastSimulation.MOCode, Product.LastSimulation.RunningCard));
                        if (msg.IsSuccess() == false)
                        {
                            return(msg);
                        }
                    }
                    msg.AddMessages(DoAction(Product));

                    if (!msg.IsSuccess())
                    {
                        return(msg);
                    }
                    else
                    {
                        return(msg);
                    }
                }
                else
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                }

                return(msg);
            }

            return(msg);
        }
Beispiel #5
0
        public void ImportMaterialNeed(bool isRollBack)
        {
            ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this._DataProvider);
            DBDateTime       dbDateTime       = FormatHelper.GetNowDBDateTime(this._DataProvider);

            object[] objs  = ConvertArrayListToObjectArray(_ImportDataTable);
            object[] objDt = ConvertArrayListToObjectArray(_ImportDataTable);

            try
            {
                _DataProvider.BeginTransaction();

                if (objs != null && objDt != null)
                {
                    for (int i = 0; i < objs.Length; i++)
                    {
                        try
                        {
                            MaterialReqStd materialReqStd = objs[i] as MaterialReqStd;
                            if (_MaterialFacade == null)
                            {
                                _MaterialFacade = new MaterialFacade(_DataProvider);
                            }

                            object objWorkPlan = _MaterialFacade.GetMaterialReqStd(materialReqStd.ItemCode, materialReqStd.OrganizationID);

                            if (objWorkPlan != null)
                            {
                                _DataProvider.Update(objs[i]);
                                _DataProvider.Update(objDt[i]);
                            }
                            else
                            {
                                _DataProvider.Insert(objDt[i]);
                            }

                            GridRecord row = _ImportGridRow[i] as GridRecord;
                            row.Items.FindItemByKey("ImportResult").Text     = _LanguageComponent1.GetString("$CycleImport_Success");
                            row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue";
                        }
                        catch (Exception ex)
                        {
                            GridRecord row = _ImportGridRow[i] as GridRecord;
                            row.Items.FindItemByKey("ImportResult").Text     = "导入失败";
                            row.Items.FindItemByKey("ImportResult").CssClass = "ForeColorRed";
                            this.ErrorArray.Add(ex);
                        }
                    }
                }

                _DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                _DataProvider.RollbackTransaction();
                this.ErrorArray.Add(ex);
            }
        }
 protected override int GetRowCount()
 {
     if (_Facade == null)
     {
         _Facade = new MaterialFacade(base.DataProvider);
     }
     return(this._Facade.QueryMaterialTransCount(
                FormatHelper.TODateInt(DateTime.Now),
                FormatHelper.TODateInt(FormatHelper.CleanString(dateVoucherDateFrom.Text))
                ));
 }
        protected override object[] LoadDataSource(int inclusive, int exclusive)
        {
            if (_Facade == null)
            {
                _Facade = new MaterialFacade(base.DataProvider);
            }
            ;

            return(this._Facade.QueryMaterialTrans(
                       FormatHelper.TODateInt(DateTime.Now),
                       FormatHelper.TODateInt(FormatHelper.CleanString(dateVoucherDateFrom.Text)),
                       inclusive, exclusive));
        }
        private void btnCost_Click(object sender, System.EventArgs e)
        {
            //成本刷新
            try
            {
                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "成本刷新";

                MaterialFacade mf = new MaterialFacade();
                mf.UpdateCost(operLog);
                Popup("成本刷新成功");
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }
Beispiel #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                OperLog operLog = new OperLog();
                operLog.cnvcOperID   = oper.strLoginID;
                operLog.cnvcDeptID   = oper.strDeptID;
                operLog.cnvcOperType = "下架产品移除";

                MaterialFacade mf = new MaterialFacade();
                mf.DelFormula(operLog);
                Popup("移除成功!");
                btnQuery_Click(null, null);
            }
            catch (Exception ex)
            {
                Popup(ex.Message);
            }
        }
Beispiel #10
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            this.txtMoCode.TextFocus(false, true);
            MaterialFacade materialFacade = new MaterialFacade(this.DataProvider);

            object[] materialIssueAndPlanSeqs = materialFacade.QueryMaterialIssueAndPlanSeq(this.txtBigSSCode.Value.Trim().ToUpper(),
                                                                                            FormatHelper.TODateInt(this.ucPlanDate.Value),
                                                                                            this.txtMoCode.Value.Trim().ToUpper(),
                                                                                            MaterialIssueType.MaterialIssueType_Issue,
                                                                                            MaterialIssueStatus.MaterialIssueStatus_Delivered);

            _DataTableLoadedPart.Clear();

            if (materialIssueAndPlanSeqs == null)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Normal, "$CS_No_Data_To_Display"));
                return;
            }



            for (int i = 0; i < materialIssueAndPlanSeqs.Length; i++)
            {
                MaterialIssueAndPlanSeq materialIssueAndPlanSeq = materialIssueAndPlanSeqs[i] as MaterialIssueAndPlanSeq;
                _DataTableLoadedPart.Rows.Add(new object[] { "false",
                                                             materialIssueAndPlanSeq.IssueSEQ,
                                                             materialIssueAndPlanSeq.PlanDate,
                                                             materialIssueAndPlanSeq.BigSSCode,
                                                             materialIssueAndPlanSeq.PlanSeq,
                                                             materialIssueAndPlanSeq.MoCode,
                                                             materialIssueAndPlanSeq.MoSeq,
                                                             materialIssueAndPlanSeq.IssueQTY,
                                                             materialIssueAndPlanSeq.IssueQTY,
                                                             materialIssueAndPlanSeq.MaintainUser,
                                                             materialIssueAndPlanSeq.MaintainDate,
                                                             materialIssueAndPlanSeq.MaintainTime });
            }
        }
Beispiel #11
0
        private void txtMoCodeEdit_TxtboxKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (this.txtMoCodeEdit.Value == string.Empty)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$MO_Cannot_Null"));
                    this.txtMoCodeEdit.TextFocus(false, true);
                    return;
                }

                if (materialFacade == null)
                {
                    materialFacade = new MaterialFacade(this.DataProvider);
                }

                if (materialFacade.GetMOCode(this.txtMoCodeEdit.Value) == false)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Rework_MO_Not_Exist"));
                    this.txtMoCodeEdit.TextFocus(false, true);
                    return;
                }

                if (mofacade == null)
                {
                    mofacade = new MOFacade(this.DataProvider);
                }
                object objMO = mofacade.GetMO(this.txtMoCodeEdit.Value.Trim().ToUpper());
                if (objMO == null || ((MO)objMO).MOStatus.Trim().ToUpper() == "MOSTATUS_CLOSE")
                {
                    //该工单已关单,不能维护打X板!
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_MO_Close_Not_SmtRelQty"));
                    this.txtMoCodeEdit.TextFocus(false, true);
                    return;
                }
                this.txtRCardEdit.TextFocus(false, true);
            }
        }
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();

            this._LanguageComponent1                    = new ControlLibrary.Web.Language.LanguageComponent(this.components);
            this._LanguageComponent1.Language           = "CHS";
            this._LanguageComponent1.LanguagePackageDir = "";
            this._LanguageComponent1.RuntimePage        = null;
            this._LanguageComponent1.RuntimeUserControl = null;
            this._LanguageComponent1.UserControlName    = "";

            this._ExcelExporter = new BenQGuru.eMES.Web.Helper.ExcelExporter(this.components);
            this._ExcelExporter.FileExtension     = "xls";
            this._ExcelExporter.LanguageComponent = this._LanguageComponent1;
            this._ExcelExporter.Page     = this;
            this._ExcelExporter.RowSplit = "\r\n";

            this._MaterialFacade = new MaterialFacade(this.DataProvider);

            this.gridWebGrid.ClickCellButton += new Infragistics.WebUI.UltraWebGrid.ClickCellButtonEventHandler(this.gridWebGrid_ClickCellButton);

            this.pagerToolBar.OnPagerToolBarClick += new EventHandler(this.PagerToolBar_OnPagerToolBarClick);
        }
Beispiel #13
0
        private Messages CollectKeyPartTS(ProductInfo Product)
        {
            Messages msg = new Messages();

            // 根据联美兰达的需求,不良品如果到TS,则自动将KeyPart采到TS
            BenQGuru.eMES.TS.TSFacade  tsFacade = new BenQGuru.eMES.TS.TSFacade(this.DataProvider);
            BenQGuru.eMES.Domain.TS.TS ts       = (BenQGuru.eMES.Domain.TS.TS)tsFacade.GetCardLastTSRecord(Product.LastSimulation.RunningCard);
            if (ts != null && (ts.TSStatus == TSStatus.TSStatus_New || ts.TSStatus == TSStatus.TSStatus_Confirm || ts.TSStatus == TSStatus.TSStatus_TS))
            {
            }
            else
            {
                return(msg);
            }
            if (this.LastRCardOnWIPItem == null || this.LastRCardOnWIPItem.Length == 0)
            {
                return(msg);
            }

            Domain.TS.TSErrorCode2Location[] errorInfo = null;
            MaterialFacade mfacade = new MaterialFacade(this.DataProvider);


            ActionDropMaterial actionDrop = new ActionDropMaterial(this.DataProvider);

            for (int i = 0; i < this.LastRCardOnWIPItem.Length; i++)
            {
                msg.AddMessages(actionDrop.CollectKeyPartNG(this.LastRCardOnWIPItem[i].MCARD, errorInfo, _usercode, _rescode));
                if (msg.IsSuccess() == true)
                {
                    msg.Add(new UserControl.Message(MessageType.Success, "$KeyPart_NG_Collect_Success"));
                }
                msg.Add(new UserControl.Message(MessageType.Normal, "$PageControl_Keyparts: " + this.LastRCardOnWIPItem[i].MCARD));
            }
            return(msg);
        }
Beispiel #14
0
        public Messages DeductQty(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade, MINNO minno)
        {
            SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider);
            MaterialFacade      materialFacade      = new MaterialFacade(this.DataProvider);
            MOFacade            moFacade            = new MOFacade(this.DataProvider);
            OPBOMFacade         opbomFacade         = new OPBOMFacade(this.DataProvider);
            ItemFacade          itemFacade          = new ItemFacade(this.DataProvider);
            InventoryFacade     inventoryFacade     = new InventoryFacade(this.DataProvider);
            LotSimulation       simulation          = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
            LotSimulationReport simulationReport    = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
            Messages            returnValue         = new Messages();
            string lotNoList = string.Empty;// add by Jarvis For onWipItem

            ProductInfo   productionInfo = actionEventArgs.ProductInfo;
            LotSimulation sim            = actionEventArgs.ProductInfo.NowSimulation;
            int           orgid          = actionEventArgs.ProductInfo.Resource.OrganizationID;
            MO            mo             = actionEventArgs.ProductInfo.CurrentMO;

            if (mo == null)
            {
                mo = moFacade.GetMO(sim.MOCode) as MO;
            }

            //获取当前工单号
            string moCode = productionInfo.NowSimulation.MOCode;
            //获取当前工序号
            string opCode = productionInfo.NowSimulation.OPCode;
            //获取当前产品号
            string itemCode = productionInfo.NowSimulation.ItemCode;
            //获取途程代码
            string routeCode = productionInfo.NowSimulation.RouteCode;
            string resCode   = productionInfo.Resource.ResourceCode;
            //获取ORGID
            int    orgID    = productionInfo.Resource.OrganizationID;
            string moBomVer = string.Empty;

            object objMo = moFacade.GetMO(moCode);

            if (objMo != null)
            {
                moBomVer = (objMo as MO).BOMVersion;
            }

            //获取物料名称
            string MItemName = string.Empty;

            Domain.MOModel.Material material = ((Domain.MOModel.Material)itemFacade.GetMaterial(minno.MItemCode, orgID));
            if (material != null)
            {
                MItemName = material.MaterialName;
            }

            //添加产品已上料扣料判断  tblonwip
            string  lotNo = productionInfo.NowSimulation.LotCode;
            decimal seq   = productionInfo.NowSimulation.LotSeq;

            //object[] objOnWip = dataCollectFacade.QueryLotOnWIP(lotNo, moCode, opCode, "CINNO");

            //if (objOnWip != null && objOnWip.Length > 0)
            //{
            //    return returnValue;
            //}

            //remove by Jarvis 不检查工单BOM 20120321
            //object[] objMoBoms = moFacade.QueryMoBom(sim.ItemCode, minno.MItemCode, sim.MOCode);//检查工单BOM是否有该首选料, Jarvis 20120319
            //if (objMoBoms == null)
            //{
            //    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$Error_NotExistInMoBOM" + String.Format("[$MOCode='{0}']", sim.MOCode));
            //}

            object[] opbomObjs = opbomFacade.QueryOPBOMDetail(sim.ItemCode, minno.MItemCode, string.Empty, string.Empty, string.Empty, sim.RouteCode, opCode, (int)MaterialType.CollectMaterial, int.MinValue, int.MaxValue, orgid, true);
            if (opbomObjs == null)
            {
                throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$Error_NotExistInOPBOM" + String.Format("[$ItemCode='{0}']", sim.ItemCode));
            }

            object[] moRouteObjs = moFacade.QueryMORoutes(sim.MOCode, sim.RouteCode);
            if (moRouteObjs == null)
            {
                throw new Exception("$Error_MORouteNOExist");
            }

            bool iflag = false;

            decimal iOPBOMItemQty = 0;

            //需要比对的子阶料料号 比对成功的 只在工单生产BOM 中
            if (opbomObjs == null)//去掉检查工单BOM是否为空
            {
                return(returnValue);
            }

            //以工单标准BOM为基准,扣减当前工单的倒冲库存地(tblmo. EATTRIBUTE2)中相对应的库存信息
            //for (int n = 0; n < objMoBoms.Length; n++)//去掉工单BOM 20120321 Jarvis
            //{
            //求得opbom中对应的料品
            string TempMOBOMItemCode = minno.MItemCode;

            iflag         = false;
            iOPBOMItemQty = 0;
            for (int j = 0; j < opbomObjs.Length; j++)
            {
                if (TempMOBOMItemCode.ToUpper() == ((OPBOMDetail)opbomObjs[j]).OPBOMItemCode.ToUpper() ||
                    TempMOBOMItemCode.ToUpper() == ((OPBOMDetail)opbomObjs[j]).OPBOMSourceItemCode.ToUpper())
                {   //子阶料存在或有替代料可用
                    iflag = true;
                    //TempMOBOMItemCode = ((OPBOMDetail)opbomObjs[j]).OPBOMItemCode;//remove by Jarvis 20120316
                    //For 替代料,记录首选料号,Jarvis 20120316
                    //TempMOBOMItemCode = ((MOBOM)objMoBoms[n]).MOBOMItemCode;

                    iOPBOMItemQty  = (decimal)((OPBOMDetail)opbomObjs[j]).OPBOMItemQty;
                    iOPBOMItemQty *= sim.LotQty;

                    break;
                }
            }

            //比对成功:子阶料料号一致
            if (iflag)//子阶料不存在, 即只在工单标准bom中
            {
                //object[] objInfos = inventoryFacade.QueryStorageInfoByIDAndMCode(mo.EAttribute2, TempMOBOMItemCode.ToUpper());
                object[] objInfos = inventoryFacade.QueryStorageInfoByIDAndMCode(TempMOBOMItemCode.ToUpper());
                if (objInfos == null)
                {
                    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
                }

                //获取物料的总库存数,Jarvis 20120316
                //decimal total = inventoryFacade.GetStorageQty(mo.EAttribute2, TempMOBOMItemCode.ToUpper());
                decimal total = inventoryFacade.GetStorageQty(TempMOBOMItemCode.ToUpper());

                if (total < iOPBOMItemQty)
                {
                    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
                }

                #region //先判断备料批号中的数据量,不够扣减就退出
                decimal   temlotQty          = 0;
                object[]  objStorageLotInfo  = null;
                ArrayList StorageLotInfoList = new ArrayList();

                //获取子阶料的备料信息,Jarvis 20120316,按Seq排序
                object[] minnoss = materialFacade.QueryMINNO_New(moCode, routeCode, opCode, resCode, moBomVer, minno.MSourceItemCode);    //获取同一首选料的备料信息,Jarvis 20120321

                //获取备料信息中可扣减数,Jarvis 20120316
                foreach (MINNO temp in minnoss)
                {
                    //objStorageLotInfo = inventoryFacade.QueryStorageLot(temp.LotNO, mo.EAttribute2, temp.MItemCode);
                    objStorageLotInfo = inventoryFacade.QueryStorageLot(temp.LotNO, temp.MItemCode);
                    if (objStorageLotInfo != null)
                    {
                        foreach (StorageLotInfo lotInfo in objStorageLotInfo)
                        {
                            temlotQty += lotInfo.Lotqty;
                            if (lotInfo.Lotqty <= 0)    //如果批数量为0不记录该批
                            {
                                continue;
                            }
                            StorageLotInfoList.Add(lotInfo);
                        }
                    }
                }


                if (temlotQty < iOPBOMItemQty)
                {
                    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "-" + MItemName + "]" + "$CS_DeductQty_ERROR");
                }
                #endregion

                #region 数量可以扣减

                foreach (StorageLotInfo lotInfo in StorageLotInfoList)
                {
                    if (iOPBOMItemQty > lotInfo.Lotqty)
                    {
                        iOPBOMItemQty = iOPBOMItemQty - lotInfo.Lotqty;
                        inventoryFacade.DeleteStorageLotInfo(lotInfo);
                        this.UpdateStorageQty(lotInfo, inventoryFacade, lotInfo.Lotqty);
                        lotNoList += ("," + lotInfo.Lotno + ",");

                        #region 记录过账信息
                        LotOnWipItem wipItem    = new LotOnWipItem();
                        MINNO        minnoTemp  = null;
                        object[]     minnoTemps = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, lotInfo.Mcode, minno.MSourceItemCode, lotInfo.Lotno);
                        if (minnoTemps != null)
                        {
                            minnoTemp = (MINNO)minnoTemps[0];
                        }
                        wipItem.DateCode       = minnoTemp.DateCode;
                        wipItem.LOTNO          = minnoTemp.LotNO;
                        wipItem.MItemCode      = minnoTemp.MItemCode;
                        wipItem.VendorCode     = minnoTemp.VendorCode;
                        wipItem.VendorItemCode = minnoTemp.VendorItemCode;
                        wipItem.Version        = minnoTemp.Version;
                        wipItem.MSeq           = seqForDeductQty;
                        wipItem.MCardType      = minno.EAttribute1;

                        wipItem.Eattribute1         = simulation.EAttribute1;
                        wipItem.ItemCode            = simulation.ItemCode;
                        wipItem.ResCode             = simulation.ResCode;
                        wipItem.RouteCode           = simulation.RouteCode;
                        wipItem.LotCode             = simulation.LotCode;
                        wipItem.LotSeq              = simulation.LotSeq;
                        wipItem.SegmentCode         = simulationReport.SegmentCode;
                        wipItem.BeginShiftCode      = simulationReport.BeginShiftCode;
                        wipItem.ShiftTypeCode       = simulationReport.ShiftTypeCode;
                        wipItem.StepSequenceCode    = simulationReport.StepSequenceCode;
                        wipItem.BeginTimePeriodCode = simulationReport.BeginTimePeriodCode;
                        wipItem.MOCode              = simulation.MOCode;
                        wipItem.ModelCode           = simulation.ModelCode;
                        wipItem.OPCode              = simulation.OPCode;
                        wipItem.CollectStatus       = simulation.CollectStatus;
                        wipItem.BeginDate           = simulation.BeginDate;
                        wipItem.BeginTime           = simulation.BeginTime;
                        wipItem.MaintainUser        = simulation.MaintainUser;
                        wipItem.TransStatus         = TransactionStatus.TransactionStatus_YES;
                        wipItem.Qty = lotInfo.Lotqty;

                        wipItem.ActionType = (int)MaterialType.CollectMaterial;
                        wipItem.MOSeq      = simulation.MOSeq;

                        dataCollectFacade.AddLotOnWIPItem(wipItem);

                        LotSimulationReport simulationRpt = dataCollectFacade.GetLastLotSimulationReport(wipItem.LotCode);
                        if (simulationRpt != null)
                        {
                            dataCollectFacade.UpdateLotSimulationReport(simulationRpt);
                        }
                        seqForDeductQty++;
                        #endregion
                    }
                    else
                    {
                        lotInfo.Lotqty = lotInfo.Lotqty - iOPBOMItemQty;
                        inventoryFacade.UpdateStorageLotInfo(lotInfo);
                        this.UpdateStorageQty(lotInfo, inventoryFacade, iOPBOMItemQty);

                        #region 记录过账信息
                        LotOnWipItem wipItem    = new LotOnWipItem();
                        MINNO        minnoTemp  = null;
                        object[]     minnoTemps = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, lotInfo.Mcode, minno.MSourceItemCode, lotInfo.Lotno);
                        if (minnoTemps != null)
                        {
                            minnoTemp = (MINNO)minnoTemps[0];
                        }
                        wipItem.DateCode       = minnoTemp.DateCode;
                        wipItem.LOTNO          = minnoTemp.LotNO;
                        wipItem.MItemCode      = minnoTemp.MItemCode;
                        wipItem.VendorCode     = minnoTemp.VendorCode;
                        wipItem.VendorItemCode = minnoTemp.VendorItemCode;
                        wipItem.Version        = minnoTemp.Version;
                        wipItem.MSeq           = seqForDeductQty;
                        wipItem.MCardType      = minno.EAttribute1;

                        wipItem.Eattribute1         = simulation.EAttribute1;
                        wipItem.ItemCode            = simulation.ItemCode;
                        wipItem.ResCode             = simulation.ResCode;
                        wipItem.RouteCode           = simulation.RouteCode;
                        wipItem.LotCode             = simulation.LotCode;
                        wipItem.LotSeq              = simulation.LotSeq;
                        wipItem.SegmentCode         = simulationReport.SegmentCode;
                        wipItem.BeginShiftCode      = simulationReport.BeginShiftCode;
                        wipItem.ShiftTypeCode       = simulationReport.ShiftTypeCode;
                        wipItem.StepSequenceCode    = simulationReport.StepSequenceCode;
                        wipItem.BeginTimePeriodCode = simulationReport.BeginTimePeriodCode;
                        wipItem.MOCode              = simulation.MOCode;
                        wipItem.ModelCode           = simulation.ModelCode;
                        wipItem.OPCode              = simulation.OPCode;
                        wipItem.CollectStatus       = simulation.CollectStatus;
                        wipItem.BeginDate           = simulation.BeginDate;
                        wipItem.BeginTime           = simulation.BeginTime;
                        wipItem.MaintainUser        = simulation.MaintainUser;
                        wipItem.TransStatus         = TransactionStatus.TransactionStatus_YES;
                        wipItem.Qty = iOPBOMItemQty;

                        wipItem.ActionType = (int)MaterialType.CollectMaterial;
                        wipItem.MOSeq      = simulation.MOSeq;

                        dataCollectFacade.AddLotOnWIPItem(wipItem);

                        LotSimulationReport simulationRpt = dataCollectFacade.GetLastLotSimulationReport(wipItem.LotCode);
                        if (simulationRpt != null)
                        {
                            dataCollectFacade.UpdateLotSimulationReport(simulationRpt);
                        }
                        seqForDeductQty++;
                        #endregion
                        iOPBOMItemQty = 0;
                        lotNoList    += ("," + lotInfo.Lotno + ",");
                        break;
                    }
                }

                #endregion
            }
            //}
            return(returnValue);
        }
Beispiel #15
0
        // Added end

        public override Messages Action(object act)
        {
            Messages           msg     = new Messages();
            ActionOnLineHelper _helper = null;

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args             = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
                args.RunningCard = act.ToString().ToUpper().Trim();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();

            //Laws Lu,2006/06/03	添加	获取已有连接
            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()
                                 as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

            DataCollectFacade dataCollect = new DataCollect.DataCollectFacade(domainProvider);
            TSFacade          tsFacade    = new TSFacade(domainProvider);

            if (msg.IsSuccess())
            {
                MO          moWillGo = (MO)keypartsHT["MOWillGo"];
                ProductInfo product  = (ProductInfo)keypartsHT["ProdcutInfo"];

                if (opBomDetailCount > opBomDetailCollectNum)
                {
                    try
                    {
                        object[] opBomDetailCompare = new object[opBomDetailList.Count];
                        opBomDetailList.CopyTo(opBomDetailCompare);
                        string ItemCode = string.Empty;

                        string parseTypeSetting = "," + ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMParseType + ",";
                        string checkTypeSetting = "," + ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMCheckType + ",";
                        bool   checkStatus      = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).CheckStatus == BenQGuru.eMES.Web.Helper.FormatHelper.TRUE_STRING;

                        string CheckNeedVendor = string.Empty;
                        if (!string.IsNullOrEmpty(((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).NeedVendor))
                        {
                            CheckNeedVendor = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).NeedVendor;
                        }

                        string MItemCode   = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMItemCode;
                        string OBSItemCode = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMSourceItemCode;
                        int    inputLength = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).SerialNoLength;

                        MaterialFacade facade   = new MaterialFacade(domainProvider);
                        MINNO          newMINNO = facade.CreateNewMINNO();
                        newMINNO.MItemCode = MItemCode;

                        Messages parseSuccess    = new Messages();
                        Messages oldParseSuccess = new Messages();

                        parseSuccess.Add(new UserControl.Message(MessageType.Error, "$CS_Error_ParseFailed:"));
                        int num = 0;


                        //勾选了料号比对,必须选择解析方式
                        if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                        {
                            if (parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_BARCODE.ToLower() + ",") < 0 &&
                                parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PREPARE.ToLower() + ",") < 0 &&
                                parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PRODUCT.ToLower() + ",") < 0)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, " $CS_Error_ParseFailed:$CheckCompareItem_Must_CheckOneParse"));
                                goto Label2;
                            }
                        }

                        //Parse from barcode
                        if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_BARCODE.ToLower() + ",") >= 0)
                        {
                            OPBOMDetail opBOMDetailForItemCode = null;
                            if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                            {
                                opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum];
                            }
                            oldParseSuccess.AddMessages(parseSuccess);
                            parseSuccess = dataCollect.ParseFromBarcode(ref newMINNO, data, opBOMDetailForItemCode, inputLength);

                            num += 1;
                        }
                        //Parse from prepare
                        if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PREPARE.ToLower() + ",") >= 0)
                        {
                            Simulation sim = (Simulation)dataCollect.GetSimulation(ID);
                            newMINNO.MOCode = sim.MOCode;
                            OPBOMDetail opBOMDetailForItemCode = null;
                            if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                            {
                                opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum];
                            }
                            oldParseSuccess.AddMessages(parseSuccess);
                            parseSuccess = dataCollect.ParseFromPrepare(ref newMINNO, data, opBOMDetailForItemCode, inputLength);

                            num += 1;
                        }
                        //Parse from product
                        if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PRODUCT.ToLower() + ",") >= 0)
                        {
                            OPBOMDetail opBOMDetailForItemCode = null;
                            if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                            {
                                opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum];
                            }
                            oldParseSuccess.AddMessages(parseSuccess);
                            parseSuccess = dataCollect.ParseFromProduct(ref newMINNO, checkStatus, data, opBOMDetailForItemCode, inputLength);

                            num += 1;
                        }

                        if (!parseSuccess.IsSuccess())
                        {
                            if (num > 0)
                            {
                                oldParseSuccess.AddMessages(parseSuccess);
                                msg.AddMessages(oldParseSuccess);
                                goto Label2;
                            }

                            if (num == 0)
                            {
                                if (inputLength > 0 && data.Trim().Length != inputLength)
                                {
                                    msg.Add(new UserControl.Message(MessageType.Error, "$Error_SNLength_Wrong"));
                                    goto Label2;
                                }
                            }
                        }

                        //检查新上料是否在TS中而不可用
                        if (!tsFacade.RunningCardCanBeClollected(data, CardType.CardType_Part))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + data));
                            goto Label2;
                        }

                        #region Check if key part was used

                        if (((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_KEYPARTS &&
                            KeyPartUsed(domainProvider, data, newMINNO.MItemCode, true))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CS_Error_KeyPartUsed"));
                            goto Label2;
                        }

                        #endregion

                        #region check NeedVendor


                        //如果VendorCode为空,到tblmaterial中获取
                        if (newMINNO.VendorCode == null || newMINNO.VendorCode.Trim().Length <= 0)
                        {
                            ItemFacade itemfacade  = new ItemFacade(domainProvider);
                            object     objMaterial = itemfacade.GetMaterial(newMINNO.MItemCode.Trim(), GlobalVariables.CurrentOrganizations.First().OrganizationID);
                            if (objMaterial != null)
                            {
                                newMINNO.VendorCode = ((BenQGuru.eMES.Domain.MOModel.Material)objMaterial).VendorCode;
                            }
                        }

                        if (CheckNeedVendor == NeedVendor.NeedVendor_Y)
                        {
                            Messages checkNeedVendor = new Messages();
                            checkNeedVendor = dataCollect.CheckNeedVebdor(newMINNO);

                            if (!checkNeedVendor.IsSuccess())
                            {
                                msg.AddMessages(checkNeedVendor);
                                goto Label2;
                            }
                        }

                        #endregion

                        if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_LINKBARCODE.ToLower() + ",") >= 0)
                        {
                            //Link barcode
                            if (string.IsNullOrEmpty(newMINNO.MItemCode))
                            {
                                newMINNO.MItemCode = MItemCode;
                            }

                            newMINNO.MItemPackedNo = data;
                            if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
                            {
                                newMINNO.EAttribute1 = MCardType.MCardType_Keyparts;
                            }
                            else if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT)
                            {
                                newMINNO.EAttribute1 = MCardType.MCardType_INNO;
                                newMINNO.Qty         = ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemQty;
                            }

                            opBomdetailRealCollectList.Add((object)newMINNO);
                        }

                        ++opBomDetailCollectNum;
Label2:

                        if (opBomDetailCount > opBomDetailCollectNum)
                        {
                            if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType != null &&
                                ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT)
                            {
                                msg.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Lot:" + ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMSourceItemCode));

                                ProcessBeforeReturn(this.Status, msg);
                                return(msg);
                            }
                            else
                            {
                                msg.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputKeypart:" + ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMSourceItemCode));

                                ProcessBeforeReturn(this.Status, msg);
                                return(msg);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        msg.Add(new UserControl.Message(MessageType.Error, ex.Message));
                    }
                }


                domainProvider.BeginTransaction();
                try
                {
                    BenQGuru.eMES.BaseSetting.BaseModelFacade dataModel = new BenQGuru.eMES.BaseSetting.BaseModelFacade(domainProvider);
                    Resource resource = (Resource)dataModel.GetResource(args.ResourceCode);

                    _helper = new ActionOnLineHelper(domainProvider);
                    ActionCheckStatus actionCheckStatus = new ActionCheckStatus();
                    actionCheckStatus.ProductInfo          = product;
                    actionCheckStatus.ProductInfo.Resource = resource;
                    ExtendSimulation lastSimulation = actionCheckStatus.ProductInfo.LastSimulation;

                    BenQGuru.eMES.Material.WarehouseFacade wfacade = null;
                    if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                    {
                        wfacade = new WarehouseFacade(domainProvider);
                    }

                    IDCTClient client = act as IDCTClient;

                    //检查新上料是否在TS中而不可用
                    if (opBomdetailRealCollectList != null)
                    {
                        foreach (MINNO minno in opBomdetailRealCollectList)
                        {
                            if (!tsFacade.RunningCardCanBeClollected(minno.MItemPackedNo, CardType.CardType_Part))
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + minno.MItemPackedNo));
                                break;
                            }
                        }
                    }

                    #region Check if key part was used

                    if (opBomdetailRealCollectList != null)
                    {
                        foreach (MINNO minno in opBomdetailRealCollectList)
                        {
                            if (minno.EAttribute1 == MCardType.MCardType_Keyparts)
                            {
                                if (KeyPartUsed(domainProvider, minno.MItemPackedNo, minno.MItemCode, false))
                                {
                                    msg.Add(new UserControl.Message(MessageType.Error, "$CS_Error_KeyPartUsed"));
                                    break;
                                }
                            }
                        }
                    }

                    #endregion

                    if (msg.IsSuccess())
                    {
                        object[] objOpBomdetailRealCollect = new object[opBomdetailRealCollectList.Count];
                        opBomdetailRealCollectList.CopyTo(objOpBomdetailRealCollect);

                        string strRCard = product.NowSimulation.RunningCard;



                        msg.AddMessages(_helper.ActionWithTransaction(
                                            new CINNOActionEventArgs(
                                                ActionType.DataCollectAction_CollectINNO, strRCard,
                                                client.LoginedUser,
                                                client.ResourceCode,
                                                product,
                                                string.Empty,
                                                wfacade), actionCheckStatus, objOpBomdetailRealCollect));
                    }


                    #region 物料过账

                    if (msg.IsSuccess())
                    {
                        BaseModelFacade bMfacade = new BaseModelFacade(domainProvider);
                        object          objOP    = bMfacade.GetOperationByResource(client.ResourceCode);
                        string          strRCard = product.NowSimulation.RunningCard;

                        object[] objOpBomdetailRealCollect = new object[opBomdetailRealCollectList.Count];
                        opBomdetailRealCollectList.CopyTo(objOpBomdetailRealCollect);

                        if (opBomdetailRealCollectList != null && opBomdetailRealCollectList.Count > 0)
                        {
                            Messages messagesNew = new Messages();
                            string   ItemCode    = string.Empty;

                            DataCollectFacade dataCollectFacade = new DataCollectFacade(domainProvider);
                            object            objectSimulation  = dataCollectFacade.GetSimulation(strRCard);
                            if (objectSimulation != null)
                            {
                                ItemCode = ((Simulation)objectSimulation).ItemCode;
                            }

                            foreach (MINNO minno in opBomdetailRealCollectList)
                            {
                                messagesNew.AddMessages(_helper.ActionWithTransaction(new TryEventArgs(
                                                                                          ActionType.DataCollectAction_TryNew, client.LoginedUser, ((Operation2Resource)objOP).OPCode, client.ResourceCode,
                                                                                          ItemCode, strRCard, minno.MItemCode, minno.MItemPackedNo, string.Empty, true, true)));
                            }
                            msg.AddMessages(messagesNew);
                        }
                    }

                    #endregion

                    if (msg.IsSuccess())
                    {
                        if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                        {
                            if (wfacade != null)
                            {
                                wfacade.ExecCacheSQL();
                            }
                        }

                        #region 增加良品采集
                        {
                            Resource Resource = (Resource)dataModel.GetResource(client.ResourceCode);

                            Messages messages1 = new Messages();
                            if (actionCheckStatus.ProductInfo == null)
                            {
                                messages1 = _helper.GetIDInfo(ID);
                                actionCheckStatus.ProductInfo          = (ProductInfo)messages1.GetData().Values[0];
                                actionCheckStatus.ProductInfo.Resource = Resource;
                                lastSimulation = actionCheckStatus.ProductInfo.LastSimulation;
                                msg.AddMessages(messages1);
                            }
                            else        //将上一个Action的NowSimulation设置为本Action的LastSimulation
                            {
                                if (actionCheckStatus.ActionList.Count > 0)
                                {
                                    actionCheckStatus.ProductInfo = new ProductInfo();
                                    actionCheckStatus.ProductInfo.NowSimulation = new Simulation();
                                    actionCheckStatus.ProductInfo.Resource      = Resource;
                                    //actionCheckStatus.ProductInfo.LastSimulation =
                                    //    new ExtendSimulation(((ActionEventArgs)actionCheckStatus.ActionList[actionCheckStatus.ActionList.Count - 1]).ProductInfo.NowSimulation);
                                    actionCheckStatus.ProductInfo.LastSimulation =
                                        new ExtendSimulation((Simulation)(new DataCollectFacade(domainProvider)).GetLastSimulationOrderByDateAndTime(ID));
                                }
                            }

                            product = actionCheckStatus.ProductInfo;

                            // Changed end
                            if (msg.IsSuccess())
                            {
                                messages1.AddMessages(_helper.ActionWithTransaction(new ActionEventArgs(ActionType.DataCollectAction_GOOD, ID,
                                                                                                        client.LoginedUser, client.ResourceCode,
                                                                                                        product), actionCheckStatus));
                            }
                        }
                        #endregion
                    }

                    if (msg.IsSuccess())
                    {
                        domainProvider.CommitTransaction();
                        msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_CollectSuccess")));
                    }
                    else
                    {
                        domainProvider.RollbackTransaction();
                    }
                }
                catch (Exception ex)
                {
                    domainProvider.RollbackTransaction();

                    msg.Add(new UserControl.Message(ex));
                }
                finally
                {
                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                }
            }

            if (msg.IsSuccess())
            {
                base.Action(act);

                this.ObjectState = null;
                this.keypartsHT  = null;
                this.opBomDetailList.Clear();
                this.opBomDetailCount      = 0;
                this.opBomDetailCollectNum = 0;
                this.opBomdetailRealCollectList.Clear();
                ID = string.Empty;
            }

            ProcessBeforeReturn(this.Status, msg);
            return(msg);
        }
Beispiel #16
0
        private Messages DropLoadedParts(string rcard)
        {
            Messages msg = new Messages();

            ActionOnLineHelper onLine            = new ActionOnLineHelper(DataProvider);
            MaterialFacade     materialFacade    = new MaterialFacade(this.DataProvider);
            ItemFacade         itemFacade        = new ItemFacade(this.DataProvider);
            DataCollectFacade  dataCollectFacade = new DataCollectFacade(this.DataProvider);
            TSFacade           tsFacade          = new TSFacade(this.DataProvider);

            string sourceRCard = dataCollectFacade.GetSourceCard(rcard.Trim().ToUpper(), string.Empty);

            ProductInfo product = GetProduct(sourceRCard);

            if (product == null || product.LastSimulation == null)
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                return(msg);
            }

            // Marked By HI1/Venus.Feng on 20081013 for Hisense Version : GOOD can do drop

            /*
             * if (product.LastSimulation.ProductStatus != ProductStatus.NG)
             * {
             *  msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_NG"));
             *  return msg;
             * }
             */
            // End Marked

            msg.Add(new UserControl.Message(rcard));

            //获取所有需要拆解或者替换的Parts
            ArrayList partsToUnload = new ArrayList();

            for (int i = 0; i < this.ultraGridLoadedPart.Rows.Count; i++)
            {
                if (ultraGridLoadedPart.Rows[i].Cells[0].Text.ToLower() == "true")
                {
                    InnoObject innoObject = new InnoObject();

                    innoObject.LineIndex  = i;
                    innoObject.MCard      = ultraGridLoadedPart.Rows[i].Cells["PackedNo"].Text;
                    innoObject.MCardType  = ultraGridLoadedPart.Rows[i].Cells["MCardType"].Text;
                    innoObject.ItemIndex  = partsToUnload.Count + 1;
                    innoObject.MItemCode  = ultraGridLoadedPart.Rows[i].Cells["ItemCode"].Text;
                    innoObject.MOCode     = ultraGridLoadedPart.Rows[i].Cells["MOCode"].Text;
                    innoObject.Qty        = 1;
                    innoObject.NewBarcode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(ultraGridLoadedPart.Rows[i].Cells["NewBarcode"].Text.Trim()));

                    partsToUnload.Add(innoObject);
                }
            }

            //对于需要替换的Parts,需要做类似上料中的解析和检查
            for (int i = 0; i < partsToUnload.Count; i++)
            {
                InnoObject innoObject = (InnoObject)partsToUnload[i];

                if (innoObject.NewBarcode.Trim().Length > 0)
                {
                    //抓取物料的设定
                    Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(innoObject.MItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID);
                    if (material == null)
                    {
                        msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_NotFound"));
                        return(msg);
                    }

                    string barcode = innoObject.NewBarcode.Trim();

                    //模拟一个OPBOMDetail
                    OPBOMDetail detailTemp = new OPBOMDetail();
                    detailTemp.OPBOMItemControlType = material.MaterialControlType;
                    detailTemp.OPBOMParseType       = material.MaterialParseType;
                    detailTemp.OPBOMCheckType       = material.MaterialCheckType;
                    detailTemp.CheckStatus          = material.CheckStatus;
                    detailTemp.SerialNoLength       = material.SerialNoLength;
                    detailTemp.NeedVendor           = material.NeedVendor;
                    detailTemp.OPBOMSourceItemCode  = innoObject.MItemCode;
                    detailTemp.OPBOMItemCode        = innoObject.MItemCode;
                    detailTemp.OPBOMItemQty         = 1;


                    MINNO newMINNO = new MINNO();
                    newMINNO.MOCode    = innoObject.MOCode.Trim();
                    newMINNO.MItemCode = material.MaterialCode.Trim();

                    Messages collectMessage = dataCollectFacade.GetMINNOByBarcode(detailTemp, barcode, newMINNO.MOCode, null, false, false, out newMINNO);

                    if (collectMessage.IsSuccess())
                    {
                        innoObject.NewLotNo          = newMINNO.LotNO;
                        innoObject.NewPCBA           = newMINNO.PCBA;
                        innoObject.NewBIOS           = newMINNO.BIOS;
                        innoObject.NewVersion        = newMINNO.Version;
                        innoObject.NewVendorItemCode = newMINNO.VendorItemCode;
                        innoObject.NewVendorCode     = newMINNO.VendorCode;
                        innoObject.NewDateCode       = newMINNO.DateCode;
                    }
                    else
                    {
                        msg.AddMessages(collectMessage);
                        return(msg);
                    }
                }
            }

            try
            {
                this.DataProvider.BeginTransaction();

                //更新试流单
                //下料中处理tbltry,tbltry2rcard
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];

                    TryEventArgs tryEventArgs = new TryEventArgs(
                        ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode,
                        product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.MCard, string.Empty, false, false);

                    msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs));
                    if (!msg.IsSuccess())
                    {
                        DataProvider.RollbackTransaction();
                        return(msg);
                    }
                }

                //更新试流单
                //上料中处理tbltry,tbltry2rcard
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];
                    if (innoObject.NewBarcode.Trim().Length > 0)
                    {
                        TryEventArgs tryEventArgs = new TryEventArgs(
                            ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode,
                            product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.NewBarcode, string.Empty, true, true);

                        msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs));
                        if (!msg.IsSuccess())
                        {
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }
                    }
                }

                //检查新上料是否在TS中而不可用
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];
                    if (innoObject.NewBarcode.Trim().Length > 0)
                    {
                        if (!tsFacade.RunningCardCanBeClollected(innoObject.NewBarcode.Trim(), CardType.CardType_Part))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + innoObject.NewBarcode.Trim()));
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }
                    }
                }

                //拆解或者替换处理tblonwipitem,tblsimulationreport
                DropMaterialEventArgs dropMaterialEventArgs = new DropMaterialEventArgs(ActionType.DataCollectAction_DropMaterial, product.LastSimulation.RunningCard,
                                                                                        ApplicationService.Current().UserCode, ApplicationService.Current().ResourceCode,
                                                                                        product);
                dropMaterialEventArgs.OnwipItems = partsToUnload.ToArray();

                msg.AddMessages(onLine.ActionWithTransaction(dropMaterialEventArgs));
                if (!msg.IsSuccess())
                {
                    DataProvider.RollbackTransaction();
                    return(msg);
                }

                //针对拆解下的物料,做TS相关的动作
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];

                    if (_TSList[innoObject.LineIndex] != null)
                    {
                        if (_TSErrorCodeList[innoObject.LineIndex] == null)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CS_Please_Select_ErrorCode"));
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }

                        Domain.TS.TS oldTS = (Domain.TS.TS)tsFacade.QueryLastTSByRunningCard(innoObject.MCard);
                        if (oldTS != null)
                        {
                            if (oldTS.TSStatus == TSStatus.TSStatus_New ||
                                oldTS.TSStatus == TSStatus.TSStatus_Confirm ||
                                oldTS.TSStatus == TSStatus.TSStatus_TS)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTS"));
                                DataProvider.RollbackTransaction();
                                return(msg);
                            }
                            else if (oldTS.TSStatus != TSStatus.TSStatus_Reflow &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Split &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Complete &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Scrap)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_WrongTSStatus"));
                                DataProvider.RollbackTransaction();
                                return(msg);
                            }
                        }

                        Domain.TS.TS newTS = (Domain.TS.TS)_TSList[innoObject.LineIndex];
                        tsFacade.AddTS(newTS);
                        foreach (TSErrorCode tsErrorCode in (TSErrorCode[])_TSErrorCodeList[innoObject.LineIndex])
                        {
                            tsErrorCode.RunningCard         = newTS.RunningCard;
                            tsErrorCode.RunningCardSequence = newTS.RunningCardSequence;
                            tsErrorCode.ItemCode            = newTS.ItemCode;
                            tsErrorCode.ModelCode           = newTS.ModelCode;
                            tsErrorCode.MOCode       = newTS.MOCode;
                            tsErrorCode.MOSeq        = newTS.MOSeq;
                            tsErrorCode.MaintainUser = newTS.MaintainUser;
                            tsErrorCode.MaintainDate = newTS.MaintainDate;
                            tsErrorCode.MaintainTime = newTS.MaintainTime;

                            tsFacade.AddTSErrorCode(tsErrorCode);
                        }
                    }
                }

                if (!msg.IsSuccess())
                {
                    DataProvider.RollbackTransaction();
                    return(msg);
                }

                if (msg.IsSuccess())
                {
                    DataProvider.CommitTransaction();
                }
                else
                {
                    DataProvider.RollbackTransaction();
                }
            }
            catch (Exception e)
            {
                this.DataProvider.RollbackTransaction();
                msg.Add(new UserControl.Message(e));
            }

            return(msg);
        }
Beispiel #17
0
        private Messages LoadData(string rcard)
        {
            Messages msg = new Messages();

            _DataTableLoadedPart.Clear();

            MOFacade       moFacade       = new MOFacade(this.DataProvider);
            OPBOMFacade    opBOMFacade    = new OPBOMFacade(this.DataProvider);
            MaterialFacade materialFacade = new MaterialFacade(this.DataProvider);
            ItemFacade     itemFacade     = new ItemFacade(this.DataProvider);

            //根据当前的序列号获取产品原始的序列号
            DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
            string            sourceRCard       = dataCollectFacade.GetSourceCard(rcard, string.Empty);

            //Get Product Info
            ProductInfo product = GetProduct(sourceRCard);

            if (product == null || product.LastSimulation == null)
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                return(msg);
            }

            // Marked By HI1/Venus.Feng on 20081013 for Hisense Version : GOOD can do drop

            /*
             * if (product.LastSimulation.ProductStatus != ProductStatus.NG)
             * {
             *  msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_NG"));
             *  return msg;
             * }
             */
            // End Marked

            //Get loaded parts
            OnWIPItem[] onWIPItems = materialFacade.QueryLoadedPartByRCard(product.LastSimulation.RunningCard, string.Empty);

            if (onWIPItems == null)
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_CINNO"));
                return(msg);
            }

            try
            {
                if (onWIPItems != null)
                {
                    for (int i = 0; i < onWIPItems.Length; i++)
                    {
                        MO  mo    = (MO)moFacade.GetMO(onWIPItems[i].MOCode);
                        int orgID = GlobalVariables.CurrentOrganizations.First().OrganizationID;
                        if (mo != null)
                        {
                            orgID = mo.OrganizationID;
                        }

                        Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(onWIPItems[i].MItemCode, orgID);
                        //changed by hiro 08/11/04
                        if (material != null)
                        {
                            _DataTableLoadedPart.Rows.Add(new object[] {
                                false,
                                false,
                                string.Empty,
                                i + 1,
                                onWIPItems[i].MItemCode,
                                onWIPItems[i].MOCode,
                                onWIPItems[i].MCARD,
                                material.MaterialDescription == null ? "" : material.MaterialDescription,
                                string.Empty,
                                onWIPItems[i].MCardType
                            });
                        }
                        //end by hiro
                    }
                }
            }
            catch (Exception E)
            {
                msg.Add(new UserControl.Message(E));
            }

            return(msg);
        }
Beispiel #18
0
        private void CheckWorkPlan()
        {
            int              count            = this._ImportDataTable.Rows.Count;
            Hashtable        checkedRow       = new Hashtable();
            ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this._DataProvider);
            MaterialFacade   materialFacade   = new MaterialFacade(this._DataProvider);
            DBDateTime       dbDateTime       = FormatHelper.GetNowDBDateTime(this._DataProvider);

            for (int i = count - 1; i >= 0; i--)
            {
                DataRow    row           = this._ImportDataTable.Rows[i];
                GridRecord gridRow       = this._ImportGridRow[i] as GridRecord;
                string     moCode        = row["MOCODE"].ToString();
                string     bigSSCode     = row["BIGSSCODE"].ToString();
                string     planDate      = row["PLANDATE"].ToString();
                string     planSeq       = row["PLANSEQ"].ToString();
                string     moSeq         = row["MOSEQ"].ToString();
                string     planStartTime = (Convert.ToDateTime(row["PLANSTARTTIME"])).ToString("HH:mm:ss");
                string     planQty       = row["PLANQTY"].ToString();


                if (string.IsNullOrEmpty(moCode))
                {
                    if (!checkedRow.ContainsKey(moCode))
                    {
                        checkedRow.Add(moCode, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = _LanguageComponent1.GetString("$CS_MO_NotExit");
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);
                    continue;
                }

                if (string.IsNullOrEmpty(bigSSCode))
                {
                    if (!checkedRow.ContainsKey(bigSSCode))
                    {
                        checkedRow.Add(bigSSCode, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = _LanguageComponent1.GetString("$BIGSSCODE_IS_NOT_EXIT");
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                if (string.IsNullOrEmpty(planDate))
                {
                    if (!checkedRow.ContainsKey(planDate))
                    {
                        checkedRow.Add(planDate, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "计划日期不能为空";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                try
                {
                    DateTime planDateTime = Convert.ToDateTime(FormatHelper.ToDateString(int.Parse(planDate), "-"));
                }
                catch
                {
                    if (!checkedRow.ContainsKey(planDate))
                    {
                        checkedRow.Add(planDate, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "计划日期错误";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                if (string.IsNullOrEmpty(planSeq))
                {
                    if (!checkedRow.ContainsKey(planSeq))
                    {
                        checkedRow.Add(planSeq, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "生产顺序不能为空";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                if (string.IsNullOrEmpty(moSeq))
                {
                    if (!checkedRow.ContainsKey(moSeq))
                    {
                        checkedRow.Add(moSeq, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "工单项次不能为空";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                if (string.IsNullOrEmpty(planStartTime))
                {
                    if (!checkedRow.ContainsKey(planStartTime))
                    {
                        checkedRow.Add(planStartTime, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "计划开始时间不能为空";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }


                try
                {
                    int numplanSeq = int.Parse(planSeq);
                    if (numplanSeq < 0)
                    {
                        if (!checkedRow.ContainsKey(planSeq))
                        {
                            checkedRow.Add(planSeq, false);
                        }

                        gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                        gridRow.Items.FindItemByKey("ImportResult").Text             = "生产顺序不应小于0";
                        gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                        this._ImportDataTable.Rows.Remove(row);
                        this._ImportGridRow.Remove(gridRow);

                        continue;
                    }
                }
                catch
                {
                    if (!checkedRow.ContainsKey(planSeq))
                    {
                        checkedRow.Add(planSeq, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "生产顺序格式错误";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                try
                {
                    int nummoSeq = int.Parse(moSeq);
                    if (nummoSeq < 0)
                    {
                        if (!checkedRow.ContainsKey(moSeq))
                        {
                            checkedRow.Add(moSeq, false);
                        }

                        gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                        gridRow.Items.FindItemByKey("ImportResult").Text             = "工单项次不应小于0";
                        gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                        this._ImportDataTable.Rows.Remove(row);
                        this._ImportGridRow.Remove(gridRow);

                        continue;
                    }
                }
                catch
                {
                    if (!checkedRow.ContainsKey(moSeq))
                    {
                        checkedRow.Add(moSeq, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "工单项次格式错误";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                try
                {
                    decimal numplanQty = decimal.Parse(planQty);
                    if (numplanQty < 0)
                    {
                        if (!checkedRow.ContainsKey(planQty))
                        {
                            checkedRow.Add(planQty, false);
                        }

                        gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                        gridRow.Items.FindItemByKey("ImportResult").Text             = "计划数量不应小于0";
                        gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                        this._ImportDataTable.Rows.Remove(row);
                        this._ImportGridRow.Remove(gridRow);

                        continue;
                    }
                }
                catch
                {
                    if (!checkedRow.ContainsKey(planQty))
                    {
                        checkedRow.Add(planQty, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "计划数量格式错误";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);
                    continue;
                }

                //planDate
                try
                {
                    int numplanDate = FormatHelper.TODateInt(planDate.Insert(4, "-").Insert(7, "-"));
                }
                catch
                {
                    if (!checkedRow.ContainsKey(planDate))
                    {
                        checkedRow.Add(planDate, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "计划日期格式错误";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);
                    continue;
                }

                //planStartTime
                try
                {
                    int numplanStartTime = FormatHelper.TOTimeInt(planStartTime.ToString());
                }
                catch
                {
                    if (!checkedRow.ContainsKey(planStartTime))
                    {
                        checkedRow.Add(planStartTime, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "计划开始时间格式错误";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);
                    continue;
                }

                int shiftDay = shiftModelFacade.GetShiftDayByBigSSCode(bigSSCode, dbDateTime.DateTime);

                object[] objs = _DataProvider.CustomQuery(typeof(BenQGuru.eMES.Domain.MOModel.Model),
                                                          new SQLParamCondition(@"select mocode from tblmo where 1=1 " + GlobalVariables.CurrentOrganizations.GetSQLCondition() + @" and mocode=$MOCODE", new SQLParameter[] { new SQLParameter("$MOCODE", typeof(string), moCode.ToUpper()) }));

                if (objs == null)
                {
                    if (!checkedRow.ContainsKey(moCode))
                    {
                        checkedRow.Add(moCode, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = _LanguageComponent1.GetString("$CS_MO_NotExit");
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                object[] objss = _DataProvider.CustomQuery(typeof(BenQGuru.eMES.Domain.BaseSetting.StepSequence),
                                                           new SQLParamCondition(@"select distinct bigsscode from tblss where 1=1 " + GlobalVariables.CurrentOrganizations.GetSQLCondition() + @" and bigsscode=$BIGSSCODE",
                                                                                 new SQLParameter[] { new SQLParameter("$BIGSSCODE", typeof(string), bigSSCode.ToUpper()) }));

                if (objss == null)
                {
                    if (!checkedRow.ContainsKey(bigSSCode))
                    {
                        checkedRow.Add(bigSSCode, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = _LanguageComponent1.GetString("$BIGSSCODE_IS_NOT_EXIT");
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                if (_MaterialFacade == null)
                {
                    _MaterialFacade = new MaterialFacade(_DataProvider);
                }

                object objWorkPlanFromDB = _MaterialFacade.GetWorkPlan(bigSSCode, int.Parse(planDate), moCode, decimal.Parse(moSeq));

                if (objWorkPlanFromDB != null)
                {
                    //修改的投入数量必须大于等于实际数量
                    if (decimal.Parse(planQty) < ((WorkPlan)objWorkPlanFromDB).ActQty)
                    {
                        if (!checkedRow.ContainsKey(planQty))
                        {
                            checkedRow.Add(planQty, false);
                        }

                        gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                        gridRow.Items.FindItemByKey("ImportResult").Text             = _LanguageComponent1.GetString("$planqty_isnotequ_actqty");
                        gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                        this._ImportDataTable.Rows.Remove(row);
                        this._ImportGridRow.Remove(gridRow);

                        continue;
                    }

                    if ((((WorkPlan)objWorkPlanFromDB).ActionStatus == WorkPlanActionStatus.WorkPlanActionStatus_Close))
                    //执行状态为待投产或生产中才update
                    {
                        if (!checkedRow.ContainsKey(planDate))
                        {
                            checkedRow.Add(planDate, false);
                        }

                        gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                        gridRow.Items.FindItemByKey("ImportResult").Text             = _LanguageComponent1.GetString("$status_error");
                        gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                        this._ImportDataTable.Rows.Remove(row);
                        this._ImportGridRow.Remove(gridRow);

                        continue;
                    }
                }

                if (int.Parse(planDate) < shiftDay)
                {
                    if (!checkedRow.ContainsKey(planDate))
                    {
                        checkedRow.Add(planDate, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "计划日期不能早于当前日期";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                WorkPlan GetworkPlanByKeys    = (WorkPlan)materialFacade.GetWorkPlan(bigSSCode, int.Parse(planDate), moCode, decimal.Parse(moSeq));
                WorkPlan GetworkPlanByUniques = (WorkPlan)materialFacade.GetWorkPlan(bigSSCode, int.Parse(planDate), int.Parse(planSeq));

                if (GetworkPlanByKeys == null && GetworkPlanByUniques != null)
                {
                    if (!checkedRow.ContainsKey(moCode))
                    {
                        checkedRow.Add(moCode, false);
                    }

                    gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                    gridRow.Items.FindItemByKey("ImportResult").Text             = "请检查日期+线别+投产顺序的唯一性";
                    gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                    this._ImportDataTable.Rows.Remove(row);
                    this._ImportGridRow.Remove(gridRow);

                    continue;
                }

                if (GetworkPlanByKeys != null && GetworkPlanByUniques != null)
                {
                    if (GetworkPlanByKeys.BigSSCode != GetworkPlanByUniques.BigSSCode ||
                        GetworkPlanByKeys.PlanDate != GetworkPlanByUniques.PlanDate ||
                        GetworkPlanByKeys.MoCode != GetworkPlanByUniques.MoCode ||
                        GetworkPlanByKeys.MoSeq != GetworkPlanByUniques.MoSeq)
                    {
                        if (!checkedRow.ContainsKey(moCode))
                        {
                            checkedRow.Add(moCode, false);
                        }

                        gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = false;
                        gridRow.Items.FindItemByKey("ImportResult").Text             = "请检查日期+线别+投产顺序的唯一性";
                        gridRow.Items.FindItemByKey("ImportResult").CssClass         = "MsgYellow";
                        this._ImportDataTable.Rows.Remove(row);
                        this._ImportGridRow.Remove(gridRow);

                        continue;
                    }
                }

                if (!checkedRow.ContainsKey(moCode))
                {
                    checkedRow.Add(moCode, false);
                }

                gridRow.Items.FindItemByKey(gridHelper.CheckColumnKey).Value = true;
            }
        }
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            //添加
            //字段判断
            // 不为空判断
            if (JudgeIsNull(this.txtProductCode.Text, "原料编码"))
            {
                return;
            }
            if (JudgeIsNull(this.txtProductName.Text, "原料名称"))
            {
                return;
            }
            if (IsOut(this.txtProductName.Text, 40))
            {
                Popup("原料名称超长,只能是20个汉字或40个英文数字!");
                return;
            }
            if (JudgeIsNull(this.txtPrice.Text, "计量价格"))
            {
                return;
            }
            if (JudgeIsNull(this.txtConversion.Text, "换算关系"))
            {
                return;
            }
            if (JudgeIsNull(this.txtUnit.Text, "出仓单位"))
            {
                return;
            }
            if (JudgeIsNull(this.txtStandardUnit.Text, "规格单位"))
            {
                return;
            }
            if (JudgeIsNull(this.txtStandardCount.Text, "规格数量"))
            {
                return;
            }
            if (!JudgeIsNum(this.txtPrice.Text, "计量价格"))
            {
                return;
            }
            if (!JudgeIsNum(this.txtConversion.Text, "换算关系"))
            {
                return;
            }
            if (!JudgeIsNum(this.txtStandardCount.Text, "规格数量"))
            {
                return;
            }
            if (!JudgeIsCode(this.ddlProductType.SelectedValue, this.ddlProductClass.SelectedValue, this.txtProductCode.Text))
            {
                Popup("编码错误");
                return;
            }

            Material mat = new Material();

            mat.cnnConversion    = decimal.Parse(txtConversion.Text);
            mat.cnnPrice         = decimal.Parse(txtPrice.Text);
            mat.cnnStatdardCount = decimal.Parse(txtStandardCount.Text);
            mat.cnvcLeastUnit    = ddlLeastUnit.SelectedValue;
            mat.cnvcMaterialCode = txtProductCode.Text;
            mat.cnvcMaterialName = txtProductName.Text;
            mat.cnvcProductType  = ddlProductType.SelectedValue;
            mat.cnvcStandardUnit = txtStandardUnit.Text;
            mat.cnvcUnit         = txtUnit.Text;
            mat.cnvcProductClass = ddlProductClass.SelectedValue;

            //tbBusiLog
            string    strSql     = "select * from tbMaterial where cnvcMaterialCode='" + mat.cnvcMaterialCode + "'";
            DataTable dtMaterial = Helper.Query(strSql);

            if (dtMaterial.Rows.Count > 0)
            {
                Popup("相同编码原料材料已存在");
                return;
            }

            OperLog operLog = new OperLog();

            operLog.cnvcOperID   = oper.strLoginID;
            operLog.cnvcDeptID   = oper.strDeptID;
            operLog.cnvcOperType = "添加原料材料";

            MaterialFacade mf = new MaterialFacade();

            mf.AddMaterial(mat, operLog);
            this.Popup("原料材料添加成功!");
            btnCancel_Click(null, null);
        }
Beispiel #20
0
        private void txtRelationQtyEdit__TxtboxKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                #region facade
                if (mofacade == null)
                {
                    mofacade = new MOFacade(this.DataProvider);
                }
                if (materialFacade == null)
                {
                    materialFacade = new MaterialFacade(this.DataProvider);
                }
                if (collectfacade == null)
                {
                    collectfacade = new DataCollectFacade(this.DataProvider);
                }
                if (morcardfacade == null)
                {
                    morcardfacade = new MORunningCardFacade(this.DataProvider);
                }
                if (smtfacade == null)
                {
                    smtfacade = new SMTFacade(this.DataProvider);
                }
                if (itemfacade == null)
                {
                    itemfacade = new ItemFacade(this.DataProvider);
                }
                #endregion

                if (this.txtMoCodeEdit.Enabled == false && this.txtRCardEdit.Enabled == false)
                {
                    btnSave_Click(sender, e);
                    return;
                }

                #region   null
                if (this.txtMoCodeEdit.Value == string.Empty)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$MO_Cannot_Null"));
                    this.txtMoCodeEdit.TextFocus(false, true);
                    return;
                }
                if (string.IsNullOrEmpty(txtRCardEdit.Value))
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$RMARcard_Cannot_Null"));
                    this.txtRCardEdit.TextFocus(false, true);
                    return;
                }
                if (this.txtRelationQtyEdit.Value.Trim() == string.Empty)
                {
                    //数量不能为空 $Error_Qty_Cannot_Empty
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Qty_Cannot_Empty"));
                    this.txtRelationQtyEdit.TextFocus(false, true);
                    return;
                }
                #endregion

                try
                {
                    #region mocode
                    if (materialFacade.GetMOCode(this.txtMoCodeEdit.Value) == false)
                    {
                        //该工单不存在
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Rework_MO_Not_Exist"));
                        this.txtMoCodeEdit.TextFocus(false, true);
                        return;
                    }
                    object objMO = mofacade.GetMO(this.txtMoCodeEdit.Value.Trim().ToUpper());
                    if (objMO == null || ((MO)objMO).MOStatus.Trim().ToUpper() == "MOSTATUS_CLOSE")
                    {
                        //该工单已关单,不能维护打X板!
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_MO_Close_Not_SmtRelQty"));
                        this.txtMoCodeEdit.TextFocus(false, true);
                        return;
                    }
                    #endregion

                    #region rcard
                    object lastsimulationReport = materialFacade.GetLastSimulationReport(this.txtRCardEdit.Value.Trim().ToUpper());
                    if (lastsimulationReport != null)
                    {
                        if (((SimulationReport)lastsimulationReport).IsComplete.Trim() == "0")
                        {
                            // 该序列号在生产中,不允许维护打X板!
                            ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Rcard_inProduction"));
                            this.txtRCardEdit.TextFocus(false, true);
                            return;
                        }
                        object simulationReport = collectfacade.GetSimulationReport(this.txtMoCodeEdit.Value.Trim().ToUpper(), this.txtRCardEdit.Value.Trim().ToUpper());
                        if (simulationReport != null)
                        {
                            // 该序列号在生产中或者已经完工,不允许维护打X板!
                            ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Rcard_inProductionOrClose"));
                            this.txtRCardEdit.TextFocus(false, true);
                            return;
                        }
                        else
                        {
                            //修改  rcard不在工单范围内
                            #region
                            object item2sncheck = itemfacade.GetItem2SNCheck(((MO)objMO).ItemCode.Trim().ToUpper(), ItemCheckType.ItemCheckType_SERIAL);
                            if (item2sncheck != null)
                            {
                                string checkContent = ((Item2SNCheck)item2sncheck).SNContentCheck.Trim().ToUpper();
                                int    checkLength  = ((Item2SNCheck)item2sncheck).SNLength;
                                string checkPrefix  = ((Item2SNCheck)item2sncheck).SNPrefix.Trim().ToUpper();

                                string rcardCheck = this.txtRCardEdit.Value.Trim().ToUpper();
                                if (!string.IsNullOrEmpty(checkPrefix))
                                {
                                    if (rcardCheck.IndexOf(checkPrefix) != 0)
                                    {
                                        // 该序列号与工单要求的序列号前缀不一样
                                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardPrefix_ERROR  $CS_RunningCardPrefix: " + checkPrefix));
                                        this.txtRCardEdit.TextFocus(false, true);
                                        return;
                                    }
                                }
                                if (checkLength != null && checkLength > 0)
                                {
                                    if (rcardCheck.Length != checkLength)
                                    {
                                        // 该序列号与工单要求的序列号长度不一样
                                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardLength_ERROR  $CS_RunningCardLength: " + checkLength));
                                        this.txtRCardEdit.TextFocus(false, true);
                                        return;
                                    }
                                }
                                if (checkContent != null && checkContent == "Y")
                                {
                                    string pattern = @"^([A-Za-z0-9]+[ ]*)*[A-Za-z0-9]+$";
                                    Regex  rex     = new Regex(pattern, RegexOptions.IgnoreCase);
                                    Match  match   = rex.Match(rcardCheck);
                                    // 序列号被限制为字符 空格 数字
                                    if (!match.Success)
                                    {
                                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SNContent_CheckWrong $CS_Param_RunSeq:" + this.txtRCardEdit.Value.Trim()));
                                        this.txtRCardEdit.TextFocus(false, true);
                                        return;
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        //修改      rcard不在工单范围内
                        #region
                        object item2sncheck = itemfacade.GetItem2SNCheck(((MO)objMO).ItemCode.Trim().ToUpper(), ItemCheckType.ItemCheckType_SERIAL);
                        if (item2sncheck != null)
                        {
                            string checkContent = ((Item2SNCheck)item2sncheck).SNContentCheck.Trim().ToUpper();
                            int    checkLength  = ((Item2SNCheck)item2sncheck).SNLength;
                            string checkPrefix  = ((Item2SNCheck)item2sncheck).SNPrefix.Trim().ToUpper();

                            string rcardCheck = this.txtRCardEdit.Value.Trim().ToUpper();
                            if (!string.IsNullOrEmpty(checkPrefix))
                            {
                                if (rcardCheck.IndexOf(checkPrefix) != 0)
                                {
                                    // 该序列号与工单要求的序列号前缀不一样
                                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardPrefix_ERROR  $CS_RunningCardPrefix: " + checkPrefix));
                                    this.txtRCardEdit.TextFocus(false, true);
                                    return;
                                }
                            }
                            if (checkLength != null && checkLength > 0)
                            {
                                if (rcardCheck.Length != checkLength)
                                {
                                    // 该序列号与工单要求的序列号长度不一样
                                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardLength_ERROR  $CS_RunningCardLength: " + checkLength));
                                    this.txtRCardEdit.TextFocus(false, true);
                                    return;
                                }
                            }
                            if (checkContent != null && checkContent == "Y")
                            {
                                string pattern = @"^([A-Za-z0-9]+[ ]*)*[A-Za-z0-9]+$";
                                Regex  rex     = new Regex(pattern, RegexOptions.IgnoreCase);
                                Match  match   = rex.Match(rcardCheck);
                                // 序列号被限制为字符 空格 数字
                                if (!match.Success)
                                {
                                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SNContent_CheckWrong $CS_Param_RunSeq:" + this.txtRCardEdit.Value.Trim()));
                                    this.txtRCardEdit.TextFocus(false, true);
                                    return;
                                }
                            }
                        }
                        #endregion
                    }
                    #endregion

                    #region  Qty
                    try
                    {
                        decimal moQty  = 0;
                        int     intQty = Convert.ToInt32(this.txtRelationQtyEdit.Value);
                        if (intQty <= 0)
                        {
                            //数量应为整数类型 $Error_Qty_Not_Int
                            ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_SmtRelQty_Should_Over_Zero"));
                            this.txtRelationQtyEdit.TextFocus(false, true);
                            return;
                        }
                        if (objMO != null && ((MO)objMO).IDMergeRule >= 0)
                        {
                            moQty = ((MO)objMO).IDMergeRule;
                        }
                        if (moQty < Convert.ToDecimal(intQty))
                        {
                            //数量应小于工单的连板数 $Error_Qty_Not_Int
                            ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_SmtRelQty_Should_less_MO" + ": " + moQty));
                            this.txtRelationQtyEdit.TextFocus(false, true);
                            return;
                        }
                    }
                    catch
                    {
                        //数量应为整数类型 $Error_Qty_Not_Int
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Qty_Not_Int"));
                        this.txtRelationQtyEdit.TextFocus(false, true);
                        return;
                    }
                    #endregion

                    #region      Smtrelationqty
                    DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    if (smtfacade.GetSMTRelationQty(this.txtRCardEdit.Value.Trim().ToUpper(), this.txtMoCodeEdit.Value.Trim().ToUpper()) != null)
                    {
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_RCard_Exist"));
                        this.txtRCardEdit.TextFocus(false, true);
                        return;
                    }
                    Smtrelationqty smtqty = smtfacade.CreateNewSmtrelationqty();
                    smtqty.Rcard        = this.txtRCardEdit.Value.Trim().ToUpper();
                    smtqty.Mocode       = this.txtMoCodeEdit.Value.Trim().ToUpper();
                    smtqty.Itemcode     = ((MO)mofacade.GetMO(smtqty.Mocode)).ItemCode;
                    smtqty.Relationqtry = int.Parse(this.txtRelationQtyEdit.Value);
                    smtqty.Muser        = ApplicationService.Current().UserCode;
                    smtqty.Mdate        = dbDateTime.DBDate;
                    smtqty.Mtime        = dbDateTime.DBTime;
                    smtqty.Eattribute1  = "";
                    smtqty.Eattribute2  = "";
                    smtqty.Eattribute3  = "";
                    smtqty.Memo         = "";
                    smtfacade.AddSmtrelationqty(smtqty);
                    #endregion
                }
                catch (Exception ex)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, ex.Message));
                    return;
                }
                btnQuery_Click(sender, e);
            }
        }
Beispiel #21
0
        private void txtRCardEdit_TxtboxKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                #region facade
                if (collectfacade == null)
                {
                    collectfacade = new DataCollectFacade(this.DataProvider);
                }
                if (morcardfacade == null)
                {
                    morcardfacade = new MORunningCardFacade(this.DataProvider);
                }
                if (materialFacade == null)
                {
                    materialFacade = new MaterialFacade(this.DataProvider);
                }
                if (mofacade == null)
                {
                    mofacade = new MOFacade(this.DataProvider);
                }
                if (itemfacade == null)
                {
                    itemfacade = new ItemFacade(this.DataProvider);
                }

                #endregion

                #region   null
                if (this.txtMoCodeEdit.Value == string.Empty)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$MO_Cannot_Null"));
                    this.txtMoCodeEdit.TextFocus(false, true);
                    return;
                }
                if (txtRCardEdit.Value.Trim().Equals(""))
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$RMARcard_Cannot_Null"));
                    this.txtRCardEdit.TextFocus(false, true);
                    return;
                }
                #endregion

                #region mocode
                if (materialFacade.GetMOCode(this.txtMoCodeEdit.Value) == false)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Rework_MO_Not_Exist"));
                    this.txtMoCodeEdit.TextFocus(false, true);
                    return;
                }
                object objMO = mofacade.GetMO(this.txtMoCodeEdit.Value.Trim().ToUpper());
                if (objMO == null || ((MO)objMO).MOStatus.Trim().ToUpper() == "MOSTATUS_CLOSE")
                {
                    //该工单已关单,不能维护打X板!
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_MO_Close_Not_SmtRelQty"));
                    this.txtMoCodeEdit.TextFocus(false, true);
                    return;
                }
                #endregion

                #region rcard
                object lastsimulationReport = materialFacade.GetLastSimulationReport(this.txtRCardEdit.Value.Trim().ToUpper());
                if (lastsimulationReport != null)
                {
                    if (((SimulationReport)lastsimulationReport).IsComplete.Trim() == "0")
                    {
                        // 该序列号在生产中,不允许维护打X板!
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Rcard_inProduction"));
                        this.txtRCardEdit.TextFocus(false, true);
                        return;
                    }
                    object simulationReport = collectfacade.GetSimulationReport(this.txtMoCodeEdit.Value.Trim().ToUpper(), this.txtRCardEdit.Value.Trim().ToUpper());
                    if (simulationReport != null)
                    {
                        // 该序列号在生产中或者已经完工,不允许维护打X板!
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Rcard_inProductionOrClose"));
                        this.txtRCardEdit.TextFocus(false, true);
                        return;
                    }
                    else
                    {
                        //修改  rcard不在工单范围内
                        #region
                        object item2sncheck = itemfacade.GetItem2SNCheck(((MO)objMO).ItemCode.Trim().ToUpper(), ItemCheckType.ItemCheckType_SERIAL);
                        if (item2sncheck != null)
                        {
                            string checkContent = ((Item2SNCheck)item2sncheck).SNContentCheck.Trim().ToUpper();
                            int    checkLength  = ((Item2SNCheck)item2sncheck).SNLength;
                            string checkPrefix  = ((Item2SNCheck)item2sncheck).SNPrefix.Trim().ToUpper();

                            string rcardCheck = this.txtRCardEdit.Value.Trim().ToUpper();
                            if (!string.IsNullOrEmpty(checkPrefix))
                            {
                                if (rcardCheck.IndexOf(checkPrefix) != 0)
                                {
                                    // 该序列号与工单要求的序列号前缀不一样
                                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardPrefix_ERROR  $CS_RunningCardPrefix: " + checkPrefix));
                                    this.txtRCardEdit.TextFocus(false, true);
                                    return;
                                }
                            }
                            if (checkLength != null && checkLength > 0)
                            {
                                if (rcardCheck.Length != checkLength)
                                {
                                    // 该序列号与工单要求的序列号长度不一样
                                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardLength_ERROR  $CS_RunningCardLength: " + checkLength));
                                    this.txtRCardEdit.TextFocus(false, true);
                                    return;
                                }
                            }
                            if (checkContent != null && checkContent == "Y")
                            {
                                string pattern = @"^([A-Za-z0-9]+[ ]*)*[A-Za-z0-9]+$";
                                Regex  rex     = new Regex(pattern, RegexOptions.IgnoreCase);
                                Match  match   = rex.Match(rcardCheck);
                                // 序列号被限制为字符 空格 数字
                                if (!match.Success)
                                {
                                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SNContent_CheckWrong $CS_Param_RunSeq:" + this.txtRCardEdit.Value.Trim()));
                                    this.txtRCardEdit.TextFocus(false, true);
                                    return;
                                }
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    //修改      rcard不在工单范围内
                    #region
                    object item2sncheck = itemfacade.GetItem2SNCheck(((MO)objMO).ItemCode.Trim().ToUpper(), ItemCheckType.ItemCheckType_SERIAL);
                    if (item2sncheck != null)
                    {
                        string checkContent = ((Item2SNCheck)item2sncheck).SNContentCheck.Trim().ToUpper();
                        int    checkLength  = ((Item2SNCheck)item2sncheck).SNLength;
                        string checkPrefix  = ((Item2SNCheck)item2sncheck).SNPrefix.Trim().ToUpper();

                        string rcardCheck = this.txtRCardEdit.Value.Trim().ToUpper();
                        if (!string.IsNullOrEmpty(checkPrefix))
                        {
                            if (rcardCheck.IndexOf(checkPrefix) != 0)
                            {
                                // 该序列号与工单要求的序列号前缀不一样
                                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardPrefix_ERROR  $CS_RunningCardPrefix: " + checkPrefix));
                                this.txtRCardEdit.TextFocus(false, true);
                                return;
                            }
                        }
                        if (checkLength != null && checkLength > 0)
                        {
                            if (rcardCheck.Length != checkLength)
                            {
                                // 该序列号与工单要求的序列号长度不一样
                                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_RunningCardLength_ERROR  $CS_RunningCardLength: " + checkLength));
                                this.txtRCardEdit.TextFocus(false, true);
                                return;
                            }
                        }
                        if (checkContent != null && checkContent == "Y")
                        {
                            string pattern = @"^([A-Za-z0-9]+[ ]*)*[A-Za-z0-9]+$";
                            Regex  rex     = new Regex(pattern, RegexOptions.IgnoreCase);
                            Match  match   = rex.Match(rcardCheck);
                            // 序列号被限制为字符 空格 数字
                            if (!match.Success)
                            {
                                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SNContent_CheckWrong $CS_Param_RunSeq:" + this.txtRCardEdit.Value.Trim()));
                                this.txtRCardEdit.TextFocus(false, true);
                                return;
                            }
                        }
                    }
                    #endregion
                }
                #endregion

                this.txtRelationQtyEdit.TextFocus(false, true);
            }
        }
Beispiel #22
0
        public Messages InsertLotOnWipItem(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade, object[] OPBOMDetail)
        {
            Messages returnValue = new Messages();

            string              iNNO             = ((CINNOActionEventArgs)actionEventArgs).INNO;
            LotSimulation       simulation       = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
            LotSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
            MaterialFacade      material         = new MaterialFacade(_domainDataProvider);

            //object[] mINNOs = material.GetLastMINNOs(iNNO);
            object[] mINNOs = OPBOMDetail;
            int      i      = 0;

            if (mINNOs == null)
            {
                throw new Exception("$CS_INNO_NOT_EXIST");
            }

            //确定是否需要扣料
            SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider);
            Parameter           objParameter        = (Parameter)systemSettingFacade.GetParameter("DEDUCTQTY", "DEDUCTMATERIAL");
            bool isDeductQty = true;

            if (objParameter == null || objParameter.ParameterAlias != "Y")
            {
                isDeductQty = false;
            }

            foreach (MINNO mINNO in mINNOs)
            {
                if (mINNO == null)
                {
                    throw new Exception("$CS_INNOnotExist");
                }
                if (!isDeductQty)//如果不扣料只记录同一首选料的一笔过账
                {
                    //原有过账记录,挪到此处
                    LotOnWipItem wipItem = new LotOnWipItem();

                    wipItem.DateCode       = mINNO.DateCode;
                    wipItem.LOTNO          = mINNO.LotNO;
                    wipItem.MItemCode      = mINNO.MItemCode;
                    wipItem.VendorCode     = mINNO.VendorCode;
                    wipItem.VendorItemCode = mINNO.VendorItemCode;
                    wipItem.Version        = mINNO.Version;
                    wipItem.MSeq           = i;
                    wipItem.MCardType      = mINNO.EAttribute1;

                    wipItem.Eattribute1         = simulation.EAttribute1;
                    wipItem.ItemCode            = simulation.ItemCode;
                    wipItem.ResCode             = simulation.ResCode;
                    wipItem.RouteCode           = simulation.RouteCode;
                    wipItem.LotCode             = simulation.LotCode;
                    wipItem.LotSeq              = simulation.LotSeq;
                    wipItem.SegmentCode         = simulationReport.SegmentCode;
                    wipItem.BeginShiftCode      = simulationReport.BeginShiftCode;
                    wipItem.ShiftTypeCode       = simulationReport.ShiftTypeCode;
                    wipItem.StepSequenceCode    = simulationReport.StepSequenceCode;
                    wipItem.BeginTimePeriodCode = simulationReport.BeginTimePeriodCode;
                    wipItem.MOCode              = simulation.MOCode;
                    wipItem.ModelCode           = simulation.ModelCode;
                    wipItem.OPCode              = simulation.OPCode;
                    wipItem.CollectStatus       = simulation.CollectStatus;
                    wipItem.BeginDate           = simulation.BeginDate;
                    wipItem.BeginTime           = simulation.BeginTime;
                    wipItem.MaintainUser        = simulation.MaintainUser;
                    wipItem.TransStatus         = TransactionStatus.TransactionStatus_YES;

                    if (mINNO.Qty.ToString() != string.Empty && Convert.ToInt32(mINNO.Qty) != 0)
                    {
                        wipItem.Qty = mINNO.Qty * simulation.LotQty;
                    }
                    else
                    {
                        wipItem.Qty = simulation.LotQty;
                    }

                    //Laws Lu,2005/12/20,新增	采集类型
                    wipItem.ActionType = (int)MaterialType.CollectMaterial;
                    wipItem.MOSeq      = simulation.MOSeq; // Added by Icyer 2007/07/02

                    dataCollectFacade.AddLotOnWIPItem(wipItem);

                    LotSimulationReport simulationRpt = dataCollectFacade.GetLastLotSimulationReport(wipItem.LotCode);
                    if (simulationRpt != null)
                    {
                        dataCollectFacade.UpdateLotSimulationReport(simulationRpt);

                        // End Added
                    }
                    i++;
                }
                else
                {
                    //add by Jarvis 20120316 For 扣料
                    DeductQty(actionEventArgs, dataCollectFacade, mINNO);
                }
            }
            seqForDeductQty = 0;
            return(returnValue);
        }
Beispiel #23
0
        //Laws Lu,2005/12/23,新增INNO上料记录
        //Laws Lu,2006/01/06,允许记录Lot料的明细记录
        public void InsertINNOOnWipItem(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade)
        {
            string              iNNO             = ((CINNOActionEventArgs)actionEventArgs).INNO;
            LotSimulation       simulation       = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
            LotSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
            MaterialFacade      material         = new MaterialFacade(_domainDataProvider);

            object[] mINNOs = material.GetLastMINNOs(iNNO);
            int      i      = 0;

            if (mINNOs == null)
            {
                throw new Exception("$CS_INNO_NOT_EXIST");
            }
            foreach (MINNO mINNO in mINNOs)
            {
                if (mINNO == null)
                {
                    throw new Exception("$CS_INNOnotExist");
                }
                if (mINNO.MOCode != simulation.MOCode)
                {
                    throw new Exception("$CS_INNOnotForMO $CS_Param_MOCode=" + mINNO.MOCode);
                }
                if (mINNO.RouteCode != simulation.RouteCode)
                {
                    throw new Exception("$CS_INNOnotForRoute $CS_Param_RouteCode=" + mINNO.RouteCode);
                }
                if (mINNO.OPCode != simulation.OPCode)
                {
                    throw new Exception("$CS_INNOnotForOP $CS_Param_OPCode =" + mINNO.OPCode);
                }
                if (mINNO.ResourceCode != simulation.ResCode)
                {
                    throw new Exception("$CS_INNOnotForResource $CS_Param_ResourceCode=" + mINNO.ResourceCode);
                }

                LotOnWipItem wipItem = new LotOnWipItem();


                wipItem.DateCode            = mINNO.DateCode;
                wipItem.LOTNO               = mINNO.MItemPackedNo; //.LotNO;
                wipItem.MItemCode           = mINNO.MItemCode;     /*ActionOnLineHelper.StringNull;*/
                wipItem.MSeq                = i;
                wipItem.VendorCode          = mINNO.VendorCode;
                wipItem.VendorItemCode      = mINNO.VendorItemCode;
                wipItem.Version             = mINNO.Version;
                wipItem.Eattribute1         = simulation.EAttribute1;
                wipItem.ItemCode            = simulation.ItemCode;
                wipItem.ResCode             = simulation.ResCode;
                wipItem.RouteCode           = simulation.RouteCode;
                wipItem.LotCode             = simulation.LotCode;
                wipItem.LotSeq              = simulation.LotSeq;
                wipItem.SegmentCode         = simulationReport.SegmentCode;
                wipItem.BeginShiftCode      = simulationReport.BeginShiftCode;
                wipItem.ShiftTypeCode       = simulationReport.ShiftTypeCode;
                wipItem.StepSequenceCode    = simulationReport.StepSequenceCode;
                wipItem.BeginTimePeriodCode = simulationReport.BeginTimePeriodCode;
                wipItem.MOCode              = simulation.MOCode;
                wipItem.ModelCode           = simulation.ModelCode;
                wipItem.OPCode              = simulation.OPCode;
                wipItem.CollectStatus       = simulation.CollectStatus;
                wipItem.BeginDate           = simulation.BeginDate;
                wipItem.BeginTime           = simulation.BeginTime;
                wipItem.MaintainUser        = simulation.MaintainUser;

                wipItem.Qty       = mINNO.Qty * simulation.LotQty;
                wipItem.MCardType = MCardType.MCardType_INNO;
                //Laws Lu,2005/12/20,新增	采集类型
                wipItem.ActionType = (int)MaterialType.CollectMaterial;
                wipItem.MOSeq      = simulation.MOSeq; // Added by Icyer 2007/07/02

                dataCollectFacade.AddLotOnWIPItem(wipItem);

                i++;
            }
        }
Beispiel #24
0
        public void ImportWorkPlan(bool isRollBack)
        {
            ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this._DataProvider);
            DBDateTime       now = FormatHelper.GetNowDBDateTime(this._DataProvider);

            object[] objs  = ConvertArrayListToObjectArray(_ImportDataTable);
            object[] objDt = ConvertArrayListToObjectArray(_ImportDataTable);

            try
            {
                _DataProvider.BeginTransaction();

                if (objs != null && objDt != null)
                {
                    for (int i = 0; i < objs.Length; i++)
                    {
                        try
                        {
                            GridRecord row = _ImportGridRow[i] as GridRecord;
                            WorkPlan   workPlanFromExcel = objs[i] as WorkPlan;
                            int        shiftDay          = shiftModelFacade.GetShiftDayByBigSSCode(workPlanFromExcel.BigSSCode, now.DateTime);
                            if (_MaterialFacade == null)
                            {
                                _MaterialFacade = new MaterialFacade(_DataProvider);
                            }

                            WorkPlan objWorkPlanFromDB = (WorkPlan)_MaterialFacade.GetWorkPlan(workPlanFromExcel.BigSSCode, workPlanFromExcel.PlanDate,
                                                                                               workPlanFromExcel.MoCode, workPlanFromExcel.MoSeq);

                            if (objWorkPlanFromDB != null)
                            {
                                ((WorkPlan)objs[i]).MaterialQty      = objWorkPlanFromDB.MaterialQty;
                                ((WorkPlan)objs[i]).ActQty           = objWorkPlanFromDB.ActQty;
                                ((WorkPlan)objs[i]).MaterialStatus   = objWorkPlanFromDB.MaterialStatus;
                                ((WorkPlan)objs[i]).ActionStatus     = objWorkPlanFromDB.ActionStatus;
                                ((WorkPlan)objs[i]).ItemCode         = objWorkPlanFromDB.ItemCode;
                                ((WorkPlan)objs[i]).PromiseTime      = objWorkPlanFromDB.PromiseTime;
                                ((WorkPlan)objs[i]).LastReqTime      = objWorkPlanFromDB.LastReqTime;
                                ((WorkPlan)objs[i]).LastReceiveTime  = objWorkPlanFromDB.LastReceiveTime;
                                ((WorkPlan)objs[i]).PlanEndTime      = objWorkPlanFromDB.PlanEndTime;
                                ((WorkPlan)objDt[i]).MaterialQty     = objWorkPlanFromDB.MaterialQty;
                                ((WorkPlan)objDt[i]).ActQty          = objWorkPlanFromDB.ActQty;
                                ((WorkPlan)objDt[i]).MaterialStatus  = objWorkPlanFromDB.MaterialStatus;
                                ((WorkPlan)objDt[i]).ActionStatus    = objWorkPlanFromDB.ActionStatus;
                                ((WorkPlan)objDt[i]).ItemCode        = objWorkPlanFromDB.ItemCode;
                                ((WorkPlan)objDt[i]).PromiseTime     = objWorkPlanFromDB.PromiseTime;
                                ((WorkPlan)objDt[i]).LastReqTime     = objWorkPlanFromDB.LastReqTime;
                                ((WorkPlan)objDt[i]).LastReceiveTime = objWorkPlanFromDB.LastReceiveTime;
                                ((WorkPlan)objDt[i]).PlanEndTime     = objWorkPlanFromDB.PlanEndTime;

                                _DataProvider.Update(objs[i]);
                                _DataProvider.Update(objDt[i]);
                                row.Items.FindItemByKey("ImportResult").Text     = _LanguageComponent1.GetString("$CycleImport_Success");
                                row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue";
                            }
                            else
                            {
                                if ((workPlanFromExcel.PlanDate) >= shiftDay)
                                {
                                    _DataProvider.Insert(objDt[i]);
                                    row.Items.FindItemByKey("ImportResult").Text     = _LanguageComponent1.GetString("$CycleImport_Success");
                                    row.Items.FindItemByKey("ImportResult").CssClass = "LinkColorBlue";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            GridRecord row = _ImportGridRow[i] as GridRecord;
                            row.Items.FindItemByKey("ImportResult").Text     = _LanguageComponent1.GetString("$CycleImport_Error");
                            row.Items.FindItemByKey("ImportResult").CssClass = "ForeColorRed";
                            this.ErrorArray.Add(ex);
                        }
                    }
                }

                _DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                _DataProvider.RollbackTransaction();
                this.ErrorArray.Add(ex);
            }
        }
Beispiel #25
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            this.txtMoCode.TextFocus(false, true);

            MaterialFacade materialFacade = new MaterialFacade(this.DataProvider);

            if (!HaveSelectedGrid())
            {
                return;
            }

            if (!GridCheckd())
            {
                return;
            }

            try
            {
                this.DataProvider.BeginTransaction();
                DBDateTime dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

                for (int i = 0; i < ultraGridMaterial.Rows.Count; i++)
                {
                    if (ultraGridMaterial.Rows[i].Cells[0].Value.ToString().ToLower() == "true")
                    {
                        MaterialIssue materialIssue = (MaterialIssue)materialFacade.GetMaterialIssue(ultraGridMaterial.Rows[i].Cells["BigSSCode"].Value.ToString(),
                                                                                                     int.Parse(ultraGridMaterial.Rows[i].Cells["PlanDate"].Value.ToString()),
                                                                                                     ultraGridMaterial.Rows[i].Cells["MoCode"].Value.ToString(),
                                                                                                     int.Parse(ultraGridMaterial.Rows[i].Cells["MoSEQ"].Value.ToString()),
                                                                                                     int.Parse(ultraGridMaterial.Rows[i].Cells["IssueSEQ"].Value.ToString()));
                        if (materialIssue != null)
                        {
                            materialFacade.UpdateMaterialIssueIssueStatus(materialIssue);

                            MaterialIssue newMaterialIssue = materialFacade.CreateNewMaterialIssue();
                            newMaterialIssue.BigSSCode = ultraGridMaterial.Rows[i].Cells["BigSSCode"].Value.ToString();
                            newMaterialIssue.PlanDate  = int.Parse(ultraGridMaterial.Rows[i].Cells["PlanDate"].Value.ToString());
                            newMaterialIssue.MoCode    = ultraGridMaterial.Rows[i].Cells["MoCode"].Value.ToString();
                            newMaterialIssue.MoSeq     = Convert.ToDecimal(ultraGridMaterial.Rows[i].Cells["MoSEQ"].Value.ToString());
                            newMaterialIssue.IssueSEQ  = materialFacade.GetMaterialIssueMaxIssueSEQ(newMaterialIssue.BigSSCode,
                                                                                                    newMaterialIssue.PlanDate,
                                                                                                    newMaterialIssue.MoCode,
                                                                                                    newMaterialIssue.MoSeq);
                            newMaterialIssue.IssueQTY     = Convert.ToDecimal(ultraGridMaterial.Rows[i].Cells["IssueQTY"].Value.ToString());
                            newMaterialIssue.IssueType    = MaterialIssueType.MaterialIssueType_Receive;
                            newMaterialIssue.IssueStatus  = MaterialIssueStatus.MaterialIssueStatus_Close;
                            newMaterialIssue.MaintainUser = ApplicationService.Current().UserCode;
                            newMaterialIssue.MaintainDate = dBDateTime.DBDate;
                            newMaterialIssue.MaintainTime = dBDateTime.DBTime;

                            materialFacade.AddMaterialIssue(newMaterialIssue);

                            //更新BigSSCode+MoCode所有的预警信息
                            object[] workPlanObjects = materialFacade.QueryWorkPlan(newMaterialIssue.BigSSCode, newMaterialIssue.MoCode);
                            if (workPlanObjects != null)
                            {
                                for (int j = 0; j < workPlanObjects.Length; j++)
                                {
                                    WorkPlan workPlanUpdate = workPlanObjects[j] as WorkPlan;

                                    //更新当前项次的数量
                                    if (workPlanUpdate.PlanDate == newMaterialIssue.PlanDate &&  workPlanUpdate.MoSeq == newMaterialIssue.MoSeq)
                                    {
                                        workPlanUpdate.MaterialQty += Convert.ToInt32(ultraGridMaterial.Rows[i].Cells["RecevieQTY"].Value.ToString());
                                    }

                                    workPlanUpdate.LastReceiveTime = dBDateTime.DBTime;
                                    workPlanUpdate.LastReqTime     = 0;
                                    workPlanUpdate.PromiseTime     = 0;
                                    workPlanUpdate.MaterialStatus  = MaterialWarningStatus.MaterialWarningStatus_No;

                                    materialFacade.UpdateWorkPlan(workPlanUpdate);
                                }
                            }

                            materialFacade.UpdateMaterialReqInfo(ultraGridMaterial.Rows[i].Cells["BigSSCode"].Value.ToString(), ultraGridMaterial.Rows[i].Cells["MoCode"].Value.ToString());
                        }
                    }
                }

                this.DataProvider.CommitTransaction();
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_RecevieMaterial_Success"));
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();

                Messages msg = new Messages();
                msg.Add(new UserControl.Message(ex));
                ApplicationRun.GetInfoForm().Add(msg);
            }

            this.btnQuery_Click(sender, e);
        }
        public void ProcessRequest(HttpContext context)
        {
            string itemCodeValue    = context.Request.QueryString["itemCodeValue"].Trim().ToUpper();
            string snPrefix         = context.Request.QueryString["snPrefix"].Trim().ToUpper();
            string StartSnCodeValue = context.Request.QueryString["StartSnCodeValue"].Trim().ToUpper();
            string actionType       = context.Request.QueryString["Action"].Trim().ToUpper();
            string EndSnValue       = context.Request.QueryString["EndSnValue"].Trim().ToUpper();
            string SnSeqValue       = context.Request.QueryString["SnSeqValue"].Trim().ToUpper();
            string CheckedValue     = context.Request.QueryString["CheckedValue"].Trim().ToUpper();

            try
            {
                _facade = new MaterialFacade(this.DataProvider);
                string returnValue = "false";
                string _scale      = string.Empty;

                NumberScale scale = NumberScale.Scale34;
                _scale = "34";

                if (CheckedValue == "10")
                {
                    scale  = NumberScale.Scale10;
                    _scale = "10";
                }
                else if (CheckedValue == "16")
                {
                    scale  = NumberScale.Scale16;
                    _scale = "16";
                }
                else if (CheckedValue == "34")
                {
                    scale  = NumberScale.Scale34;
                    _scale = "34";
                }
                else
                {
                    scale  = NumberScale.Scale34;
                    _scale = "34";
                }


                int length = StartSnCodeValue.Trim().Length;

                if (StartSnCodeValue.Trim() != "" && EndSnValue.Trim() != "")
                {
                    long startSN = 0;
                    try
                    {
                        startSN = long.Parse(NumberScaleHelper.ChangeNumber(StartSnCodeValue.Trim(), scale, NumberScale.Scale10));
                    }
                    catch (Exception ex)
                    {
                        //throw ex;
                        //txtMORCardStartEdit.Focus();
                        returnValue = "false";
                    }

                    long endSN = 0;
                    try
                    {
                        endSN = long.Parse(NumberScaleHelper.ChangeNumber(EndSnValue.Trim(), scale, NumberScale.Scale10));
                    }
                    catch (Exception ex)
                    {
                        returnValue = "false";
                    }

                    if ((startSN.ToString().Length + snPrefix.Trim().Length) > 40)
                    {
                        returnValue = "false";
                    }

                    if (startSN > endSN)
                    {
                        returnValue = "false";
                    }

                    bool needUpdateDetail = true;

                    if (actionType == "UPDATE")
                    {
                        MKeyPart oldMKeyPart = (MKeyPart)_facade.GetMKeyPart(Convert.ToDecimal(SnSeqValue), itemCodeValue);

                        if (oldMKeyPart != null &&
                            oldMKeyPart.RCardPrefix.Trim().ToUpper() == snPrefix.Trim().ToUpper() &&
                            oldMKeyPart.RunningCardStart.Trim().ToUpper() == StartSnCodeValue.Trim().ToUpper() &&
                            oldMKeyPart.RunningCardEnd.Trim().ToUpper() == EndSnValue.Trim().ToUpper() &&
                            oldMKeyPart.SNScale.Trim().ToUpper() == _scale)
                        {
                            needUpdateDetail = false;
                        }
                    }

                    //if (actionType == "ADD")
                    //{
                    //检查需要插入的detail数据量是否太多

                    if (needUpdateDetail)
                    {
                        if (endSN - startSN > 4999)
                        {
                            returnValue = "true";
                        }
                        else
                        {
                            returnValue = "false";
                        }
                    }
                    else
                    {
                        returnValue = "false";
                    }


                    //}

                    //if (actionType == "UPDATE")
                    //{
                    //    long count = endSN - startSN + 1;  //当前界面上算出来的数量

                    //    try
                    //    {

                    //        long checkCount = _facade.CheckMKeyPartDetail(SnSeqValue, itemCodeValue, StartSnCodeValue, EndSnValue, snPrefix.Trim().ToUpper());


                    //        if (checkCount == 0)
                    //        {
                    //            if (endSN - startSN > 4999)
                    //            {
                    //                returnValue = "true";
                    //            }
                    //            else
                    //            {
                    //                returnValue = "false";
                    //            }


                    //        }
                    //        else
                    //        {

                    //            if (count - checkCount < 0 || count - checkCount == 0) //会删掉数据库的序列号,所以速度比较快。
                    //            {
                    //                returnValue = "false";

                    //            }
                    //            else
                    //            {
                    //                if (count - checkCount > 4999)  //为4999 //会insert into 序列号到数据库,所以要判断inset into的数量是否大于4999
                    //                {
                    //                    returnValue = "true";

                    //                }
                    //                else
                    //                {
                    //                    returnValue = "false";

                    //                }
                    //            }
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        returnValue = "false";

                    //    }


                    //}
                }
                else
                {
                    returnValue = "false";
                }

                context.Response.Write(returnValue);
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
            }
        }