/// <summary> /// Check all form controls have valid data if not display user to message and return fail /// </summary> /// <returns> form validation sucuss or Fail </returns> private bool IsFormvalidate() { try { bool validateResult = true; bool isControlFocused = true; Regex alphanumericpatt = new Regex("^[A-Za-z0-9!@#$%&*()-{}.,/ ]+$"); //--- Supplier code already exists --//-- if (!string.IsNullOrEmpty(txtSupplierCode.Text) && string.IsNullOrEmpty(editSupplierCode)) { var IssupplierModel = supplierManager.GetSupplierByID(txtSupplierCode.Text); if (IssupplierModel != null) { CommonFunc.SetErrorProvidertoControl(ref supplierErrorProvider, ref txtSupplierCode, "Supplier code already exists", true); txtSupplierCode.Focus(); validateResult = false; isControlFocused = false; } else { supplierErrorProvider.SetError(txtSupplierCode, string.Empty); txtSupplierCode.BorderColor = CommonFunc.DefaultBorderColor; } } if (!CommonFunc.SetErrorProvidertoControl(ref supplierErrorProvider, ref txtName, "Supplier Name value required")) { if (isControlFocused) { this.txtName.Focus(); } validateResult = false; isControlFocused = false; } if (!CommonFunc.SetErrorProvidertoControl(ref supplierErrorProvider, ref txtContactPerson, "Contact Person value required")) { if (isControlFocused) { this.txtContactPerson.Focus(); } validateResult = false; isControlFocused = false; } if (!CommonFunc.validateEmailId(this.txtEmailAddress.Text.ToString()) && !string.IsNullOrEmpty(this.txtEmailAddress.Text.ToString())) { if (!CommonFunc.SetErrorProvidertoControl(ref supplierErrorProvider, ref txtEmailAddress, "E-mail should in standard E-mail format.", true)) { if (isControlFocused) { txtEmailAddress.Focus(); } validateResult = false; isControlFocused = false; } } else { supplierErrorProvider.SetError(txtEmailAddress, string.Empty); txtEmailAddress.BorderColor = CommonFunc.DefaultBorderColor; } if (!string.IsNullOrEmpty(txtVatTanNo.Text.Trim())) { if (alphanumericpatt.IsMatch(txtVatTanNo.Text) == false) { validateResult = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref supplierErrorProvider, ref txtVatTanNo, "Vat Tin No allows Alphanumeric Character", false)) { this.txtVatTanNo.Focus(); } } else { supplierErrorProvider.SetError(txtVatTanNo, string.Empty); txtVatTanNo.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtCstTinNo.Text.Trim())) { if (alphanumericpatt.IsMatch(txtCstTinNo.Text) == false) { validateResult = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref supplierErrorProvider, ref txtCstTinNo, "CST Tin No allows Alphanumeric Character", false)) { this.txtCstTinNo.Focus(); } } else { supplierErrorProvider.SetError(txtCstTinNo, string.Empty); txtCstTinNo.BorderColor = CommonFunc.DefaultBorderColor; } } return(validateResult); } catch (Exception ex) { throw ex; } }
private bool IsFormValidate() { try { bool isValid = true; // Regex patt = new Regex("^[A-Za-z0-9]+$"); Regex alphanumericpatt = new Regex("^[A-Za-z0-9!@#$%&*()-{}.,/ ]+$"); if (!string.IsNullOrEmpty(txtPromotionId.Text.Trim())) { if (alphanumericpatt.IsMatch(txtPromotionId.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtPromotionId, "Promotion Id allows Alphanumeric Character", false)) { this.txtPromotionId.Focus(); } } else { errorProvider.SetError(txtPromotionId, string.Empty); txtPromotionId.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtPromotionName.Text.Trim())) { if (alphanumericpatt.IsMatch(txtPromotionName.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtPromotionName, "Promotion Name allows Alphanumeric Character", false)) { this.txtPromotionName.Focus(); } } else { errorProvider.SetError(txtPromotionName, string.Empty); txtPromotionName.BorderColor = CommonFunc.DefaultBorderColor; } } if (string.IsNullOrEmpty(txtPromotionName.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtPromotionName, "Promotion name required")) { this.txtPromotionName.Focus(); isValid = false; } } else if (string.IsNullOrEmpty(txtPromotionValue.Text.Trim())) { string typeVale = "Discount Value "; if (rdbFlatPrice.Checked == true) { typeVale = "Flat Price "; } else if (rdoAmountOff.Checked == true) { typeVale = "Amount Off Value "; } if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtPromotionValue, typeVale + " required")) { this.txtPromotionValue.Focus(); isValid = false; } } else { if (rdoDiscountPer.Checked == true) { if (Convert.ToDecimal(txtPromotionValue.Value) <= Convert.ToDecimal("0")) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtPromotionValue, "Promotion Value Should be Greater Than 0", false)) { this.txtPromotionValue.Focus(); return(isValid); } } if (Convert.ToDecimal(txtPromotionValue.Value) > Convert.ToDecimal("100.00")) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtPromotionValue, "Promotion Value Not Greater Than 100", false)) { this.txtPromotionValue.Focus(); return(isValid); } } else { errorProvider.SetError(txtPromotionValue, string.Empty); txtPromotionValue.BorderColor = CommonFunc.DefaultBorderColor; } } else { if (Convert.ToDecimal(txtPromotionValue.Value) <= Convert.ToDecimal("0")) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtPromotionValue, "Promotion Value Should be Greater Than 0", false)) { this.txtPromotionValue.Focus(); return(isValid); } } else { errorProvider.SetError(txtPromotionValue, string.Empty); txtPromotionValue.BorderColor = CommonFunc.DefaultBorderColor; } } } if (!string.IsNullOrEmpty(txtPromotionId.Text.Trim()) && flagAddEdit == false) { var promotionDetail = this.promotionManager.GetPromotionById(txtPromotionId.Text.Trim()); if (promotionDetail != null) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtPromotionId, "Promotion already Exists", false)) { this.txtPromotionId.Focus(); } } else { errorProvider.SetError(txtPromotionId, string.Empty); txtPromotionId.BorderColor = CommonFunc.DefaultBorderColor; } } return(isValid); } catch (Exception ex) { throw (ex); } }
private bool IsFormValidate() { try { bool isValid = true; bool isSiteValid = true; Regex sitecodepatt = new Regex("^[A-Za-z0-9]+$"); Regex alphanumericpatt = new Regex("^[A-Za-z0-9!@#$%&*()-{}.,/ ]+$"); Regex numberpatt = new Regex("^[0-9]+$"); Regex alphapatt = new Regex("^[A-Za-z ]+$"); if (string.IsNullOrEmpty(txtSiteCode.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtSiteCode, "Site Code Required")) { this.txtSiteCode.Focus(); isValid = false; } } else { if (sitecodepatt.IsMatch(txtSiteCode.Text) == false) { isValid = false; isSiteValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtSiteCode, "Site Code Allows Alphanumeric Character", false)) { this.txtSiteCode.Focus(); } } else { errorProvider.SetError(txtSiteCode, string.Empty); txtSiteCode.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtCorporateName.Text.Trim())) { if (alphanumericpatt.IsMatch(txtCorporateName.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtCorporateName, "Corporate Name Allows Alphanumeric Character", false)) { this.txtCorporateName.Focus(); } } else { errorProvider.SetError(txtCorporateName, string.Empty); txtCorporateName.BorderColor = CommonFunc.DefaultBorderColor; } } if (string.IsNullOrEmpty(txtOfficialName.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtOfficialName, "Site Name Required")) { this.txtSiteCode.Focus(); isValid = false; } } else { if (alphanumericpatt.IsMatch(txtOfficialName.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtOfficialName, "Site Name Allows Alphanumeric Character", false)) { this.txtSiteCode.Focus(); } } else { errorProvider.SetError(txtOfficialName, string.Empty); txtOfficialName.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtAddress1.Text.Trim())) { if (alphanumericpatt.IsMatch(txtAddress1.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtAddress1, "Address Allows Alphanumeric Character", false)) { this.txtAddress1.Focus(); } } else { errorProvider.SetError(txtAddress1, string.Empty); txtAddress1.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtAddress2.Text.Trim())) { if (alphanumericpatt.IsMatch(txtAddress2.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtAddress2, "Address Allows Alphanumeric Character", false)) { this.txtAddress2.Focus(); } } else { errorProvider.SetError(txtAddress2, string.Empty); txtAddress2.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtAddress3.Text.Trim())) { if (alphanumericpatt.IsMatch(txtAddress3.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtAddress3, "Address Allows Alphanumeric Character", false)) { this.txtAddress3.Focus(); } } else { errorProvider.SetError(txtAddress3, string.Empty); txtAddress3.BorderColor = CommonFunc.DefaultBorderColor; } } if (string.IsNullOrEmpty(txtCountry.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtCountry, "Country Code Required")) { this.txtCountry.Focus(); isValid = false; } } else { if (alphapatt.IsMatch(txtCountry.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtCountry, "Country Allows Character Only", false)) { this.txtCountry.Focus(); } } else { errorProvider.SetError(txtCountry, string.Empty); txtCountry.BorderColor = CommonFunc.DefaultBorderColor; } } if (string.IsNullOrEmpty(txtCurrencyCode.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtCurrencyCode, "Currency Code Required")) { this.txtCurrencyCode.Focus(); isValid = false; } } else { errorProvider.SetError(txtCurrencyCode, string.Empty); txtCurrencyCode.BorderColor = CommonFunc.DefaultBorderColor; var IsCurrencyExist = this.siteManager.GetCurrencySymbol(txtCurrencyCode.Text.Trim()); if (IsCurrencyExist == null) { if (string.IsNullOrEmpty(txtCurrencySymol.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtCurrencySymol, "Currency Symbol Required")) { this.txtCurrencySymol.Focus(); isValid = false; } } else { errorProvider.SetError(txtCurrencySymol, string.Empty); txtCurrencySymol.BorderColor = CommonFunc.DefaultBorderColor; } } else { errorProvider.SetError(txtCurrencySymol, string.Empty); txtCurrencySymol.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtEmail.Text.Trim())) { if (!CommonFunc.validateEmailId(this.txtEmail.Text.ToString()) && !string.IsNullOrEmpty(this.txtEmail.Text.ToString())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtEmail, "E-mail Should in Standard E-mail Format.", true)) { isValid = false; txtEmail.Focus(); } } else { errorProvider.SetError(txtEmail, string.Empty); txtEmail.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtContactPerson.Text.Trim())) { if (alphanumericpatt.IsMatch(txtContactPerson.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtContactPerson, "Contact Person Allows Alphanumeric Character", false)) { this.txtContactPerson.Focus(); } } else { errorProvider.SetError(txtContactPerson, string.Empty); txtContactPerson.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtContactNumber.Text.Trim())) { if (numberpatt.IsMatch(txtContactNumber.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtContactNumber, "Contact Number Allows Numeric Only", false)) { this.txtContactNumber.Focus(); } } else { errorProvider.SetError(txtContactNumber, string.Empty); txtContactNumber.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtFaxNo.Text.Trim())) { if (numberpatt.IsMatch(txtFaxNo.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtFaxNo, "Fax Number Allows Numeric Only", false)) { this.txtFaxNo.Focus(); } } else { errorProvider.SetError(txtFaxNo, string.Empty); txtFaxNo.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtTaxNo.Text.Trim())) { if (alphanumericpatt.IsMatch(txtTaxNo.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTaxNo, "Tax Number Allows Alphanumeric Only", false)) { this.txtTaxNo.Focus(); } } else { errorProvider.SetError(txtTaxNo, string.Empty); txtTaxNo.BorderColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtLicenceNo.Text.Trim())) { if (alphanumericpatt.IsMatch(txtLicenceNo.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtLicenceNo, "License Number Allows Numeric Only", false)) { this.txtLicenceNo.Focus(); } } else { errorProvider.SetError(txtLicenceNo, string.Empty); txtLicenceNo.BorderColor = CommonFunc.DefaultBorderColor; } } if (string.IsNullOrEmpty(finYearBeginDate.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref finYearBeginDate, "Financial Year Begin Date required")) { this.finYearBeginDate.Focus(); isValid = false; } } else { errorProvider.SetError(finYearBeginDate, string.Empty); finYearBeginDate.BorderColor = CommonFunc.DefaultBorderColor; } if (string.IsNullOrEmpty(finYearEndDate.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref finYearEndDate, "Financial Year End Date required")) { this.finYearEndDate.Focus(); isValid = false; } } else { errorProvider.SetError(finYearEndDate, string.Empty); finYearEndDate.BorderColor = CommonFunc.DefaultBorderColor; } if (!string.IsNullOrEmpty(finYearBeginDate.Text.Trim())) { if (string.IsNullOrEmpty(finYearEndDate.Text.Trim())) { isValid = false; if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref finYearEndDate, "Please select a valid End Date")) { this.finYearEndDate.Focus(); } } else { DateTime beginDate = Convert.ToDateTime(finYearBeginDate.Value); DateTime endDate = Convert.ToDateTime(finYearEndDate.Value); int addDays = 364; string FiscYear = DateTime.Now.Year.ToString(); if (Convert.ToInt32(FiscYear.Substring(FiscYear.Length - 2)) % 4 == 0) { addDays = 365; } if (endDate >= beginDate.AddDays(addDays)) { errorProvider.SetError(finYearEndDate, string.Empty); finYearEndDate.BorderColor = CommonFunc.DefaultBorderColor; } else { isValid = false; if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref finYearEndDate, "Difference between the Start Date and End Date should be 1 year. Please select a valid End Date")) { this.finYearEndDate.Focus(); } } } } if (!string.IsNullOrEmpty(txtSiteCode.Text.Trim()) && flagAddEdit == false && isSiteValid == true) { var IsSiteExist = this.siteManager.GetSiteByID(txtSiteCode.Text.Trim()); if (IsSiteExist != null) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtSiteCode, "Site Name Already Exist", false)) { this.txtSiteCode.Focus(); } } else { errorProvider.SetError(txtSiteCode, string.Empty); txtSiteCode.BorderColor = CommonFunc.DefaultBorderColor; } } return(isValid); } catch (Exception ex) { throw (ex); } }
/// <summary> /// Check all form controls have valid data if not display user to message and return fail /// </summary> /// <returns> form validation sucuss or Fail </returns> private bool IsFormvalidate() { try { Regex alphaNumericPatt = new Regex("^[A-Za-z0-9- ]+$"); bool validateResult = true; bool isControlFocused = true; if ((int)EnumSave.Tree == SaveMode) { if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txtFlTreeName, "Tree Name value required")) { this.txtFlTreeName.Focus(); validateResult = false; isControlFocused = false; } // Tree Name Mandatory. Alphanumeric Textbox. Accepts space but no special characters. if (alphaNumericPatt.IsMatch(txtFlTreeName.Text) == false) { validateResult = false; if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txtFlTreeName, " Tree Name is Alphanumeric Textbox. Accepts space but no special characters.", true)) { this.txtFlTreeName.Focus(); } } else { epArticleHierarchy.SetError(txtFlTreeName, string.Empty); txtFlTreeName.BorderColor = CommonFunc.DefaultBorderColor; } if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txtDefineLevel, "Level value required")) { if (isControlFocused) { this.txtDefineLevel.Focus(); } validateResult = false; isControlFocused = false; } // Check Level Names for (int rowIndex = 1; rowIndex < dgDifineLevel.Rows.Count; rowIndex++) { if (string.IsNullOrEmpty(dgDifineLevel.Rows[rowIndex][1] as string)) { MessageBox.Show(CommonFunc.getResourceString("IH012")); this.dgDifineLevel.Focus(); validateResult = false; isControlFocused = false; goto gotLevelResult; } else { if (alphaNumericPatt.IsMatch(dgDifineLevel.Rows[rowIndex][1] as string) == false) { this.dgDifineLevel.Focus(); validateResult = false; MessageBox.Show("Tree level at Level Code- " + rowIndex + " is Alphanumeric Textbox. Accepts space but no special characters."); isControlFocused = false; goto gotLevelResult; } } } } else { if (!CommonFunc.SetErrorProvidertoControl(ref epArticleHierarchy, ref txttp2NodeName, "Set Tree Name")) { this.txttp2NodeName.Focus(); validateResult = false; isControlFocused = false; } } gotLevelResult: return(validateResult); } catch (Exception ex) { throw ex; } }
private bool ValidateTax() { try { bool isValid = true; if (string.IsNullOrEmpty(txtTaxName.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtTaxName, "Tax Name Required")) { this.txtTaxName.Focus(); isValid = false; } } else { Regex patt = new Regex("^[A-Za-z0-9-.% ]+$"); if (patt.IsMatch(txtTaxName.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTaxName, "Tax Name Allows AlphaNumeric,space,%,-", false)) { this.txtTaxName.Focus(); } } else { errorProvider.SetError(txtTaxName, string.Empty); txtTaxName.BorderColor = CommonFunc.DefaultBorderColor; } } if (string.IsNullOrEmpty(txtTaxValue.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtTaxValue, "Tax Value Required")) { this.txtTaxValue.Focus(); isValid = false; } } else { decimal taxval = Convert.ToDecimal(txtTaxValue.Value.ToString().Trim()); if (taxval <= 0) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTaxValue, "Value Should be Greater Than 0", false)) { this.txtTaxValue.Focus(); return(isValid); } } if (rdoTVTPercent.Checked == true) { if (taxval > Convert.ToDecimal("100.00")) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTaxValue, "Tax Value Can Not be Greater Than 100", false)) { this.txtTaxValue.Focus(); return(isValid); } } } else { if (taxval > Convert.ToDecimal("1000000.00")) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTaxValue, "Tax Value Can Not be Greater Than 1000000", false)) { this.txtTaxValue.Focus(); return(isValid); } } } if (txtTaxValue.Text.Contains(".")) { string[] decKeys = txtTaxValue.Text.Split('.'); if (decKeys[1].Length > 2) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTaxValue, "Only Two Decimal Digits Allowed", false)) { this.txtTaxValue.Focus(); } } else { errorProvider.SetError(txtTaxValue, string.Empty); txtTaxValue.BorderColor = CommonFunc.DefaultBorderColor; } } else { errorProvider.SetError(txtTaxValue, string.Empty); txtTaxValue.BorderColor = CommonFunc.DefaultBorderColor; } } if ((cmbDocumentType.SelectedValue == null)) { if (!CommonFunc.SetErrorProviderComboControl(ref errorProvider, ref cmbDocumentType, "Please Select Document Type", false)) { this.cmbDocumentType.Focus(); isValid = false; } //CommonFunc.ShowMessage("Required", Models.Enums.MessageType.Information); } if ((cmbAppliedon.SelectedValue == null)) { if (!CommonFunc.SetErrorProviderComboControl(ref errorProvider, ref cmbAppliedon, "Please Select Applied On ", false)) { this.cmbAppliedon.Focus(); isValid = false; } } return(isValid); } catch (Exception ex) { Logger.Log(ex, Logger.LogingLevel.Error); throw ex; } }
private bool IsFormvalidate() { try { bool isValid = true; bool isTenderChecked = false; // Regex patt = new Regex("^[A-Za-z0-9]+$"); Regex alphanumericpatt = new Regex("^[A-Za-z0-9!@#$%&*()-{}.,/ ]+$"); if (string.IsNullOrEmpty(txtTenderCode.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtTenderCode, "Tender Code required")) { this.txtTenderCode.Focus(); isValid = false; } } else { if (alphanumericpatt.IsMatch(txtTenderCode.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTenderCode, "Tender Code allows Alphanumeric Character", false)) { this.txtTenderCode.Focus(); } } else { isTenderChecked = true; errorProvider.SetError(txtTenderCode, string.Empty); txtTenderCode.BorderColor = CommonFunc.DefaultBorderColor; } } if (string.IsNullOrEmpty(txtTenderName.Text.Trim())) { if (!CommonFunc.SetErrorProvidertoControl(ref errorProvider, ref txtTenderName, "Tender Name required")) { this.txtTenderName.Focus(); isValid = false; } } else { if (alphanumericpatt.IsMatch(txtTenderName.Text) == false) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTenderName, "Tender Name allows Alphanumeric Character", false)) { this.txtTenderName.Focus(); } } else { errorProvider.SetError(txtTenderName, string.Empty); txtTenderName.BorderColor = CommonFunc.DefaultBorderColor; } } if (cboTenderType.SelectedIndex == -1 || cboTenderType.SelectedValue == null) { if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref errorProvider, ref cboTenderType, "Select Tender Type")) { this.cboTenderType.Focus(); isValid = false; } } else { errorProvider.SetError(cboTenderType, string.Empty); cboTenderType.BackColor = CommonFunc.DefaultBorderColor; if (cboTenderType.SelectedValue.ToString() == "CreditVouc(I)" || cboTenderType.SelectedValue.ToString() == "GiftVoucher(R)" || cboTenderType.SelectedValue.ToString() == "CLPPoint") { if (cboProgramCode.SelectedIndex == -1 || cboProgramCode.SelectedValue == null) { if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref errorProvider, ref cboProgramCode, "Select Program Code")) { this.cboProgramCode.Focus(); isValid = false; } } else { errorProvider.SetError(cboProgramCode, string.Empty); cboProgramCode.BackColor = CommonFunc.DefaultBorderColor; } } else { errorProvider.SetError(cboProgramCode, string.Empty); cboProgramCode.BackColor = CommonFunc.DefaultBorderColor; } } if (!string.IsNullOrEmpty(txtTenderCode.Text.Trim()) && isTenderChecked == true) { var tenderDetails = this.tenderManager.GetTenderByID(txtTenderCode.Text.Trim()); if (tenderDetails != null) { isValid = false; if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtTenderCode, "Tender Code Already Exists For this Site", false)) { this.txtTenderCode.Focus(); } } else { errorProvider.SetError(txtTenderCode, string.Empty); txtTenderCode.BorderColor = CommonFunc.DefaultBorderColor; } } if (isTenderChecked == false) { txtTenderCode.Focus(); } return(isValid); } catch (Exception ex) { throw ex; } }