/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (LocationCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, LocationCode_lbl.Text); popUpMessage.Warning(messageData, Text); LocationCode_txt.Focus(); return(false); } if (LocationName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, LocationName_lbl.Text); popUpMessage.Warning(messageData, Text); LocationName_txt.Focus(); return(false); } if (Building_cmb.Text == string.Empty || Building_cmb.SelectedIndex < 0) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Mold_lbl.Text); popUpMessage.Warning(messageData, Text); Building_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 AddLocationForm_Load(object sender, EventArgs e) { FormDatatableFromVo(); ComboBind(Building_cmb, buildingDatatable, "name", "id"); LocationCode_txt.Select(); if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { LoadUserData(updateData); LocationCode_txt.Enabled = false; LocationName_txt.Select(); } }
/// <summary> /// update the record to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { LocationVo inVo = new LocationVo(); if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(LocationCode_txt.Text) || !sch.IsASCII(LocationName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(LocationCode_txt.Text)) { LocationCode_txt.Focus(); } else { LocationName_txt.Focus(); } return; } //if(LocationCode_txt.Text.Trim().Length < 4) //{ // MessageData messageData = new MessageData("mmci00008", Properties.Resources.mmci00008, LocationCode_lbl.Text); // popUpMessage.Warning(messageData, Text); // LocationCode_txt.Focus(); // return; //} inVo.LocationCode = LocationCode_txt.Text.Trim(); inVo.LocationName = LocationName_txt.Text.Trim(); inVo.BuildingId = Convert.ToInt32(Building_cmb.SelectedValue); if (string.Equals(mode, CommonConstants.MODE_ADD)) { LocationVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, LocationCode_lbl.Text + " : " + LocationCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); LocationCode_txt.Focus(); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { LocationVo outVo = (LocationVo)base.InvokeCbm(new AddLocationMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.LocationId = updateData.LocationId; LocationVo outVo = (LocationVo)base.InvokeCbm(new UpdateLocationMasterMntCbm(), 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(); } } }