/// <summary> /// Handles Load event for mold data Insert/Update operations /// Loading mold data for update mold data and binding controls with selected mold record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddModelForm_Load(object sender, EventArgs e) { // FormDatatableFromVo(); ModelCode_txt.Select(); if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { LoadUserData(updateData); ModelCode_txt.Enabled = false; ModelName_txt.Select(); } }
private bool CheckDate() { if (ModelCode_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, ModelCode_lbl.Text); popUpMessage.Warning(messageData, Text); ModelCode_txt.Focus(); return(false); } if (ModelName_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, ModelName_lbl.Text); popUpMessage.Warning(messageData, Text); ModelName_txt.Focus(); return(false); } ModelCode_txt.Text = ModelCode_txt.Text.Trim(); ModelName_txt.Text = ModelName_txt.Text.Trim(); ModelVo outVo = new ModelVo(), inVo = new ModelVo { ModelId = vo.ModelId, ModelCode = ModelCode_txt.Text }; try { outVo = (ModelVo)DefaultCbmInvoker.Invoke(new CheckModelCbm(), inVo); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmcc00006", Properties.Resources.mmcc00006, ModelCode_lbl.Text); popUpMessage.Warning(messageData, Text); ModelCode_txt.Focus(); return(false); } } catch (Com.Nidec.Mes.Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return(false); } return(true); }
///// <summary> ///// Constructor for the form ///// </summary> ///// <param name="pmode"></param> ///// <param name="userItem"></param> //public AddModelForm(string pmode, ModelVo 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 (ModelCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, ModelCode_lbl.Text); popUpMessage.Warning(messageData, Text); ModelCode_txt.Focus(); return(false); } if (ModelName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, ModelName_lbl.Text); popUpMessage.Warning(messageData, Text); ModelName_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) { ModelVo inVo = new ModelVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(ModelCode_txt.Text) || !sch.IsASCII(ModelName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(ModelCode_txt.Text)) { ModelCode_txt.Focus(); } else { ModelName_txt.Focus(); } return; } inVo.ModelCode = ModelCode_txt.Text.Trim(); inVo.ModelName = ModelName_txt.Text.Trim(); if (string.Equals(mode, CommonConstants.MODE_ADD)) { ModelVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, ModelCode_lbl.Text + " : " + ModelCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); ModelCode_txt.Focus(); return; } } try { this.Cursor = Cursors.WaitCursor; if (string.Equals(mode, CommonConstants.MODE_ADD)) { ModelVo outVo = (ModelVo)base.InvokeCbm(new AddModelMasterMntCbm(), inVo, false); IntSuccess = outVo.ModelId; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.ModelId = updateData.ModelId; ModelVo outVo = (ModelVo)base.InvokeCbm(new UpdateModelMasterMntCbm(), 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(); } } }