/// <summary> /// Constructor for the form /// </summary> /// <param name="pmode"></param> /// <param name="userItem"></param> //public AddBuldingForm(string pmode, buildingVo 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 (BuildingCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, BuildingCode_lbl.Text); popUpMessage.Warning(messageData, Text); BuildingCode_txt.Focus(); return(false); } if (BuildingName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, BuildingName_lbl.Text); popUpMessage.Warning(messageData, Text); BuildingName_txt.Focus(); return(false); } if (FactoryCode_cmb.Text == string.Empty || FactoryCode_cmb.SelectedIndex < 0) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Factory_lbl.Text); popUpMessage.Warning(messageData, Text); FactoryCode_cmb.Focus(); return(false); } return(true); }
/// <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 AddBuildingForm_Load(object sender, EventArgs e) { FormDatatableFromVo(); BuildingCode_txt.Select(); ComboBind(FactoryCode_cmb, factoryDatatable, "code", "code"); if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { LoadUserData(updateData); BuildingCode_txt.Enabled = false; BuildingName_txt.Select(); } BuildingCode_txt.Focus(); }
/// <summary> /// update the record to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { BuildingVo inVo = new BuildingVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(BuildingCode_txt.Text) || !sch.IsASCII(BuildingName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(BuildingCode_txt.Text)) { BuildingCode_txt.Focus(); } else { BuildingName_txt.Focus(); } return; } inVo.BuildingCode = BuildingCode_txt.Text.Trim(); inVo.BuildingName = BuildingName_txt.Text.Trim(); inVo.FactoryCode = FactoryCode_cmb.SelectedValue.ToString(); if (string.Equals(mode, CommonConstants.MODE_ADD)) { BuildingVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, BuildingCode_lbl.Text + " : " + BuildingCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); BuildingCode_txt.Focus(); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { BuildingVo outVo = (BuildingVo)base.InvokeCbm(new AddBuildingMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.BuildingId = updateData.BuildingId; BuildingVo outVo = (BuildingVo)base.InvokeCbm(new UpdateBuildingMasterMntCbm(), 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(); } } }