Beispiel #1
0
 private bool IsFormValidate()
 {
     try
     {
         bool  isValid          = true;
         Regex alphanumericpatt = new Regex("^[0-9]+$");
         if (string.IsNullOrEmpty(txtLevel.Text.Trim()))
         {
             CommonFunc.ShowMessage("Please select level first", MessageType.Information);
             isValid = false;
         }
         if (!string.IsNullOrEmpty(txtNoOfPts.Text.Trim()))
         {
             if (alphanumericpatt.IsMatch(txtNoOfPts.Text.Trim()) == false)
             {
                 isValid = false;
                 if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtNoOfPts, "Allows Numbers only", false))
                 {
                     this.txtNoOfPts.Focus();
                 }
             }
             else if (Convert.ToInt32(txtNoOfPts.Text.Trim()) <= 0)
             {
                 isValid = false;
                 if (!CommonFunc.SetCustomErrorProvidertoControl(ref errorProvider, ref txtNoOfPts, "Value should be grater than 0 ", false))
                 {
                     this.txtNoOfPts.Focus();
                 }
             }
             else
             {
                 errorProvider.SetError(txtNoOfPts, string.Empty);
                 txtNoOfPts.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
            {
                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;
            }
        }
Beispiel #3
0
        private bool ValidateArticleStock()
        {
            try
            {
                bool   valfields = true, valAdjQuantity = true, valAdjNegativeQuantity = true;
                int    ValidReasonLengthCounter = 0;
                int    ValidReasonTextCounter = 0;
                string a    = (string)cmbStockOutReason.SelectedValue;
                Regex  patt = new Regex("^[A-Za-z0-9!@#$%&*()-{}.,/ ]+$");


                if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref Itemerrorprovider, ref cmbStockOutReason, "Stock Out Reason required"))
                {
                    this.cmbStockOutReason.Focus();
                    valfields = false;
                }

                if ((string)cmbStockOutReason.SelectedValue == "SupplierReturn" || (string)cmbStockOutReason.SelectedValue == "WriteOff")
                {
                    if (!CommonFunc.SetErrorProvidertoControlForWindowsForm(ref Itemerrorprovider, ref cmbFromLocation, "From Location Reason required"))
                    {
                        this.cmbFromLocation.Focus();
                        valfields = false;
                    }
                    else
                    {
                        Itemerrorprovider.SetError(cmbFromLocation, string.Empty);
                        cmbFromLocation.BackColor = CommonFunc.DefaultBorderColor;
                    }
                }
                if (!string.IsNullOrEmpty(txtRemark.Text.Trim()))
                {
                    if (patt.IsMatch(txtRemark.Text) == false)
                    {
                        valfields = false;
                        if (!CommonFunc.SetCustomErrorProvidertoControl(ref Itemerrorprovider, ref txtRemark, "Remark Allows Alphanumeric Character", false))
                        {
                            this.txtRemark.Focus();
                        }
                    }
                    else
                    {
                        Itemerrorprovider.SetError(txtRemark, string.Empty);
                        txtRemark.BorderColor = CommonFunc.DefaultBorderColor;
                    }
                }
                int rowcount = gridScanArticle.Rows.Count;
                if (rowcount > 1)
                {
                    for (int rowIndex = 1; rowIndex < gridScanArticle.Rows.Count; rowIndex++)
                    {
                        Int64 intavailqty = Convert.ToInt64(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AvailableQty]);
                        Int64 LookupValue;
                        bool  LookupValueIsANumber = Int64.TryParse(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AdjustmentQty].ToString(), out LookupValue);

                        if (LookupValueIsANumber == false)
                        {
                            CommonFunc.ShowMessage("Please Enter Proper Adjustment quantity", Models.Enums.MessageType.Information);
                            gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AdjustmentQty] = 0;
                            return(false);
                        }
                        Int64  intadjustqty = Convert.ToInt64(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.AdjustmentQty]);
                        string reason       = Convert.ToString(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.Reason]);
                        if (intadjustqty > 0 && intadjustqty > intavailqty)
                        {
                            valAdjQuantity = false;
                        }
                        else if (intadjustqty <= 0)
                        {
                            valAdjNegativeQuantity = false;
                        }
                        if (reason.Trim() != "" && reason.Trim().Length > 30)
                        {
                            ValidReasonLengthCounter = ValidReasonLengthCounter + 1;
                        }
                        else if (reason.Trim() != "" && patt.IsMatch(reason.Trim()) == false)
                        {
                            ValidReasonTextCounter = ValidReasonTextCounter + 1;
                        }
                    }
                }
                else
                {
                    if (valfields)
                    {
                        CommonFunc.ShowMessage("Please add Item", MessageType.Information);
                        valfields = false;
                        return(valfields);
                    }
                }
                if (!valAdjQuantity)
                {
                    CommonFunc.ShowMessage("Adjustment quantity must be less than Available quantity", Models.Enums.MessageType.Information);
                    return(false);
                }
                if (!valAdjNegativeQuantity)
                {
                    CommonFunc.ShowMessage("Adjustment quantity must be greater than Zero(0)", Models.Enums.MessageType.Information);
                    return(false);
                }
                if (ValidReasonLengthCounter > 0)
                {
                    CommonFunc.ShowMessage("Reason allows 30 characters only", Models.Enums.MessageType.Information);
                    return(false);
                }
                if (ValidReasonTextCounter > 0)
                {
                    CommonFunc.ShowMessage("Reason allows alphnumeric characters only", Models.Enums.MessageType.Information);
                    return(false);
                }
                return(valfields);
            }
            catch (Exception ex)
            {
                Logger.Log(ex, Logger.LogingLevel.Error);
                throw ex;
            }
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #6
0
        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;
            }
        }
        /// <summary>
        ///
        /// </summary>
        private bool ValidateArticleStock()
        {
            try
            {
                bool    isValid = true;
                Boolean IsSingleCheckBoxCheck = false; //vipin

                if (!string.IsNullOrEmpty(txtInvoiceNumber.Text.Trim()))
                {
                    var invoiceNumber = articleStockManager.CheckInvoiceID(txtInvoiceNumber.Text.Trim());
                    if (invoiceNumber != null)
                    {
                        if (!CommonFunc.SetCustomErrorProvidertoControl(ref articlePurchaseProvider, ref txtInvoiceNumber, "Invoice Number Already Exist", false))
                        {
                            this.txtInvoiceNumber.Focus();
                            return(false);
                        }
                    }
                    else
                    {
                        articlePurchaseProvider.SetError(txtInvoiceNumber, string.Empty);
                        txtInvoiceNumber.BorderColor = CommonFunc.DefaultBorderColor;
                    }
                }
                int rowcount = gridScanArticle.Rows.Count;
                if (rowcount > 1)
                {
                    for (int rowIndex = 1; rowIndex < gridScanArticle.Rows.Count; rowIndex++)
                    {
                        Int64   intqty  = Convert.ToInt64(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.Quantity]);
                        Decimal intcost = (gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.CostPrice] == null) ? 0 : Convert.ToInt64(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.CostPrice]);
                        Decimal inttax  = (gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.TaxAmount] == null) ? 0 : Convert.ToInt64(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.TaxAmount]);

                        if (IsSingleCheckBoxCheck != true)  //vipin
                        {
                            if (Convert.ToBoolean(gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.Select]) == true)
                            {
                                IsSingleCheckBoxCheck = true;
                            }
                        }
                        if (IsSingleCheckBoxCheck == false)
                        {
                            CommonFunc.ShowMessage("Select at least one article", MessageType.Information);
                            isValid = false;
                            return(isValid);
                        }

                        //changes end by vipin

                        if (gridScanArticle.Rows[rowIndex][(int)GridColumnArticles.ArticleCode] != null)
                        {
                            if (intqty <= 0)
                            {
                                CommonFunc.ShowMessage("Quantity should be more than 0", MessageType.Information);
                                isValid = false;
                                return(isValid);
                            }
                            //else if (intcost <= 0)   // Commented by vipin as  per Tester 13-04-2017
                            //{
                            //    CommonFunc.ShowMessage("Cost Price should be more than 0", MessageType.Information);
                            //    isValid = false;
                            //    return isValid;
                            //}
                            else if (inttax < 0)
                            {
                                CommonFunc.ShowMessage("Tax Amount should be more than 0", MessageType.Information);
                                isValid = false;
                                return(isValid);
                            }
                        }
                    }
                }
                else
                {
                    CommonFunc.ShowMessage("Please add Item", MessageType.Information);
                    isValid = false;
                }

                return(isValid);
            }
            catch (Exception ex)
            {
                Logger.Log(ex, Logger.LogingLevel.Error);
                throw ex;
            }
        }