/// <summary> /// Constructor for the form /// </summary> /// <param name="pmode"></param> /// <param name="userItem"></param> //public AddBuldingForm(string pmode, MoldCategoryVo userItem = null) //{ // InitializeComponent(); // mode = pmode; // updateData = userItem; // if (string.Equals(mode, CommonConstants.MODE_UPDATE)) // { // this.Text = UpdateText_lbl.Text; // } //} #endregion #region PrivateMethods /// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (MoldCategoryCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MoldCategoryCode_lbl.Text); popUpMessage.Warning(messageData, Text); MoldCategoryCode_txt.Focus(); return(false); } if (MoldCategoryName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MoldCategoryName_lbl.Text); popUpMessage.Warning(messageData, Text); MoldCategoryName_txt.Focus(); return(false); } //if (DisplayOrder_txt.Text == string.Empty) //{ // messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, DisplayOrder_lbl.Text); // popUpMessage.Warning(messageData, Text); // DisplayOrder_txt.Focus(); // return false; //} return(true); }
/// <summary> /// update the record to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { MoldCategoryVo inVo = new MoldCategoryVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(MoldCategoryCode_txt.Text) || !sch.IsASCII(MoldCategoryName_txt.Text)) //|| !sch.IsASCII(DisplayOrder_txt.Text) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(MoldCategoryCode_txt.Text)) { MoldCategoryCode_txt.Focus(); } else if (!sch.IsASCII(MoldCategoryName_txt.Text)) { MoldCategoryName_txt.Focus(); } else { DisplayOrder_txt.Focus(); } return; } inVo.MoldCategoryCode = MoldCategoryCode_txt.Text.Trim(); inVo.MoldCategoryName = MoldCategoryName_txt.Text.Trim(); // inVo.DisplayOrder = Convert.ToInt32(DisplayOrder_txt.Text.Trim()); if (string.Equals(mode, CommonConstants.MODE_ADD)) { MoldCategoryVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, MoldCategoryCode_lbl.Text + " : " + MoldCategoryCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); MoldCategoryCode_txt.Focus(); return; } //MoldCategoryVo checkDisplayVo = DuplicateDisplayCheck(inVo); //if (checkDisplayVo != null && checkDisplayVo.AffectedCount > 0) //{ // messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, DisplayOrder_lbl.Text + " : " + DisplayOrder_txt.Text); // logger.Info(messageData); // popUpMessage.ConfirmationOkCancel(messageData, Text); // DisplayOrder_txt.Focus(); // return; //} } try { this.Cursor = Cursors.WaitCursor; if (string.Equals(mode, CommonConstants.MODE_ADD)) { MoldCategoryVo outVo = (MoldCategoryVo)base.InvokeCbm(new AddMoldCategoryMasterMntCbm(), inVo, false); IntSuccess = outVo.MoldCategoryId; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { //if (updateData.DisplayOrder != Convert.ToInt32(DisplayOrder_txt.Text)) //{ // MoldCategoryVo checkDisplayVo = DuplicateDisplayCheck(inVo); // if (checkDisplayVo != null && checkDisplayVo.AffectedCount > 0) // { // messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, DisplayOrder_lbl.Text + " : " + DisplayOrder_txt.Text); // logger.Info(messageData); // popUpMessage.ConfirmationOkCancel(messageData, Text); // DisplayOrder_txt.Focus(); // return; // } //} inVo.MoldCategoryId = updateData.MoldCategoryId; MoldCategoryVo outVo = (MoldCategoryVo)base.InvokeCbm(new UpdateMoldCategoryMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } finally { this.Cursor = Cursors.Default; } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.Close(); } } }