/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (MachineCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MachineCode_lbl.Text); popUpMessage.Warning(messageData, Text); MachineCode_txt.Focus(); return(false); } if (MachineName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MachineName_lbl.Text); popUpMessage.Warning(messageData, Text); MachineName_txt.Focus(); return(false); } return(true); }
/// <summary> /// inserts/updates process on ok click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (string.IsNullOrEmpty(MachineCode_txt.Text) || string.IsNullOrEmpty(MachineName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (string.IsNullOrEmpty(MachineCode_txt.Text)) { MachineCode_txt.Focus(); } else { MachineName_txt.Focus(); } return; } MachineVo inVo = new MachineVo { MachineCode = MachineCode_txt.Text.Trim(), MachineName = MachineName_txt.Text.Trim(), //RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), RegistrationUserCode = UserData.GetUserData().UserCode, FactoryCode = UserData.GetUserData().FactoryCode }; if (string.Equals(mode, CommonConstants.MODE_ADD)) { MachineVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, MachineCode_lbl.Text + " : " + MachineCode_txt.Text); logger.Info(messageData); popUpMessage.ApplicationError(messageData, Text); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { MachineVo outVo = (MachineVo)base.InvokeCbm(new AddMachineMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.MachineId = updateData.MachineId; MachineVo outVo = (MachineVo)base.InvokeCbm(new UpdateMachineMasterMntCbm(), 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(); } } }