/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (MoldCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MoldCode_lbl.Text); popUpMessage.Warning(messageData, Text); MoldCode_txt.Focus(); return(false); } if (MoldName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MoldName_lbl.Text); popUpMessage.Warning(messageData, Text); MoldName_txt.Focus(); return(false); } //if (MoldType_cmb.Text == string.Empty || MoldType_cmb.SelectedIndex < 0) //{ // messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, MoldType_lbl.Text); // popUpMessage.Warning(messageData, Text); // MoldType_cmb.Focus(); // return false; //} return(true); }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void Ok_btn_Click(object sender, EventArgs e) { if (CheckMandatory()) { var sch = StringCheckHelper.GetInstance(); if (string.IsNullOrEmpty(MoldCode_txt.Text) || string.IsNullOrEmpty(MoldName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (string.IsNullOrEmpty(MoldCode_txt.Text)) { MoldCode_txt.Focus(); } else { MoldName_txt.Focus(); } return; } MoldVo inVo = new MoldVo(); inVo.MoldCode = MoldCode_txt.Text.Trim(); inVo.MoldName = MoldName_txt.Text.Trim(); inVo.MoldTypeId = Convert.ToInt32(MoldType_cmb.SelectedValue); if (!string.IsNullOrEmpty(Weight_txt.Text)) { inVo.Weight = Convert.ToDecimal(Weight_txt.Text); } if (!string.IsNullOrEmpty(Height_txt.Text)) { inVo.Height = Convert.ToDecimal(Height_txt.Text); } if (!string.IsNullOrEmpty(Width_txt.Text)) { inVo.Width = Convert.ToDecimal(Width_txt.Text); } if (!string.IsNullOrEmpty(Depth_txt.Text)) { inVo.Depth = Convert.ToDecimal(Depth_txt.Text); } if (!string.IsNullOrWhiteSpace(ProductionDate_dtp.Text)) { inVo.ProductionDate = Convert.ToDateTime(ProductionDate_dtp.Value); } inVo.Comment = Comment_txt.Text; if (!string.IsNullOrEmpty(LifeShotCount_txt.Text)) { inVo.LifeShotCount = Convert.ToInt32(LifeShotCount_txt.Text); } if (string.Equals(mode, CommonConstants.MODE_ADD)) { MoldVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, MoldCode_lbl.Text + " : " + MoldCode_txt.Text); logger.Info(messageData); popUpMessage.ApplicationError(messageData, Text); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { MoldVo outVo = (MoldVo)base.InvokeCbm(new AddMoldMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.MoldId = updateData.MoldId; MoldVo outVo = (MoldVo)base.InvokeCbm(new UpdateMoldMasterMntCbm(), 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(); } } }