/// <summary> /// load screen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddDefectiveCategoryForm_Load(object sender, EventArgs e) { DefectiveCategoryCode_txt.Select(); if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { LoadDefectiveCategoryData(updateData); DefectiveCategoryCode_txt.Enabled = false; DefectiveCategoryName_txt.Select(); } }
/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (DefectiveCategoryCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, DefectiveCategoryCode_lbl.Text); popUpMessage.Warning(messageData, Text); DefectiveCategoryCode_txt.Focus(); return(false); } if (DefectiveCategoryName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, DefectiveCategoryName_lbl.Text); popUpMessage.Warning(messageData, Text); DefectiveCategoryName_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) { DefectiveCategoryVo inVo = new DefectiveCategoryVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (string.IsNullOrEmpty(DefectiveCategoryCode_txt.Text) || string.IsNullOrEmpty(DefectiveCategoryName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (string.IsNullOrEmpty(DefectiveCategoryCode_txt.Text)) { DefectiveCategoryCode_txt.Focus(); } else { DefectiveCategoryName_txt.Focus(); } return; } inVo.DefectiveCategoryCode = DefectiveCategoryCode_txt.Text.Trim(); inVo.DefectiveCategoryName = DefectiveCategoryName_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)) { DefectiveCategoryVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, DefectiveCategoryCode_lbl.Text + " : " + DefectiveCategoryCode_txt.Text); logger.Info(messageData); popUpMessage.ApplicationError(messageData, Text); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { DefectiveCategoryVo outVo = (DefectiveCategoryVo)base.InvokeCbm(new AddDefectiveCategoryMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { inVo.DefectiveCategoryId = updateData.DefectiveCategoryId; DefectiveCategoryVo outVo = (DefectiveCategoryVo)base.InvokeCbm(new UpdateDefectiveCategoryMasterMntCbm(), 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> /// form load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DefectiveCategoryForm_Load(object sender, EventArgs e) { Update_btn.Enabled = Delete_btn.Enabled = false; DefectiveCategoryCode_txt.Select(); }