/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (EmployeeCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, EmployeeCode_lbl.Text); popUpMessage.Warning(messageData, Text); EmployeeCode_txt.Focus(); return(false); } if (EmployeeName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, EmployeeName_lbl.Text); popUpMessage.Warning(messageData, Text); EmployeeName_txt.Focus(); return(false); } if (Department_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Department_lbl.Text); popUpMessage.Warning(messageData, Text); Department_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) { EmployeeVo inVo = new EmployeeVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(EmployeeCode_txt.Text) || !sch.IsASCII(EmployeeName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(EmployeeCode_txt.Text)) { EmployeeCode_txt.Focus(); } else { EmployeeName_txt.Focus(); } return; } inVo.EmployeeCode = EmployeeCode_txt.Text.Trim(); inVo.EmployeeName = EmployeeName_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)) { EmployeeVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, EmployeeCode_lbl.Text + " : " + EmployeeCode_txt.Text); logger.Info(messageData); popUpMessage.ApplicationError(messageData, Text); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { EmployeeVo outVo = (EmployeeVo)base.InvokeCbm(new AddEmployeeMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { inVo.EmployeeCode = updateData.EmployeeCode; EmployeeVo outVo = (EmployeeVo)base.InvokeCbm(new UpdateEmployeeMasterMntCbm(), 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(); } } }