/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (EquipmentCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, EquipmentCode_lbl.Text); popUpMessage.Warning(messageData, Text); EquipmentCode_txt.Focus(); return(false); } if (EquipmentName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, EquipmentName_lbl.Text); popUpMessage.Warning(messageData, Text); EquipmentName_txt.Focus(); return(false); } if (InstrationDate_dtp.Text == " ") { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, InstrationDate_lbl.Text); popUpMessage.Warning(messageData, Text); InstrationDate_dtp.Focus(); return(false); } if (AssetNo_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, AssetNo_lbl.Text); popUpMessage.Warning(messageData, Text); AssetNo_txt.Focus(); return(false); } //if (Manufacturer_txt.Text == string.Empty) //{ // messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, "manufacturer"); // popUpMessage.Warning(messageData, Text); // Manufacturer_txt.Focus(); // return false; //} //if (ModelCode_txt.Text == string.Empty) //{ // messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, "model code"); // popUpMessage.Warning(messageData, Text); // ModelCode_txt.Focus(); // return false; //} //if (ModelName_txt.Text == string.Empty) //{ // messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, "model name"); // popUpMessage.Warning(messageData, Text); // ModelName_txt.Focus(); // return false; //} return(true); }
private bool checkdate() { if (AssetCode_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AssetCode_lbl.Text); popUpMessage.Warning(messageData, Text); AssetCode_txt.Focus(); return(false); } if (AssetName_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AssetName_lbl.Text); popUpMessage.Warning(messageData, Text); AssetName_txt.Focus(); return(false); } if (AssetModel_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AssetModel_lbl.Text); popUpMessage.Warning(messageData, Text); AssetModel_txt.Focus(); return(false); } if (AssetSupplier_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AssetSupplier_lbl.Text); popUpMessage.Warning(messageData, Text); AssetSupplier_txt.Focus(); return(false); } if (AssetInvoice_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AssetInvoice_lbl.Text); popUpMessage.Warning(messageData, Text); AssetInvoice_txt.Focus(); return(false); } if (AssetLife_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, Life_lbl.Text); popUpMessage.Warning(messageData, Text); AssetLife_txt.Focus(); return(false); } if (Asset_Acquistion_Cost_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, Acquistion_Cost_lbl.Text); popUpMessage.Warning(messageData, Text); Asset_Acquistion_Cost_txt.Focus(); return(false); } if (AssetNo_txt.Text.Trim().Length == 0) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, AssetNo_lbl.Text); popUpMessage.Warning(messageData, Text); AssetNo_txt.Focus(); return(false); } if (Asset_Acquistion_Date_dtp.Value > DateTime.Now) { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, Acquistion_Date_lbl.Text); popUpMessage.Warning(messageData, Text); Asset_Acquistion_Date_dtp.Focus(); return(false); } AssetCode_txt.Text = AssetCode_txt.Text.Trim(); AssetNo_txt.Text = AssetNo_txt.Text.Trim(); AssetName_txt.Text = AssetName_txt.Text.Trim(); AssetModel_txt.Text = AssetModel_txt.Text.Trim(); AssetSupplier_txt.Text = AssetSupplier_txt.Text.Trim(); AssetInvoice_txt.Text = AssetInvoice_txt.Text.Trim(); AssetSerial_txt.Text = AssetSerial_txt.Text.Trim(); AssetLife_txt.Text = AssetLife_txt.Text.Trim(); Asset_Acquistion_Cost_txt.Text = Asset_Acquistion_Cost_txt.Text.Trim(); AssetVo outVo = new AssetVo(), inVo = new AssetVo { AssetNo = int.Parse(AssetNo_txt.Text), AssetCode = AssetCode_txt.Text }; try { outVo = (AssetVo)DefaultCbmInvoker.Invoke(new CheckAssetCbm(), inVo); if (outVo.AffectedCount == 1) { messageData = new MessageData("mmce00001", AssetCode_lbl.Text + " : " + AssetCode_txt.Text + " is duplicate !", AssetCode_lbl.Text + " : " + AssetCode_txt.Text); logger.Warn(messageData); popUpMessage.Information(messageData, Text); return(false); } } catch (Com.Nidec.Mes.Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return(false); } return(true); }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { string manufacturer = string.Empty; string modelCode = string.Empty; string modelName = string.Empty; var sch = StringCheckHelper.GetInstance(); if (Manufacturer_txt.Text != null) { manufacturer = Manufacturer_txt.Text.Trim(); } if (ModelCode_txt.Text != null) { modelCode = ModelCode_txt.Text.Trim(); } if (ModelName_txt.Text != null) { modelName = ModelName_txt.Text.Trim(); } EquipmentVo inVo = new EquipmentVo(); if (CheckMandatory()) { if (string.IsNullOrEmpty(EquipmentCode_txt.Text) || string.IsNullOrEmpty(EquipmentName_txt.Text) || string.IsNullOrEmpty(AssetNo_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (string.IsNullOrEmpty(EquipmentCode_txt.Text)) { EquipmentCode_txt.Focus(); } else if (string.IsNullOrEmpty(EquipmentName_txt.Text)) { EquipmentName_txt.Focus(); } else if (string.IsNullOrEmpty(AssetNo_txt.Text)) { AssetNo_txt.Focus(); } return; } inVo.EquipmentCode = EquipmentCode_txt.Text.Trim(); inVo.EquipmentName = EquipmentName_txt.Text.Trim(); inVo.InstrationDate = InstrationDate_dtp.Value; inVo.AssetNo = AssetNo_txt.Text.Trim(); inVo.Manufacturer = manufacturer; inVo.ModelCode = modelCode; inVo.ModelName = modelName; //inVo.RegistrationDateTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); inVo.RegistrationUserCode = UserData.GetUserData().UserCode; inVo.FactoryCode = UserData.GetUserData().FactoryCode; if (string.Equals(mode, CommonConstants.MODE_ADD)) { EquipmentVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, EquipmentCode_lbl.Text + " : " + EquipmentCode_txt.Text); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); return; } } if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.EquipmentId = updateData.EquipmentId; } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { EquipmentVo outVo = (EquipmentVo)base.InvokeCbm(new AddEquipmentMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.EquipmentId = updateData.EquipmentId; EquipmentVo outVo = (EquipmentVo)base.InvokeCbm(new UpdateEquipmentMasterMntCbm(), 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(); } } }