/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (LineCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, LineCode_lbl.Text); popUpMessage.Warning(messageData, Text); LineCode_txt.Focus(); return(false); } if (LineName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, LineName_lbl.Text); popUpMessage.Warning(messageData, Text); LineName_txt.Focus(); return(false); } return(true); }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { LineVo inVo = new LineVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (string.IsNullOrEmpty(LineCode_txt.Text) || string.IsNullOrEmpty(LineName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (string.IsNullOrEmpty(LineCode_txt.Text)) { LineCode_txt.Focus(); } else { LineName_txt.Focus(); } return; } inVo.LineCode = LineCode_txt.Text.Trim(); inVo.LineName = LineName_txt.Text.Trim(); //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; inVo.FactoryCode = UserData.GetUserData().FactoryCode; if (string.Equals(mode, CommonConstants.MODE_ADD)) { LineVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, LineCode_lbl.Text + " : " + LineCode_txt.Text); logger.Info(messageData); popUpMessage.ApplicationError(messageData, Text); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { LineVo outVo = (LineVo)base.InvokeCbm(new AddLineMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { inVo.LineId = updateData.LineId; LineVo outVo = (LineVo)base.InvokeCbm(new UpdateLineMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.Close(); } } }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void Ok_btn_Click(object sender, EventArgs e) { LineVo inVo = new LineVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(LineCode_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); LineCode_txt.Focus(); return; } inVo.LineCode = LineCode_txt.Text.Trim(); inVo.LineName = LineName_txt.Text.Trim(); //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; inVo.FactoryCode = UserData.GetUserData().FactoryCode; if (string.Equals(mode, CommonConstants.MODE_ADD)) { LineVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, LineCode_lbl.Text + " : " + LineCode_txt.Text); logger.Info(messageData); popUpMessage.ApplicationError(messageData, Text); return; } } ValueObjectList <ValueObject> inVoList = new ValueObjectList <ValueObject>(); try { this.StartProgress(Properties.Resources.mmci00009); if (string.Equals(mode, CommonConstants.MODE_ADD)) { inVoList.add(inVo); inVoList.add(GetSelectedProcessWork()); LineVo outVo = (LineVo)base.InvokeCbm(new AddLineMasterAndProcessworkCbm(), inVoList, false); IntSuccess = (outVo.LineId > 0) ? 1 : 0; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { inVo.LineId = updateData.LineId; inVoList.add(inVo); inVoList.add(GetSelectedProcessWork()); LineVo outVo = (LineVo)base.InvokeCbm(new UpdateLineMasterAndProcessworkCbm(), inVoList, false); IntSuccess = (outVo.AffectedCount > 0) ? 1 : 0; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } finally { this.CompleteProgress(); } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.Close(); } } }