private object CheckRpeat(object obj, string type) { if (obj == null) { return(null); } switch (type) { case "Model2Item": BenQGuru.eMES.Domain.MOModel.Model2Item model2item = obj as BenQGuru.eMES.Domain.MOModel.Model2Item; ModelFacade modelfacade = new ModelFacade(this.MESProvider); return(modelfacade.GetModel2ItemByItemCode(model2item.ItemCode)); case "Item": BenQGuru.eMES.Domain.MOModel.Item item = obj as BenQGuru.eMES.Domain.MOModel.Item; ItemFacade itemfacade = new ItemFacade(this.MESProvider); return(itemfacade.GetItem(item.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID)); case "MO": BenQGuru.eMES.Domain.MOModel.MO mo = obj as BenQGuru.eMES.Domain.MOModel.MO; MOFacade mofacade = new MOFacade(this.MESProvider); return(mofacade.GetMO(mo.MOCode)); default: return(null); } }
/// <summary> /// 根据工单把产品,产品别信息取出来 /// </summary> private void txtMoCode_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == '\r') { string mocode = this.txtMoCode.Text.Trim().ToUpper(); if (mocode.Length == 0) { return; } BenQGuru.eMES.MOModel.MOFacade facade = new MOFacade(this.DataProvider); BenQGuru.eMES.Domain.MOModel.MO mo = facade.GetMO(mocode) as BenQGuru.eMES.Domain.MOModel.MO; if (mo == null || mo.MOCode == null) { ErrorMsg("$CS_MO_Not_Exist"); this.txtMoCode.Focus(); return; } BenQGuru.eMES.MOModel.ModelFacade modelfacade = new ModelFacade(this.DataProvider); BenQGuru.eMES.Domain.MOModel.Model model = modelfacade.GetModelByItemCode(mo.ItemCode) as BenQGuru.eMES.Domain.MOModel.Model; if (model == null) { ErrorMsg("$CS_Model_Lost"); return; } BenQGuru.eMES.MOModel.ItemFacade itemfacade = new ItemFacade(this.DataProvider); BenQGuru.eMES.Domain.MOModel.Item item = itemfacade.GetItem(mo.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as BenQGuru.eMES.Domain.MOModel.Item; if (item == null) { ErrorMsg("$Error_ItemCode_NotExist"); return; } this.cbxModel.SetSelectItem(model.ModelCode); this.cbxItemCode.SetSelectItem(mo.ItemCode); this.txtItemDesc.Value = item.ItemDescription; this.txtNum.Focus(); } }
private void btnConfirm_Click(object sender, System.EventArgs e) { try { this.Cursor = System.Windows.Forms.Cursors.WaitCursor; Messages msg = new Messages(); if (this.txtAlertMsg.InnerTextBox.Text.Trim() == string.Empty) { msg.Add(new UserControl.Message(MessageType.Error, this.txtAlertMsg.Caption + " $Error_Input_Empty")); ApplicationRun.GetInfoForm().Add(msg); return; } if (this.txtMOCode.InnerTextBox.Text.Trim() == string.Empty) { msg.Add(new UserControl.Message(MessageType.Error, this.txtMOCode.Caption + " $Error_Input_Empty")); ApplicationRun.GetInfoForm().Add(msg); this.txtMOCode.TextFocus(false, true); return; } //根据工单得到产品代码 BenQGuru.eMES.MOModel.MOFacade moFacade = new MOFacade(this.DataProvider); BenQGuru.eMES.Domain.MOModel.MO mo = moFacade.GetMO(this.txtMOCode.InnerTextBox.Text.Trim()) as BenQGuru.eMES.Domain.MOModel.MO; string productcode; if (mo != null) { productcode = mo.ItemCode; } else { msg.Add(new UserControl.Message(MessageType.Error, "$ManualAlert_MOCode_Error")); //工单号码输入错误 ApplicationRun.GetInfoForm().Add(msg); this.txtMOCode.TextFocus(false, true); return; } try { DataProvider.BeginTransaction(); BenQGuru.eMES.AlertModel.AlertFacade facade = new BenQGuru.eMES.AlertModel.AlertFacade(DataProvider); BenQGuru.eMES.Domain.Alert.Alert alert = facade.CreateNewAlert(); alert.ItemCode = string.Empty; alert.AlertItem = string.Empty; alert.AlertStatus = BenQGuru.eMES.AlertModel.AlertStatus_Old.Unhandled; alert.AlertType = BenQGuru.eMES.AlertModel.AlertType_Old.Manual; //Laws Lu,2006/11/13 uniform system collect date DBDateTime dbDateTime; dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider); alert.MaintainDate = dbDateTime.DBDate; alert.MaintainUser = ApplicationService.Current().UserCode; alert.MaintainTime = dbDateTime.DBTime; alert.AlertLevel = this._levelDict[this.cbAlertLevel.ComboBoxData.SelectedItem.ToString()]; alert.AlertMsg = ApplicationService.Current().ResourceCode + ":" + this.txtAlertMsg.InnerTextBox.Text; alert.Description = string.Empty; alert.MailNotify = "N"; alert.AlertValue = 0; alert.ProductCode = productcode; //单得到产线代码 BenQGuru.eMES.BaseSetting.BaseModelFacade baseFacade = new BenQGuru.eMES.BaseSetting.BaseModelFacade(this.DataProvider); Resource res = baseFacade.GetResource(ApplicationService.Current().ResourceCode) as Resource; if (res != null) { alert.SSCode = res.StepSequenceCode; } alert.AlertMsg = this.txtAlertMsg.InnerTextBox.Text + "," + "产品: " + alert.ProductCode + ", 资源: " + ApplicationService.Current().ResourceCode; facade.AddAlert(alert); DataProvider.CommitTransaction(); msg.Add(new UserControl.Message(MessageType.Success, "$ManualAlert_Add_Success")); ApplicationRun.GetInfoForm().Add(msg); this.txtAlertMsg.InnerTextBox.Text = string.Empty; //刷新Sample //RefreshSample(); } catch (System.Exception ex) { DataProvider.RollbackTransaction(); msg.Add(new UserControl.Message(MessageType.Error, ex.Message)); ApplicationRun.GetInfoForm().Add(msg); } } finally { this.Cursor = System.Windows.Forms.Cursors.Default; this.CloseConnection(); } }
private void btnAdd_Click(object sender, System.EventArgs e) { try { this.Cursor = System.Windows.Forms.Cursors.WaitCursor; if (!this.InputValid()) { return; } if (this._nowRecNo != this.txtRecNo.Text) { this.LoadData(); } try { InventoryFacade _facade = new InventoryFacade(this.DataProvider); //检查状态,初始状态才能添加 string status = _facade.GetInvReceiveStatus(this.txtRecNo.Text.Trim()); if (status != null && status != ReceiveStatus.Receiving) { ErrorMsg("$CS_Inv_Rec_Init_Only"); //只有初始状态的入库单状态才可以添加明细 return; } //检查是不已经存在 if (_facade.InvReceiveExistByMoItem(this.txtRecNo.Text.Trim(), this.txtMoCode.Text.ToUpper().Trim(), this.cbxItemCode.SelectedItemValue.ToString())) { ErrorMsg("$CS_Inv_Detail_Exist"); //明细资料已经存在于入库单中了 return; } InvReceive rec = new InvReceive(); rec.Description = this.txtDesc.InnerTextBox.Text.Trim(); rec.InnerType = ReceiveInnerType.Normal; rec.RecType = this.cbxType.ComboBoxData.SelectedItem.ToString(); rec.ItemCode = this.cbxItemCode.ComboBoxData.SelectedItem.ToString(); rec.ItemDesc = this.txtItemDesc.InnerTextBox.Text.Trim(); rec.ModelCode = this.cbxModel.ComboBoxData.SelectedItem.ToString(); rec.PlanQty = int.Parse(this.txtNum.Text); rec.RecNo = this.txtRecNo.Text.Trim().ToUpper(); rec.MaintainUser = ApplicationService.Current().UserCode; rec.MoCode = this.txtMoCode.Text.ToUpper().Trim(); //判断工单的产品代码和用户选的是否相同 if (this.txtMoCode.Text.ToUpper().Trim() != string.Empty) { BenQGuru.eMES.MOModel.MOFacade mofacade = new MOFacade(this.DataProvider); BenQGuru.eMES.Domain.MOModel.MO mo = mofacade.GetMO(rec.MoCode) as BenQGuru.eMES.Domain.MOModel.MO; if (mo == null) { ErrorMsg("$CS_MO_Not_Exist"); return; } if (mo.ItemCode != rec.ItemCode) { ErrorMsg("$Error_ItemCode_NotCompare"); return; } } this.DataProvider.BeginTransaction(); _facade.AddInvReceive(rec); //加界面显示 this.AddDataRow(rec); this.DataProvider.CommitTransaction(); this.SucessMsg("$CS_Add_Success"); this.ClearInput(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); this.ErrorMsg(ex.Message); } //入库单号发生变化,根据新的入库单号,Load入库单数据 if (this._nowRecNo != null && this._nowRecNo != this.txtRecNo.Text.Trim()) { LoadData(); } } finally { this.Cursor = System.Windows.Forms.Cursors.Default; CloseConnection(); } }