protected void Page_Load(object sender, System.EventArgs e) { this.gridHelper = new GridHelper(this.gridItem2Route); //Laws Lu,2006/09/26 获取产品 if (Request.QueryString["ItemCode"] != null) { ItemCode = Request.QueryString["ItemCode"].Trim(); txtItemCodeQuery.Text = ItemCode; } moFac = new FacadeFactory(base.DataProvider).CreateMOFacade(); Domain.MOModel.DefaultItem2Route dItem2Route = null; object objOld = moFac.GetDefaultItem2Route(ItemCode); this.gridHelper.BuildGridRowhandle = new BuildGridRowDelegate(this.GetGridRow); this.gridHelper.GetRowCountHandle = new GetRowCountDelegate(this.GetRowCount); this.gridHelper.LoadDataSourceHandle = new LoadDataSourceDelegate(this.LoadDataSource); if (!this.IsPostBack) { this.InitWebGrid(); this.InitPageLanguage(this.languageComponent1, false); this.cmdQuery_ServerClick(null, null); } if (objOld != null) { dItem2Route = objOld as Domain.MOModel.DefaultItem2Route; } if (dItem2Route != null) { lblDefaultRoute.Text = languageComponent1.GetString("$Current_Default_Route ") + dItem2Route.RouteCode; } if (!this.Page.IsStartupScriptRegistered("SelectableTextBox_Startup_js")) { string scriptString = string.Format("<script>var STB_Virtual_Path = \"{0}\";</script><script src='{0}SelectQuery/selectableTextBox.js'></script>", this.VirtualHostRoot); this.Page.RegisterStartupScript("SelectableTextBox_Startup_js", scriptString); } }
private int GetRowCount() { if (_modelFacade == null) { _modelFacade = new SMTFacadeFactory(base.DataProvider).CreateMOFacade(); } // return this._modelFacade.QueryMOIllegibilityCount( // FormatHelper.PKCapitalFormat( FormatHelper.CleanString( this.txtMoCodeQuery.Text )), // FormatHelper.PKCapitalFormat( FormatHelper.CleanString( this.txtItemCodeQuery.Text )), // string.Empty, // FormatHelper.CleanString( this.drpMoStatusQuery.SelectedValue ), // string.Empty,string.Empty); return(this._modelFacade.QueryMOIllegibilityCount( FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtMoCodeQuery.Text)), FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtItemCodeQuery.Text)), string.Empty, this.getSelectMOStatus(), string.Empty, string.Empty)); }
protected void cmdSave_ServerClick(object sender, System.EventArgs e) { if (txtMOCodeEdit.Enabled == true && FormatHelper.CleanString(this.txtMOCodeEdit.Text) == string.Empty) { throw new Exception("$CS_MO_NotExit"); } if (facade == null) { facade = new BenQGuru.eMES.SelectQuery.SPFacade(base.DataProvider); } BenQGuru.eMES.Material.WarehouseFacade _facade = new BenQGuru.eMES.Material.WarehouseFacade(this.facade.DataProvider); ArrayList list = new ArrayList(); for (int i = 0; i < this.gridSelected.Rows.Count; i++) { if (IsDecimal(this.gridSelected.Rows[i].Cells[3].Text) && decimal.Parse(this.gridSelected.Rows[i].Cells[3].Text) != 0) { WarehouseTicketDetail item = _facade.CreateNewWarehouseTicketDetail(); item.TicketNo = this.GetRequestParam("ticketno"); item.ItemCode = this.gridSelected.Rows[i].Cells[1].Text; item.ItemName = this.gridSelected.Rows[i].Cells[2].Text; item.MOCode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtMOCodeEdit.Text)); item.Qty = decimal.Parse(this.gridSelected.Rows[i].Cells[3].Text); item.ActualQty = 0; item.MaintainUser = this.GetUserCode(); list.Add(item); } } if (FormatHelper.CleanString(this.txtMOCodeEdit.Text) != string.Empty) { BenQGuru.eMES.MOModel.MOFacade mof = new BenQGuru.eMES.MOModel.MOFacade(this.facade.DataProvider); BenQGuru.eMES.Domain.MOModel.MO mo = (BenQGuru.eMES.Domain.MOModel.MO)mof.GetMO(FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtMOCodeEdit.Text))); if (mo == null || (mo.MOStatus != MOManufactureStatus.MOSTATUS_RELEASE && mo.MOStatus != MOManufactureStatus.MOSTATUS_OPEN && mo.MOStatus != MOManufactureStatus.MOSTATUS_PENDING)) { throw new Exception("$CS_MO_NotExit"); } } _facade.AddWarehouseTicketDetail(list); this.Page.RegisterStartupScript("close window", "<script language='javascript'>CloseWindow();</script>"); }
private object[] LoadDataSource(int inclusive, int exclusive) { if (_modelFacade == null) { _modelFacade = new SMTFacadeFactory(base.DataProvider).CreateMOFacade(); } // return this._modelFacade.QueryMOIllegibility( // FormatHelper.PKCapitalFormat( FormatHelper.CleanString( this.txtMoCodeQuery.Text )), // FormatHelper.PKCapitalFormat( FormatHelper.CleanString( this.txtItemCodeQuery.Text )), // string.Empty, // FormatHelper.CleanString( this.drpMoStatusQuery.SelectedValue ), // string.Empty,string.Empty, // inclusive, exclusive ); return(this._modelFacade.QueryMOIllegibility( FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtMoCodeQuery.Text)), FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtItemCodeQuery.Text)), string.Empty, this.getSelectMOStatus(), string.Empty, string.Empty, inclusive, exclusive)); }
private void txtMOCodeQuery_TxtboxKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == '\r') { if (this.checkedMOCode != this.txtMOCodeQuery.Value.Trim().ToUpper()) { this.txtMOCodeQuery.Value = this.txtMOCodeQuery.Value.Trim().ToUpper(); BenQGuru.eMES.MOModel.MOFacade moFacade = new BenQGuru.eMES.MOModel.MOFacade(this.DataProvider); MO mo = (MO)moFacade.GetMO(this.txtMOCodeQuery.Value); if (mo == null) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_MO_Not_Exist")); //Application.DoEvents(); this.txtMOCodeQuery.TextFocus(true, true); return; } this.txtItemCodeQuery.Value = mo.ItemCode; this.checkedMOCode = this.txtMOCodeQuery.Value; } //Application.DoEvents(); this.txtSSCodeQuery.TextFocus(false, true); } }
//获取比对结果 private void GetCompareDate() { Hashtable _compareHT = new Hashtable(); //TODO 此处调用查询方法 if (facade == null) { facade = new FacadeFactory(base.DataProvider).CreateMOFacade(); } //获取工单标注BOM object[] MOStandardBoms = facade.GetMOBOM(this.MOCode); #region 测试 比对 // // MOBOM StandardmoBom0 = new MOBOM(); // StandardmoBom0.MOCode = "FFF-050718-05"; // StandardmoBom0.ItemCode = "GSM7503RD18"; // StandardmoBom0.MOBOMItemCode = "FKV8.074.967WE01"; // StandardmoBom0.MOBOMItemName = "子阶料0"; // StandardmoBom0.MOBOMItemQty = 1; // StandardmoBom0.MOBOMItemUOM = "EA"; // // MOBOM StandardmoBom1 = new MOBOM(); // StandardmoBom1.MOCode = "FFF-050718-05"; // StandardmoBom1.ItemCode = "GSM7503RD18"; // StandardmoBom1.MOBOMItemCode = "FKV8.074.967RD01"; // StandardmoBom1.MOBOMItemName = "子阶料1"; // StandardmoBom1.MOBOMItemQty = 1; // StandardmoBom1.MOBOMItemUOM = "EA"; // // MOBOM StandardmoBom2 = new MOBOM(); // StandardmoBom2.MOCode = "FFF-050718-05"; // StandardmoBom2.ItemCode = "GSM7503RD18";; // StandardmoBom2.MOBOMItemCode = "FKV8.074.968WE01"; // StandardmoBom2.MOBOMItemName = "子阶料2"; // StandardmoBom2.MOBOMItemQty = 1; // StandardmoBom2.MOBOMItemUOM = "EA"; // // //数量不对 // MOBOM StandardmoBom3 = new MOBOM(); // StandardmoBom3.MOCode = "FFF-050718-05"; // StandardmoBom3.ItemCode = "GSM7503RD18";; // StandardmoBom3.MOBOMItemCode = "FKV8.074.966RD01"; // StandardmoBom3.MOBOMItemName = "子阶料3"; // StandardmoBom3.MOBOMItemQty = 5; // StandardmoBom3.MOBOMItemUOM = "EA"; // // //只存在于MOBOM // MOBOM StandardmoBom4 = new MOBOM(); // StandardmoBom4.MOCode = "FFF-050718-05"; // StandardmoBom4.ItemCode = "GSM7503RD18";; // StandardmoBom4.MOBOMItemCode = "FKV8.074.968WW01"; // StandardmoBom4.MOBOMItemName = "子阶料w"; // StandardmoBom4.MOBOMItemQty = 1; // StandardmoBom4.MOBOMItemUOM = "EA"; // // //获取工单标注BOM // object[] MOStandardBoms = new object[]{StandardmoBom0,StandardmoBom1,StandardmoBom2,StandardmoBom3,StandardmoBom4}; #endregion //获取比对结果 _compareHT = facade.CompareMOBOM(MOStandardBoms, this.ItemCode, this.MOCode, this.RouteCode); //Test : 测试数据 显示 #region 测试数据 显示 // ArrayList SucessResult = new ArrayList(); // MOBOM moBom = new MOBOM(); // moBom.MOCode = "工单123"; // moBom.ItemCode = "手机456"; // moBom.MOBOMItemCode = "YJ001"; // moBom.MOBOMItemName = "液晶面板001"; // moBom.MOBOMItemQty = 24; // moBom.MOBOMItemUOM = "块"; // moBom.MOBOMException = "比对成功"; // SucessResult.Add(moBom); // // ArrayList InMOStandardBOMResult = new ArrayList(); // MOBOM StandardmoBom = new MOBOM(); // StandardmoBom.MOCode = "工单123"; // StandardmoBom.ItemCode = "手机456"; // StandardmoBom.MOBOMItemCode = "YJ0099"; // StandardmoBom.MOBOMItemName = "液晶面板99"; // StandardmoBom.MOBOMItemQty = 29; // StandardmoBom.MOBOMItemUOM = "块"; // StandardmoBom.MOBOMException = "比对失败 只存在于标准BOM"; // InMOStandardBOMResult.Add(StandardmoBom); // // ArrayList InMORouteResult = new ArrayList(); // OPBOMDetail opBOM = new OPBOMDetail(); // opBOM.ItemCode = "手机456"; // opBOM.OPBOMItemCode = "YJ100"; // opBOM.OPBOMItemName = "液晶面板100"; // opBOM.OPBOMItemQty = 65; // opBOM.OPBOMItemUOM = "块"; // opBOM.OPBOMSourceItemCode = "YJ1001"; // InMORouteResult.Add(opBOM); // // // _compareHT["SucessResult"] = SucessResult; // _compareHT["InMOStandardBOMResult"] = InMOStandardBOMResult; // _compareHT["InMORouteResult"] = InMORouteResult; #endregion this.CompareHT = _compareHT; Session["CompareHT"] = this.CompareHT; }
protected override void ImportData(Excel.Worksheet sheet, string[] strHeader) { DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(ApplicationService.DataProvider); ImportDataEngine impEng = new ImportDataEngine(ApplicationService.DataProvider, this.configObjList, this.configMatchType, ApplicationService.LoginUserCode, dbDateTime); impEng.ImportDataMapping = Properties.Settings.Default.DataMappingType; impEng.UpdateRepeatData = Properties.Settings.Default.DataRepeat; ApplicationService.DataProvider.BeginTransaction(); try { int iRow = 2; int iImportedCount = 0; while (true) { string[] strRow = ReadExcelRow(sheet, iRow, strHeader.Length); if (strRow == null) { break; } // 导入产品 try { // 产品途程主资料 BenQGuru.eMES.MOModel.MOFacade moFacade = new BenQGuru.eMES.MOModel.MOFacade(ApplicationService.DataProvider); BenQGuru.eMES.MOModel.ItemFacade itemFacade = new BenQGuru.eMES.MOModel.ItemFacade(ApplicationService.DataProvider); BenQGuru.eMES.Domain.MOModel.Item2Route itemRoute = new BenQGuru.eMES.Domain.MOModel.Item2Route(); itemRoute.ItemCode = strRow[0].Trim().ToUpper(); itemRoute.RouteCode = strRow[1].Trim().ToUpper(); itemRoute.OrganizationID = int.Parse(strRow[2].Trim().ToUpper()); itemRoute.IsReference = "0"; itemRoute.MaintainUser = ApplicationService.LoginUserCode; itemRoute.MaintainDate = dbDateTime.DBDate; itemRoute.MaintainTime = dbDateTime.DBTime; object ir = itemFacade.GetItem2Route(itemRoute.ItemCode, itemRoute.RouteCode, itemRoute.OrganizationID.ToString()); if (ir == null) { ApplicationService.DataProvider.Insert(itemRoute); } else { ApplicationService.DataProvider.Update(itemRoute); } // 产品默认途程 BenQGuru.eMES.Domain.MOModel.DefaultItem2Route defRoute = null; BenQGuru.eMES.Domain.MOModel.DefaultItem2Route dr = moFacade.GetDefaultItem2Route(itemRoute.ItemCode) as BenQGuru.eMES.Domain.MOModel.DefaultItem2Route; if (dr != null) { defRoute = dr; } else { defRoute = new BenQGuru.eMES.Domain.MOModel.DefaultItem2Route(); } defRoute.ItemCode = itemRoute.ItemCode; if (strRow[3].Trim().ToUpper() == "YES") { defRoute.RouteCode = itemRoute.RouteCode; } if (defRoute.RouteCode != null && defRoute.RouteCode != "") { defRoute.MDate = dbDateTime.DBDate; defRoute.MTime = dbDateTime.DBTime; if (dr == null) { ApplicationService.DataProvider.Insert(defRoute); } else { ApplicationService.DataProvider.Update(defRoute); } } // 产品途程工序列表 //将原来的删除 string strSql = string.Format("delete tblitemroute2op where itemcode = '{0}' and routecode='{1}' and orgid = {2}", itemRoute.ItemCode, itemRoute.RouteCode, itemRoute.OrganizationID.ToString()); ApplicationService.DataProvider.CustomExecute(new SQLCondition(strSql)); strSql = "insert into tblitemroute2op (opid,routecode,opcode,opseq,opcontrol,idmergetype,idmergerule,muser,mdate,mtime,itemcode,orgid) "; strSql += "select routecode||opcode||'{0}',routecode,opcode,opseq,opcontrol,'idmergetype_idmerge',1,muser,mdate,mtime,'{0}',{2} "; strSql += "from tblroute2op where routecode='{1}' "; strSql = string.Format(strSql, itemRoute.ItemCode, itemRoute.RouteCode, itemRoute.OrganizationID.ToString()); ApplicationService.DataProvider.CustomExecute(new SQLCondition(strSql)); iImportedCount++; } catch (Exception ex) { string strResult = ex.Message; if (strResult == "$DATA_REPEAT_CANCEL") // 如果是重复数据,并设置终止 { throw new Exception(strResult); } else if (strResult != "$Import_Unique_Data_Exist") // $Import_Unique_Data_Exist表示重复数据,设置忽略 { if (Properties.Settings.Default.DataError == ImportDataEngine.OnErrorDeal.Cancel) { throw new Exception(strResult); } } } iRow++; } ApplicationService.DataProvider.CommitTransaction(); MessageBox.Show(UserControl.MutiLanguages.ParserMessage("$CycleImport_Success [" + iImportedCount.ToString() + "]"), this.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { ApplicationService.DataProvider.RollbackTransaction(); MessageBox.Show(UserControl.MutiLanguages.ParserMessage(ex.Message), this.MainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
protected override string[] FormatExportRecord(object obj) { /* * MOStock stock = (MOStock)obj; * string dNGRateManual, dNGRateFromItem, dWearOffRateTotal; * if (stock.IssueQty != 0) * { * dNGRateManual = Math.Round(stock.ScrapQty / stock.IssueQty * 100, 2).ToString() + "%"; * dNGRateFromItem = Math.Round((stock.ReturnScrapQty - stock.ScrapQty) / stock.IssueQty * 100, 2).ToString() + "%"; * dWearOffRateTotal = Math.Round(stock.ReturnScrapQty / stock.IssueQty * 100, 2).ToString() + "%"; * } * else * { * dNGRateManual = dNGRateFromItem = dWearOffRateTotal = "0%"; * } * string[] strArr = * new string[]{ stock.MOCode, * stock.ItemCode, * GetItemName(stock.ItemCode), * Math.Round(stock.ReceiptQty, 2).ToString(), * Math.Round(stock.IssueQty, 2).ToString(), * Math.Round(stock.ScrapQty, 2).ToString(), * Math.Round(stock.ReturnQty, 2).ToString(), * Math.Round(stock.ReturnScrapQty, 2).ToString(), * Math.Round(stock.ReceiptQty - stock.IssueQty - stock.ReturnQty - stock.ReturnScrapQty, 2).ToString(), * dNGRateManual, * dNGRateFromItem, * dWearOffRateTotal * }; * stock = null; * return strArr; */ MOStock stock = (MOStock)obj; string dNGRateManual, dNGRateFromItem, dWearOffRateTotal; string dMOWasteRate = "0%"; //工单损耗率 string dMOScrapRate = "0%";; //工单报废率 #region 工单损耗率,工单报废率 不显示不计算 // decimal wasteRate = 0; // decimal scrapRate = 0; // if(stock.MOLoadingQty !=0 && (stock.MOLoadingQty + stock.TSLoadingQty) != 0 ) // if(stock.MOStatus == BenQGuru.eMES.Web.Helper.MOManufactureStatus.MOSTATUS_CLOSE) // { // wasteRate = (stock.ScrapQty + stock.TSUnCompletedQty) / stock.MOLoadingQty; // scrapRate = (stock.ScrapQty + stock.TSUnCompletedQty) / (stock.MOLoadingQty + stock.TSLoadingQty); // } // else // { // wasteRate = stock.ScrapQty/ stock.MOLoadingQty; // scrapRate = stock.ScrapQty / (stock.MOLoadingQty + stock.TSLoadingQty); // } // if(wasteRate != 0) // { // dMOWasteRate = wasteRate.ToString("##.##%"); // } // if(scrapRate != 0) // { // dMOScrapRate = scrapRate.ToString("##.##%"); // } #endregion if (stock.IssueQty != 0) { dNGRateManual = Math.Round(stock.ScrapQty / stock.IssueQty * 100, 2).ToString() + "%"; dNGRateFromItem = Math.Round((stock.ReturnScrapQty - stock.ScrapQty) / stock.IssueQty * 100, 2).ToString() + "%"; dWearOffRateTotal = Math.Round(stock.ReturnScrapQty / stock.IssueQty * 100, 2).ToString() + "%"; } else { dNGRateManual = dNGRateFromItem = dWearOffRateTotal = "0%"; } // if (htMOList == null) { htMOList = new Hashtable(); } if (htMOList.Contains(stock.MOCode) == false) { if (moFacade == null) { moFacade = new BenQGuru.eMES.MOModel.MOFacade(this.DataProvider); } Domain.MOModel.MO mo = (Domain.MOModel.MO)moFacade.GetMO(stock.MOCode); if (sbomFacade == null) { sbomFacade = new BenQGuru.eMES.MOModel.SBOMFacade(this.DataProvider); } object[] objsBom = sbomFacade.Query(mo.ItemCode); object[] objValue = new object[] { mo, objsBom }; htMOList.Add(stock.MOCode, objValue); } object[] objMOValue = (object[])htMOList[stock.MOCode]; Domain.MOModel.MO moValue = (Domain.MOModel.MO)objMOValue[0]; string strMOQty = Convert.ToInt32(moValue.MOPlanQty).ToString(); object[] objMOBom = (object[])objMOValue[1]; string strMOMaterialQty = "0"; if (objMOBom != null) { for (int i = 0; i < objMOBom.Length; i++) { Domain.MOModel.SBOM sbom = (Domain.MOModel.SBOM)objMOBom[i]; if (sbom.SBOMItemCode == stock.ItemCode) { strMOMaterialQty = Math.Round(moValue.MOPlanQty * sbom.SBOMItemQty, 2).ToString(); break; } } } string strDiffMaterialQty = "0"; try { decimal dTmp = Convert.ToDecimal(strMOMaterialQty) - stock.ReceiptQty + stock.ReturnScrapQty + stock.ReturnQty; strDiffMaterialQty = Math.Round(dTmp, 2).ToString(); } catch {} string strMemoQty = this.GetMemoQty(stock.MOCode, stock.ItemCode); // string[] row = new string[] { stock.MOCode, stock.ItemCode, GetItemName(stock.ItemCode), strMOQty, strMOMaterialQty, Math.Round(stock.ReceiptQty, 2).ToString(), strDiffMaterialQty, Math.Round(stock.IssueQty, 2).ToString(), Math.Round(stock.ScrapQty, 2).ToString(), Math.Round(stock.ReturnQty, 2).ToString(), Math.Round(stock.ReturnScrapQty, 2).ToString(), Math.Round(stock.ReceiptQty - stock.IssueQty - stock.ReturnQty - stock.ReturnScrapQty, 2).ToString(), strMemoQty, "" }; stock = null; return(row); }