/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (CastingMachineCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, CastingMachineCode_lbl.Text); popUpMessage.Warning(messageData, Text); CastingMachineCode_txt.Focus(); return(false); } if (CastingMachineName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, CastingMachineName_lbl.Text); popUpMessage.Warning(messageData, Text); CastingMachineName_txt.Focus(); return(false); } if (CastingMachineFurnaceName_cmb.Text == string.Empty || CastingMachineFurnaceName_cmb.SelectedIndex < 0) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, CastingMachineFurnaceName_lbl.Text); popUpMessage.Warning(messageData, Text); CastingMachineFurnaceName_cmb.Focus(); return(false); } if (Equipment_cmb.Text == string.Empty || Equipment_cmb.SelectedIndex < 0) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Equipment_lbl.Text); popUpMessage.Warning(messageData, Text); Equipment_cmb.Focus(); return(false); } return(true); }
/// <summary> /// handles insert/update /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { CastingMachineVo inVo = new CastingMachineVo(); var sch = StringCheckHelper.GetInstance(); if (CheckMandatory()) { if (string.IsNullOrEmpty(CastingMachineCode_txt.Text) || string.IsNullOrEmpty(CastingMachineName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (string.IsNullOrEmpty(CastingMachineCode_txt.Text)) { CastingMachineCode_txt.Focus(); } else if (string.IsNullOrEmpty(CastingMachineName_txt.Text)) { CastingMachineName_txt.Focus(); } return; } inVo.CastingMachineCode = CastingMachineCode_txt.Text.Trim(); inVo.CastingMachineName = CastingMachineName_txt.Text.Trim(); inVo.EquipmentId = Convert.ToInt32(Equipment_cmb.SelectedValue.ToString()); inVo.CastingMachineFurnaceId = Convert.ToInt32(CastingMachineFurnaceName_cmb.SelectedValue.ToString()); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); inVo.FactoryCode = UserData.GetUserData().FactoryCode; if (string.Equals(mode, CommonConstants.MODE_ADD)) { CastingMachineVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, CastingMachineCode_lbl.Text + " : " + CastingMachineCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); return; } } if (updateData != null) { inVo.CastingMachineId = updateData.CastingMachineId; } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { CastingMachineVo outVo = (CastingMachineVo)base.InvokeCbm(new AddCastingMachineMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { CastingMachineVo outVo = (CastingMachineVo)base.InvokeCbm(new UpdateCastingMachineMasterMntCbm(), 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(); } } }