private void DoQuery() { if (m_TryLotNo != null) { this.m_TryLotNo.Rows.Clear(); this.m_TryLotNo.AcceptChanges(); } m_tryFacade = new TryFacade(this.DataProvider); object[] TryLotList = this.m_tryFacade.GetTryWithStatus(); if (TryLotList != null) { DataRow rowNew; foreach (TryAndItemDesc swv in TryLotList) { rowNew = this.m_TryLotNo.NewRow(); rowNew["Checked"] = false; rowNew["TryCode"] = swv.TryCode; rowNew["MCode"] = swv.ItemCode; rowNew["MDesc"] = swv.ItemDescription; rowNew["PlanQty"] = swv.PlanQty; rowNew["ActualQty"] = swv.ActualQty; rowNew["Memo"] = swv.Memo; this.m_TryLotNo.Rows.Add(rowNew); } this.m_TryLotNo.AcceptChanges(); } this.ultraGridTry.ActiveRow = null; }
protected override void DeleteDomainObjects(ArrayList domainObjects) { if (facade == null) { facade = new TryFacade(base.DataProvider); } this.DataProvider.BeginTransaction(); try { foreach (Try tryTemp in (Try[])domainObjects.ToArray(typeof(Try))) { if (tryTemp.Status != TryStatus.STATUS_INITIAL && tryTemp.Status != TryStatus.STATUS_RELEASE) { throw new Exception("$Current_TryCode:" + tryTemp.TryCode + ", $Current_Status:" + this.languageComponent1.GetString(tryTemp.Status)); } this.facade.DeleteTry(tryTemp); } this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); ExceptionManager.Raise(this.GetType(), "$Error_CanNotDeleteTryCode", ex); } }
protected override void UpdateDomainObject(object domainObject) { if (facade == null) { facade = new TryFacade(base.DataProvider); } this.facade.UpdateTry((Try)domainObject); }
protected override void AddDomainObject(object domainObject) { if (facade == null) { facade = new TryFacade(base.DataProvider); } this.facade.AddTRY((Try)domainObject); }
protected override int GetRowCount() { if (facade == null) { facade = new TryFacade(this.DataProvider); } return(this.facade.QueryTry2RcardByTryCodeCount( FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtTryCodeQuery.Text)))); }
protected override object[] LoadDataSource(int inclusive, int exclusive) { if (facade == null) { facade = new TryFacade(this.DataProvider); } return(facade.QueryTry2RcardByTryCode( FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtTryCodeQuery.Text)), inclusive, exclusive)); }
protected override object GetEditObject(GridRecord row) { if (facade == null) { facade = new TryFacade(base.DataProvider); } object obj = facade.GetTry(row.Items.FindItemByKey("TryCode").Text.ToString()); if (obj != null) { return((Try)obj); } return(null); }
protected override int GetRowCount() { if (facade == null) { facade = new TryFacade(base.DataProvider); } return(this.facade.QueryTryCount( FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtTryCodeQuery.Text)), this.drpTryStatusQuery.SelectedValue, FormatHelper.CleanString(this.txtMaterialCodeQuery.Text), FormatHelper.CleanString(this.txtDeptQuery.Text), FormatHelper.CleanString(this.txtVendorNameQuery.Text), FormatHelper.TODateInt(this.dateCreatDateQuery.Text), FormatHelper.CleanString(this.txtCreateUserQuery.Text.ToUpper()), this.drpTryTypeQuery.SelectedValue )); }
protected override object[] LoadDataSource(int inclusive, int exclusive) { if (facade == null) { facade = new TryFacade(base.DataProvider); } return(this.facade.QueryTry( FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtTryCodeQuery.Text.ToUpper())), this.drpTryStatusQuery.SelectedValue, FormatHelper.CleanString(this.txtMaterialCodeQuery.Text.ToUpper()), FormatHelper.CleanString(this.txtDeptQuery.Text.ToUpper()), FormatHelper.CleanString(this.txtVendorNameQuery.Text.ToUpper()), FormatHelper.TODateInt(this.dateCreatDateQuery.Text), FormatHelper.CleanString(this.txtCreateUserQuery.Text.ToUpper()), this.drpTryTypeQuery.SelectedValue, inclusive, exclusive)); }
//更新Grid private void UpdateGrid() { if (_TryFacade == null) { this._TryFacade = new TryFacade(this.DataProvider); } object[] TryListByCarton = this._TryFacade.QueryTryByRcard(_InputRcard); if (TryListByCarton != null) { this.BindGird(TryListByCarton); } else { dtCheckTry.Rows.Clear(); this.dtCheckTry.AcceptChanges(); } }
private OQCLot CreateNewLot(ActionEventArgs actionEventArgs, Item item, DBDateTime currentDBDateTime, bool forRework, string oldLotNo) { string lotNoMarkCode = forRework ? "R" : "L"; string lotType = forRework ? OQCLotType.OQCLotType_ReDO : OQCLotType.OQCLotType_Normal; string productionType = ""; decimal lotSize = 0; OQCFacade oqcFacade = new OQCFacade(DataProvider); TryFacade tryFacade = new TryFacade(this.DataProvider); OQCLot newOQCLot = null; OQCLot objLot = null; DateTime currentDateTime = FormatHelper.ToDateTime(currentDBDateTime.DBDate, currentDBDateTime.DBTime); object[] tryListOfRCard = null; object[] tryListOfOldLot = null; if (forRework) { OQCLot oldLot = oqcFacade.GetOQCLot(oldLotNo, OQCFacade.Lot_Sequence_Default) as OQCLot; productionType = oldLot.ProductionType; if (productionType == ProductionType.ProductionType_Try) { tryListOfRCard = tryFacade.GetTryListOfRCard(actionEventArgs.ProductInfo.NowSimulation.RunningCard, item.ItemCode); } //Lot Size lotSize = oldLot.LotCapacity; tryListOfOldLot = tryFacade.GetTryListOfLotNo(oldLot.LOTNO); } else { #region 先获取产品序列号对应的工单的productionType(来自于tblmo.momemo) // 先获取产品序列号对应的工单的productionType(来自于tblmo.momemo) MO mo = (new MOFacade(DataProvider)).GetMO(actionEventArgs.ProductInfo.NowSimulation.MOCode) as MO; SystemSettingFacade ssf = new SystemSettingFacade(this.DataProvider); Parameter param; param = ssf.GetParameter(mo.MOType, BenQGuru.eMES.Web.Helper.MOType.GroupType) as Parameter; if (param != null) { if (string.Compare(param.ParameterValue, BenQGuru.eMES.Web.Helper.MOType.MOTYPE_RMAREWORKMOTYPE, true) == 0) { productionType = ProductionType.ProductionType_Claim; } else { if (string.IsNullOrEmpty(mo.MOMemo)) { productionType = ProductionType.ProductionType_Mass; mo.MOMemo = MOProductType.MO_Product_Type_Mass.ToUpper(); } // 根据Memo获取ProductionType param = ssf.GetParameter(mo.MOMemo, MOProductType.GroupType) as Parameter; //changed by hiro 08/11/10 判断param不空进行比较 if (param != null) { if (string.Compare(param.ParameterValue, MOProductType.MO_Product_Type_New, true) == 0) { productionType = ProductionType.ProductionType_New; } else if (string.Compare(param.ParameterValue, MOProductType.MO_Product_Type_Mass, true) == 0) { productionType = ProductionType.ProductionType_Mass; } else { throw new Exception("$Error_MOMemoNotConfig $Domain_Parameter=" + mo.MOMemo); } tryListOfRCard = tryFacade.GetTryListOfRCard(actionEventArgs.ProductInfo.NowSimulation.RunningCard, item.ItemCode); if (tryListOfRCard != null && tryListOfRCard.Length > 0) { productionType = ProductionType.ProductionType_Try; } } else { throw new Exception("$CS_System_Params_Losted $Domain_ParameterGroup='" + MOProductType.GroupType + "' $Domain_Parameter=" + mo.MOMemo); } } } else { throw new Exception("$CS_System_Params_Losted $Domain_ParameterGroup='" + BenQGuru.eMES.Web.Helper.MOType.GroupType + "' $Domain_Parameter=" + mo.MOType); } #endregion } #region 获取ShiftDay和ShiftCode BaseSetting.BaseModelFacade dataModel = new BaseSetting.BaseModelFacade(this.DataProvider); Domain.BaseSetting.Resource res = (Domain.BaseSetting.Resource)dataModel.GetResource(actionEventArgs.ResourceCode); int shiftDay = 0; string shiftCode = string.Empty; BaseSetting.ShiftModelFacade shiftModel = new BaseSetting.ShiftModelFacade(this.DataProvider); Domain.BaseSetting.TimePeriod period = (Domain.BaseSetting.TimePeriod)shiftModel.GetTimePeriod(res.ShiftTypeCode, currentDBDateTime.DBTime); if (period == null) { throw new Exception("$OutOfPerid"); } shiftCode = period.ShiftCode; if (period.IsOverDate == Web.Helper.FormatHelper.TRUE_STRING) { if (period.TimePeriodBeginTime < period.TimePeriodEndTime) { shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1)); } else if (Web.Helper.FormatHelper.TOTimeInt(currentDateTime) < period.TimePeriodBeginTime) { shiftDay = FormatHelper.TODateInt(currentDateTime.AddDays(-1)); } else { shiftDay = FormatHelper.TODateInt(currentDateTime); } } else { shiftDay = FormatHelper.TODateInt(currentDateTime); } #endregion bool needCreateNewLot = false; bool needAddLotTryCode = false; // 获取Lot的主逻辑 if (productionType == ProductionType.ProductionType_Try) //试流批 { object[] lotList = oqcFacade.GetLotList4TryCase(item.ItemCode, res.StepSequenceCode, lotType, productionType, lotNoMarkCode); if (lotList == null || lotList.Length == 0) // 找不到对应的任何试流批,则新建试流批 { needCreateNewLot = true; needAddLotTryCode = true; } else // 找到多个,则遍历每一个,找其中试流批与RCard完全一致的批,若没有则新建试流批 { object[] tryListOfLot; foreach (OQCLot lotTemp in lotList) { tryListOfLot = tryFacade.GetTryListOfLotNo(lotTemp.LOTNO); if (tryListOfRCard != null && tryListOfRCard.Length != 0 && tryListOfLot != null && tryListOfLot.Length != 0 && this.CompareTryCodeList(tryListOfRCard, tryListOfLot) == true) { newOQCLot = oqcFacade.GetOQCLot(lotTemp.LOTNO, lotTemp.LotSequence) as OQCLot; break; } } if (newOQCLot == null) { needCreateNewLot = true; needAddLotTryCode = true; } } } else //新品批或量产批或理赔批 { objLot = oqcFacade.GetMaxLot4NormalCase(item.ItemCode, res.StepSequenceCode, lotType, productionType, lotNoMarkCode); if (objLot == null || objLot.LOTNO == null || objLot.LOTNO == string.Empty) { needCreateNewLot = true; needAddLotTryCode = false; } else { newOQCLot = oqcFacade.GetOQCLot(objLot.LOTNO, OQCFacade.Lot_Sequence_Default) as OQCLot; } } // Added By Hi1/Venus.Feng on 20081128 for Hisense Version // 增加了ForRework的这个条件 // 如果是Rework,都应该产生新的批,因为调用该函数之前,就已经by老的lot获取新的lot了,但是没有获取到 // 才会跑到该函数中,所以在该函数中对于Rework的Case,都应该产生新的批 // End Added if (needCreateNewLot || forRework) { newOQCLot = oqcFacade.CreateNewOQCLot(); objLot = oqcFacade.GetMaxLot(res.StepSequenceCode, shiftDay, lotNoMarkCode); if (objLot == null || objLot.LOTNO == null || objLot.LOTNO == string.Empty) { newOQCLot.LOTNO = res.StepSequenceCode + shiftDay.ToString() + lotNoMarkCode + "001"; } else { string oldLotNO = objLot.LOTNO; string newSequence = Convert.ToString((int.Parse(oldLotNO.Substring(oldLotNO.Length - 3, 3)) + 1)); newOQCLot.LOTNO = oldLotNO.Substring(0, oldLotNO.Length - 3) + newSequence.PadLeft(3, '0'); } // Create New OQC Lot if (forRework) { newOQCLot = oqcFacade.CreateNewOQCLot(newOQCLot.LOTNO, actionEventArgs.UserCode, currentDBDateTime, res.OrganizationID, lotSize, res.StepSequenceCode, item.ItemCode, oldLotNo, lotType, productionType, res.ResourceCode, shiftDay, shiftCode); } else { newOQCLot = oqcFacade.CreateNewOQCLot(newOQCLot.LOTNO, actionEventArgs.UserCode, currentDBDateTime, res.OrganizationID, item.LotSize, res.StepSequenceCode, item.ItemCode, oldLotNo, lotType, productionType, res.ResourceCode, shiftDay, shiftCode); } oqcFacade.AddOQCLot(newOQCLot); if (needAddLotTryCode || forRework) { Try2Lot try2Lot = null; if (forRework) { if (tryListOfOldLot != null && tryListOfOldLot.Length > 0) { foreach (Try tempTry in tryListOfOldLot) { try2Lot = tryFacade.CreateNewTry2Lot(); try2Lot.EAttribute1 = ""; try2Lot.LotNo = newOQCLot.LOTNO; try2Lot.MaintainDate = currentDBDateTime.DBDate; try2Lot.MaintainTime = currentDBDateTime.DBTime; try2Lot.MaintainUser = actionEventArgs.UserCode; try2Lot.TryCode = tempTry.TryCode; tryFacade.AddTry2Lot(try2Lot); } } } else { foreach (Try tempTry in tryListOfRCard) { try2Lot = tryFacade.CreateNewTry2Lot(); try2Lot.EAttribute1 = ""; try2Lot.LotNo = newOQCLot.LOTNO; try2Lot.MaintainDate = currentDBDateTime.DBDate; try2Lot.MaintainTime = currentDBDateTime.DBTime; try2Lot.MaintainUser = actionEventArgs.UserCode; try2Lot.TryCode = tempTry.TryCode; tryFacade.AddTry2Lot(try2Lot); } } } } return(newOQCLot); }
protected override object GetEditObject() { if (facade == null) { facade = new TryFacade(base.DataProvider); } Try tryObj = null; DBDateTime dateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); if (this.txtTryCodeEdit.ReadOnly) { tryObj = this.facade.GetTry(FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtTryCodeEdit.Text, 40))) as Try; } else { tryObj = this.facade.CreateNewTry(); tryObj.TryCode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtTryCodeEdit.Text, 40)); tryObj.Status = TryStatus.STATUS_INITIAL; tryObj.CreateUser = this.GetUserCode(); tryObj.CreateDate = dateTime.DBDate; tryObj.CreateTime = dateTime.DBTime; tryObj.ActualQty = 0; } tryObj.MaintainUser = this.GetUserCode(); tryObj.MaintainDate = dateTime.DBDate; tryObj.MaintainTime = dateTime.DBTime; tryObj.ItemCode = this.txtMaterialCodeEdit.Text; tryObj.Department = this.txtDeptEdit.Text; string planqty = FormatHelper.CleanString(this.txtPlanQtyEdit.Text); if (planqty != null && planqty.Length != 0) { tryObj.PlanQty = int.Parse(planqty); } else { tryObj.PlanQty = 0; } if (this.chbGenerateLot.Checked) { tryObj.LinkLot = "Y"; } else { tryObj.LinkLot = "N"; } tryObj.VendorName = FormatHelper.CleanString(this.txtVendorNameEdit.Text); //tryObj.TryDocument = FormatHelper.CleanString(this.fileInit.Value); tryObj.TryDocument = ""; tryObj.Memo = FormatHelper.CleanString(this.txtMemoEdit.Text); tryObj.Result = FormatHelper.CleanString(this.txtResultEdit.Text); tryObj.TryType = this.drpTryTypeEdit.SelectedValue; tryObj.TryReason = FormatHelper.CleanString(this.txtTryReasonEdit.Text); tryObj.SoftVersion = FormatHelper.CleanString(this.txtSoftWareVersionEdit.Text); tryObj.WaitTry = drpLotWaitReslutEdit.SelectedValue; tryObj.Change = drpBothChangedEdit.SelectedValue; tryObj.BurnINDuration = FormatHelper.CleanString(this.txtAgingDateEdit.Text); return(tryObj); }
private void SetTryStatus(string newStatus) { if (facade == null) { facade = new TryFacade(this.DataProvider); } ArrayList array = this.gridHelper.GetCheckedRows(); if (array.Count > 0) { ArrayList objs = new ArrayList(array.Count); DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); try { foreach (GridRecord row in array) { object obj = this.GetEditObject(row); Try tryObj = null; if (obj != null) { tryObj = this.facade.GetTry(((Try)obj).TryCode) as Try; string status = tryObj.Status; if (newStatus == TryStatus.STATUS_RELEASE) //release button { if (status == TryStatus.STATUS_INITIAL) { tryObj.Status = TryStatus.STATUS_RELEASE; tryObj.ReleaseUser = this.GetUserCode(); tryObj.ReleaseDate = currentDateTime.DBDate; tryObj.ReleaseTime = currentDateTime.DBTime; } else { throw new Exception(string.Format("$Current_TryCode:{0} $Current_Status: {1}", tryObj.TryCode, this.languageComponent1.GetString(status))); } } if (newStatus == TryStatus.STATUS_PAUSE) //pause button { if (status == TryStatus.STATUS_PRODUCE) { tryObj.Status = TryStatus.STATUS_PAUSE; } else { throw new Exception(string.Format("$Current_TryCode:{0} $Current_Status: {1}", tryObj.TryCode, this.languageComponent1.GetString(status))); } } if (newStatus == TryStatus.STATUS_INITIAL) //cancle release button { if (status == TryStatus.STATUS_RELEASE) { tryObj.Status = TryStatus.STATUS_INITIAL; tryObj.ReleaseDate = 0; tryObj.ReleaseTime = 0; tryObj.ReleaseUser = ""; } else { throw new Exception(string.Format("$Current_TryCode:{0} $Current_Status: {1}", tryObj.TryCode, this.languageComponent1.GetString(status))); } } if (newStatus == TryStatus.STATUS_PRODUCE) //cancle pend button { if (status == TryStatus.STATUS_PAUSE) { tryObj.Status = TryStatus.STATUS_PRODUCE; } else { throw new Exception(string.Format("$Current_TryCode:{0} $Current_Status: {1}", tryObj.TryCode, this.languageComponent1.GetString(status))); } } if (newStatus == TryStatus.STATUS_FINISH) //close button { if (status != TryStatus.STATUS_FINISH) { tryObj.Status = TryStatus.STATUS_FINISH; tryObj.FinishDate = currentDateTime.DBDate; tryObj.FinishTime = currentDateTime.DBTime; tryObj.FinishUser = this.GetUserCode(); } else { throw new Exception(string.Format("$Current_TryCode:{0} $Current_Status: {1}", tryObj.TryCode, this.languageComponent1.GetString(status))); } } objs.Add(tryObj); } } this.facade.TryStatusChanged((Try[])objs.ToArray(typeof(Try))); this.RequestData(); } catch (Exception ex) { ExceptionManager.Raise(this.GetType(), "$Error_TryStatusChanged", ex); } } }
protected override void Grid_ClickCellButton(GridRecord row, string commandName) { // base.Grid_ClickCellButton(sender, e); SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider); UserFacade userFacade = new UserFacade(this.DataProvider); if (commandName == "Download") { string tryCode = row.Items.FindItemByKey("TryCode").Value.ToString(); if (facade == null) { facade = new TryFacade(base.DataProvider); } object trySelected = facade.GetTry(tryCode); if (trySelected == null) { ExceptionManager.Raise(this.GetType(), "试流单不存在"); } Try selectedTry = trySelected as Try; string originalFilePath = this.Request.PhysicalApplicationPath + @"download\TryCode.htm"; if (!File.Exists(originalFilePath)) { ExceptionManager.Raise(this.GetType(), "文件[TryCode.htm]不存在"); } //获取Deparment Name string deparmentCode = selectedTry.Department; string deparmentName = " "; if (deparmentCode.Trim().Length > 0) { Domain.BaseSetting.Parameter department = (Domain.BaseSetting.Parameter)systemSettingFacade.GetParameter(selectedTry.Department, "DEPARTMENT"); if (department != null) { deparmentName = department.ParameterAlias; } } //获取Create User Name string createUserCode = selectedTry.CreateUser; string createUserName = "******"; if (createUserCode.Trim().Length > 0) { User createUser = (User)userFacade.GetUser(createUserCode); if (createUser != null) { createUserName = createUser.UserName; } } string fileContent = File.ReadAllText(originalFilePath, Encoding.GetEncoding("GB2312")); fileContent = fileContent.Replace("$$TryCode$$", selectedTry.TryCode); fileContent = fileContent.Replace("$$Department$$", deparmentName); fileContent = fileContent.Replace("$$CreateUser$$", createUserName); fileContent = fileContent.Replace("$$ReleaseDate$$", selectedTry.ReleaseDate == 0 ? " " : FormatHelper.ToDateString(selectedTry.ReleaseDate, "/")); //fileContent = fileContent.Replace("$$ReleaseDate$$", selectedTry.ReleaseDate == 0 ? " " : selectedTry.ReleaseDate.ToString()); fileContent = fileContent.Replace("$$MaterialCode$$", selectedTry.ItemCode == "" ? " " : selectedTry.ItemCode); fileContent = fileContent.Replace("$$MaterialDescription$$", row.Items.FindItemByKey("Dept").Value.ToString() == "" ? " " : row.Items.FindItemByKey("Dept").Value.ToString()); fileContent = fileContent.Replace("$$PlanQuantity$$", selectedTry.PlanQty.ToString()); fileContent = fileContent.Replace("$$VendorCode$$", selectedTry.VendorName == "" ? " " : selectedTry.VendorName); fileContent = fileContent.Replace("$$Result$$", selectedTry.Result == "" ? " " : selectedTry.Result); fileContent = fileContent.Replace("$$Memo$$", selectedTry.Memo == "" ? " " : selectedTry.Memo); //fileContent = fileContent.Replace("$$PrintDateTime$$", DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss", new System.Globalization.CultureInfo("en-US"))); fileContent = fileContent.Replace("$$TryType$$", selectedTry.TryType.Trim() == "" ? " " : this.languageComponent1.GetString(selectedTry.TryType)); fileContent = fileContent.Replace("$$TryReason$$", selectedTry.TryReason == "" ? " " : selectedTry.TryReason); fileContent = fileContent.Replace("$$SoftVersion$$", selectedTry.SoftVersion == "" ? " " : selectedTry.SoftVersion); fileContent = fileContent.Replace("$$WaitTry$$", selectedTry.WaitTry == "" ? " " : this.languageComponent1.GetString(selectedTry.WaitTry)); fileContent = fileContent.Replace("$$Change$$", selectedTry.Change == "" ? " " : this.languageComponent1.GetString(selectedTry.Change)); fileContent = fileContent.Replace("$$BurnINDuration$$", selectedTry.BurnINDuration == "" ? " " : selectedTry.BurnINDuration); string downloadPhysicalPath = this.Request.PhysicalApplicationPath + @"upload\"; if (!Directory.Exists(downloadPhysicalPath)) { Directory.CreateDirectory(downloadPhysicalPath); } string filename = string.Format("{0}_{1}_{2}", row.Items.FindItemByKey("TryCode").Value.ToString(), FormatHelper.TODateInt(System.DateTime.Now).ToString(), FormatHelper.TOTimeInt(System.DateTime.Now).ToString()); string filepath = string.Format(@"{0}{1}{2}", downloadPhysicalPath, filename, ".xls"); while (File.Exists(filepath)) { filename = string.Format("{0}_{1}", filename, "0"); filepath = string.Format(@"{0}{1}{2}", downloadPhysicalPath, filename, ".xls"); } StreamWriter writer = new StreamWriter(filepath, false, System.Text.Encoding.GetEncoding("GB2312")); writer.Write(fileContent); writer.Flush(); writer.Close(); this.DownloadFile(filename); } }
//查询并Load数据 private void QueryDataAndBind() { if (_TryFacade == null) { this._TryFacade = new TryFacade(this.DataProvider); } switch (this.opsetOffTry.Value.ToString()) { case Carton: if (string.IsNullOrEmpty(this.txtInPutSN.Value)) { this.txtInPutSN.TextFocus(false, true); return; } DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider); object objectSimulationReport = dataCollectFacade.GetRCardByCartonCode(this.txtInPutSN.Value.Trim().ToUpper()); if (objectSimulationReport == null) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_ProductInfo_IS_Null")); this.txtInPutSN.TextFocus(false, true); return; } _InputRcard = ((SimulationReport)objectSimulationReport).RunningCard; object[] TryListByCarton = this._TryFacade.QueryTryByRcard(_InputRcard); if (TryListByCarton != null) { this.BindGird(TryListByCarton); } else { dtCheckTry.Rows.Clear(); this.dtCheckTry.AcceptChanges(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_RCARD_HAVE_NO_TRY")); this.txtInPutSN.TextFocus(false, true); return; } break; case Rcard: if (string.IsNullOrEmpty(this.txtInPutSN.Value)) { this.txtInPutSN.TextFocus(false, true); return; } _InputRcard = this.txtInPutSN.Value.Trim().ToUpper(); //根据当前序列号获取对应的原始的序列号 dataCollectFacade = new DataCollectFacade(this.DataProvider); sourceRCard = dataCollectFacade.GetSourceCard(_InputRcard.Trim().ToUpper(), string.Empty); object[] TryListByRcard = this._TryFacade.QueryTryByRcard(FormatHelper.CleanString(sourceRCard.Trim().ToUpper())); if (TryListByRcard != null) { this.BindGird(TryListByRcard); } else { dtCheckTry.Rows.Clear(); this.dtCheckTry.AcceptChanges(); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_RCARD_HAVE_NO_TRY")); this.txtInPutSN.TextFocus(false, true); return; } break; } }
public Messages Execute(ActionEventArgs actionEventArgs) { Messages messages = new Messages(); DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect"); TryEventArgs tryEventArgs = actionEventArgs as TryEventArgs; DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); int date = dbDateTime.DBDate; int time = dbDateTime.DBTime; string userCode = tryEventArgs.UserCode; string tryCode = tryEventArgs.TryCode.Trim().ToUpper(); string mItemCode = tryEventArgs.MItemCode.Trim().ToUpper(); string mCard = tryEventArgs.MRunningCard.Trim().ToUpper(); string itemCode = tryEventArgs.ItemCode.Trim().ToUpper(); string rCard = tryEventArgs.RunningCard.Trim().ToUpper(); dataCollectDebug.WhenFunctionIn(messages); try { TryFacade tryFacade = new TryFacade(this.DataProvider); //用于上料或者carton采集 if (tryEventArgs.ForCollect) { if (string.IsNullOrEmpty(tryEventArgs.MRunningCard)) { List <string> TryCodeList = new List <string>(); if (tryEventArgs.TryCode.Trim().Length > 0) { if (tryEventArgs.TryCode.IndexOf(",") >= 0) { string[] TryCode = tryEventArgs.TryCode.Split(','); for (int i = 0; i < TryCode.Length; i++) { TryCodeList.Add(TryCode[i]); } } else { TryCodeList.Add(tryEventArgs.TryCode.Trim()); } for (int i = 0; i < TryCodeList.Count; i++) { string TryCode = TryCodeList[i].ToString().Trim().ToUpper(); Try2RCard try2RCard = (Try2RCard)tryFacade.GetTry2RCard(TryCode, tryEventArgs.RunningCard, tryEventArgs.ItemCode); if (try2RCard == null) { try2RCard = tryFacade.CreateNewTry2RCard(); try2RCard.TryCode = TryCode; try2RCard.RCard = tryEventArgs.RunningCard; try2RCard.ItemCode = tryEventArgs.ItemCode; try2RCard.OPCode = tryEventArgs.OPCode; try2RCard.MaintainDate = date; try2RCard.MaintainTime = time; try2RCard.MaintainUser = userCode; try2RCard.EAttribute1 = " "; tryFacade.AddTry2RCard(try2RCard); object objectTry = tryFacade.GetTry(TryCode); if (objectTry != null) { ((Try)objectTry).ActualQty += 1; ((Try)objectTry).Status = TryStatus.STATUS_PRODUCE; ((Try)objectTry).MaintainDate = date; ((Try)objectTry).MaintainTime = time; ((Try)objectTry).MaintainUser = userCode; if (tryEventArgs.ForLinkLot) { ((Try)objectTry).LinkLot = "Y"; } else { if (((Try)objectTry).LinkLot != "Y") { ((Try)objectTry).LinkLot = "N"; } } if (string.IsNullOrEmpty(((Try)objectTry).LinkLot)) { ((Try)objectTry).LinkLot = "N"; } tryFacade.UpdateTry((Try)objectTry); } } } } } else { object[] try2RCardList = tryFacade.QueryTry2RCard(tryCode, mCard, mItemCode); if (try2RCardList != null) { foreach (Try2RCard try2RCard in try2RCardList) { Try2RCard try2RCardParent = (Try2RCard)tryFacade.GetTry2RCard(try2RCard.TryCode, rCard, itemCode); if (try2RCardParent == null) { try2RCardParent = tryFacade.CreateNewTry2RCard(); try2RCardParent.TryCode = try2RCard.TryCode; try2RCardParent.RCard = rCard; try2RCardParent.ItemCode = itemCode; try2RCardParent.OPCode = tryEventArgs.OPCode; try2RCardParent.MaintainDate = date; try2RCardParent.MaintainTime = time; try2RCardParent.MaintainUser = userCode; try2RCardParent.EAttribute1 = " "; tryFacade.AddTry2RCard(try2RCardParent); object objectTry = tryFacade.GetTry(try2RCard.TryCode); if (objectTry != null) { //((Try)objectTry).ActualQty += 1; ////((Try)objectTry).Status = TryStatus.STATUS_PRODUCE; //((Try)objectTry).MaintainDate = date; //((Try)objectTry).MaintainTime = time; //((Try)objectTry).MaintainUser = userCode; ////隐形的LINKLOT不改变 changed by hiro 2009/01/19 ////if (tryEventArgs.ForLinkLot) ////{ //// ((Try)objectTry).LinkLot = "Y"; ////} ////else ////{ //// if (((Try)objectTry).LinkLot != "Y") //// { //// ((Try)objectTry).LinkLot = "N"; //// } ////} ////if (string.IsNullOrEmpty(((Try)objectTry).LinkLot)) ////{ //// ((Try)objectTry).LinkLot = "N"; ////} //tryFacade.UpdateTry((Try)objectTry); } } } } } } //用于拆解 else { object[] try2RCardList = tryFacade.QueryTry2RCard(tryCode, mCard, mItemCode); if (try2RCardList != null) { foreach (Try2RCard try2RCard in try2RCardList) { Try2RCard try2RCardParent = (Try2RCard)tryFacade.GetTry2RCard(try2RCard.TryCode, rCard, itemCode); if (try2RCardParent != null) { Try objectTry = (Try)tryFacade.GetTry(try2RCard.TryCode); if (objectTry != null) { objectTry.ActualQty -= 1; objectTry.MaintainDate = date; objectTry.MaintainTime = time; objectTry.MaintainUser = userCode; tryFacade.UpdateTry(objectTry); } tryFacade.DeleteTry2RCard(try2RCardParent); } } } } } catch (Exception e) { messages.Add(new Message(e)); } dataCollectDebug.WhenFunctionOut(messages); return(messages); }