Exemple #1
0
 /// <summary>
 /// Called before the page is rendered.  This is used for the save functionality.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (Page.IsPostBack)
     {
         SqlConnection con      = new SqlConnection(ConfigurationManager.ConnectionStrings["eliteConnectionString"].ConnectionString);
         BearCode      bearCode = new BearCode();
         if (bearCode.IsNumber(TextBoxAmountToPay.Text) || TextBoxAmountToPay.Text.Equals(""))
         {
             String amountToPay = TextBoxAmountToPay.Text;
             if (amountToPay.Equals(""))
             {
                 amountToPay = "0";
             }
             try
             {
                 con.Open();
                 SqlCommand command = con.CreateCommand();
                 command.CommandText = "uspBMcBEARCashFlowManagerUpdateAmountToPay";
                 command.CommandType = CommandType.StoredProcedure;
                 command.Parameters.AddWithValue("@amountToPay", amountToPay);
                 command.Parameters.AddWithValue("@networkId", this.userName);
                 command.ExecuteNonQuery();
                 LabelMessage.Text = "Value Updated";
             }
             catch (SqlException sqle)
             {
                 Logger.QuickLog(VariablesCashManager.ERROR_LOG_FILE_NAME, sqle.Message, "adminOptions.aspx: Page_PreRender()", "");
             }
             finally
             {
                 if (con != null)
                 {
                     con.Close();
                 }
             }
         }
         else
         {
             LabelMessage.Text = "Please enter a valid amount";
         }
     }
 }
 /// <summary>
 /// Called before the page is rendered.  This is used for the save functionality.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
  protected void Page_PreRender(object sender, EventArgs e)
 {
     if (Page.IsPostBack)
     {
         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["eliteConnectionString"].ConnectionString);
         BearCode bearCode = new BearCode();
         if (bearCode.IsNumber(TextBoxAmountToPay.Text) || TextBoxAmountToPay.Text.Equals(""))
         {
             String amountToPay = TextBoxAmountToPay.Text;
             if (amountToPay.Equals(""))
             {
                 amountToPay = "0";
             }
             try
             {
                 con.Open();
                 SqlCommand command = con.CreateCommand();
                 command.CommandText = "uspBMcBEARCashFlowManagerUpdateAmountToPay";
                 command.CommandType = CommandType.StoredProcedure;
                 command.Parameters.AddWithValue("@amountToPay", amountToPay);
                 command.Parameters.AddWithValue("@networkId", this.userName);
                 command.ExecuteNonQuery();
                 LabelMessage.Text = "Value Updated";
             }
             catch (SqlException sqle)
             {
                 Logger.QuickLog(VariablesCashManager.ERROR_LOG_FILE_NAME, sqle.Message, "adminOptions.aspx: Page_PreRender()", "");
             }
             finally
             {
                 if (con != null)
                 {
                     con.Close();
                 }
             }
         }
         else
         {
             LabelMessage.Text = "Please enter a valid amount";
         }
     }
 }
Exemple #3
0
        protected bool IsValidManualEntry(bool isUpdate)
        {
            bool isValid = false;

            bool isLocationValid      = false;
            bool isBarcodeValid       = false;
            bool isGlCodeValid        = false;
            bool isVendorIdValid      = false;
            bool isVendorNameValid    = false;
            bool isInvoiceNumberValid = false;
            bool isInvoiceDateValid   = false;
            bool isAmountValid        = false;
            bool isCurrencyValid      = false;
            bool isDescriptionValid   = false;
            bool isOfficeValid        = false;

            if (RadioButtonListLocation.SelectedIndex != -1)
            {
                isLocationValid = true;
                toggleErrorLabel(LabelLocation, false);
            }

            if (TextBoxBarcode.Text.Length == 7 && bearCode.IsNumber(TextBoxBarcode.Text, true))
            {
                if ((!isUpdate && IsBarcodeUnique()) || isUpdate)
                {
                    isBarcodeValid = true;
                    toggleErrorLabel(LabelBarcode, false);
                    Session["barcode"] = TextBoxBarcode.Text;
                }
            }

            if (!DropDownListOffice.SelectedValue.Equals("-1") && DropDownListOffice.SelectedIndex != -1)
            {
                isOfficeValid = true;
                toggleErrorLabel(LabelOffice, false);
            }

            if (TextBoxGlCode.Text.Length == 5 && bearCode.IsNumber(TextBoxGlCode.Text, true))
            {
                isGlCodeValid = true;
                toggleErrorLabel(LabelGlCode, false);
            }

            if (bearCode.IsNumber(TextBoxVendorID.Text, true))
            {
                isVendorIdValid = true;
                toggleErrorLabel(LabelVendorID, false);
            }

            if (TextBoxVendorName.Text.Length < 100)
            {
                isVendorNameValid = true;
                toggleErrorLabel(LabelVendorName, false);
            }

            if (TextBoxInvoiceNumber.Text.Length < 30)
            {
                isInvoiceNumberValid = true;
                toggleErrorLabel(LabelInvoiceNumber, false);
            }

            if (bearCode.IsDate(TextBoxDate.Text))
            {
                isInvoiceDateValid = true;
                toggleErrorLabel(LabelInvoiceDate, false);
            }

            if (bearCode.IsNumber(TextBoxAmount.Text))
            {
                isAmountValid = true;
                toggleErrorLabel(LabelAmount, false);
            }

            if (RadioButtonListCurrency.SelectedIndex != -1)
            {
                isCurrencyValid = true;
                toggleErrorLabel(LabelCurrency, false);
            }

            if (TextBoxDescription.Text.Length < 500)
            {
                isDescriptionValid = true;
                toggleErrorLabel(LabelDescription, false);
            }

            if (isLocationValid && isOfficeValid && isGlCodeValid && isVendorIdValid && isVendorNameValid &&
                isBarcodeValid && isInvoiceNumberValid && isInvoiceDateValid && isAmountValid &&
                isCurrencyValid && isDescriptionValid)
            {
                isValid           = true;
                LabelMessage.Text = "";
            }
            else
            {
                StringBuilder message = new StringBuilder("<table>");
                message.Append("<tr><td colspan='2'><b><u>Error Messages:</u></b></td></tr>");

                if (!isLocationValid)
                {
                    message.Append(newTableRow("Location:", "Please Select a Location"));
                    toggleErrorLabel(LabelLocation, true);
                }

                if (!isBarcodeValid)
                {
                    if (TextBoxBarcode.Text.Equals(""))
                    {
                        message.Append(newTableRow("Barcode:", "Barcode may not be blank"));
                    }
                    else if (!IsBarcodeUnique())
                    {
                        message.Append(newTableRow("Barcode:", "This barcode already exists"));
                    }
                    else
                    {
                        message.Append(newTableRow("Barcode:", "Must be a number 7 digits long"));
                    }
                    toggleErrorLabel(LabelBarcode, true);
                }

                if (!isOfficeValid)
                {
                    message.Append(newTableRow("Office:", "Please select an Office"));
                    toggleErrorLabel(LabelOffice, true);
                }

                if (!isGlCodeValid)
                {
                    message.Append(newTableRow("GL Code:", "Must be a number 5 digits long"));
                    toggleErrorLabel(LabelGlCode, true);
                }

                if (!isVendorIdValid)
                {
                    message.Append(newTableRow("Vendor ID:", "Must use numeric characters only"));
                    toggleErrorLabel(LabelVendorID, true);
                }

                if (!isVendorNameValid)
                {
                    message.Append(newTableRow("Vendor Name:", "Maximum length of 100 characters"));
                    toggleErrorLabel(LabelVendorName, true);
                }

                if (!isInvoiceNumberValid)
                {
                    message.Append(newTableRow("Invoice #:", "Must be under 30 characters"));
                    toggleErrorLabel(LabelInvoiceNumber, true);
                }

                if (!isInvoiceDateValid)
                {
                    message.Append(newTableRow("Invoice Date:", "Please enter a valid Date in mm/dd/yyyy or yyyy/mm/dd format"));
                    toggleErrorLabel(LabelInvoiceDate, true);
                }

                if (!isAmountValid)
                {
                    message.Append(newTableRow("Amount:", "Please enter a valid amount"));
                    toggleErrorLabel(LabelAmount, true);
                }

                if (!isCurrencyValid)
                {
                    message.Append(newTableRow("Currency:", "Please select a currency"));
                    toggleErrorLabel(LabelCurrency, true);
                }

                if (!isDescriptionValid)
                {
                    message.Append(newTableRow("Description:", "Must be under 500 characters"));
                    toggleErrorLabel(LabelDescription, true);
                }

                message.Append("</table>");

                LabelMessage.Text = message.ToString();
            }

            return(isValid);
        }