Пример #1
0
        private void BindGender()
        {
            DropDownListGender.DataSource     = Gender.GetGenderList();
            DropDownListGender.DataTextField  = "Description";
            DropDownListGender.DataValueField = "GenderId";
            DropDownListGender.DataBind();

            if (DropDownListGender.Items.Count > 1)
            {
                DropDownListGender.Items.Insert(0, new ListItem("Please select", "0"));
            }
        }
Пример #2
0
        private bool IsValidData()
        {
            if (ButtonRegister.Text == "Update")
            {
                if (string.IsNullOrEmpty(TextBoxSupId.Text))
                {
                    Globals.MessageBoxShow(this, "Please Choose a Customer to Edit");
                    TextBoxSupId.Focus();
                    return(false);
                }
            }

            if (string.IsNullOrEmpty(TextBoxSupName.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Customer Name");
                TextBoxSupName.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(TextBoxZipCode.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Zip Code");
                TextBoxZipCode.Focus();
                return(false);
            }
            else
            {
                string zipCodePattern = @"[0-9]{6}";
                bool   isZipValid     = true;
                isZipValid = Regex.IsMatch(TextBoxZipCode.Text, zipCodePattern);
                if (!isZipValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid Zip Code");
                    TextBoxZipCode.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxSupPhno.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Phone Number");
                TextBoxSupPhno.Focus();
                return(false);
            }
            else
            {
                string phnoPattern = @"[0-9]{10}";
                bool   isphnoValid = true;
                isphnoValid = Regex.IsMatch(TextBoxSupPhno.Text, phnoPattern);
                if (!isphnoValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid Phone Number");
                    TextBoxSupPhno.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxEmail.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Email");
                TextBoxEmail.Focus();
                return(false);
            }
            else
            {
                string emailPattern = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
                bool   isemailValid = true;
                isemailValid = Regex.IsMatch(TextBoxEmail.Text, emailPattern);
                if (!isemailValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid Email");
                    TextBoxEmail.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxGSTNo.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter GST No");
                TextBoxGSTNo.Focus();
                return(false);
            }
            else
            {
                string gstPattern = @"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$";
                bool   isgstValid = true;
                isgstValid = Regex.IsMatch(TextBoxGSTNo.Text, gstPattern);
                if (!isgstValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid GST No");
                    TextBoxGSTNo.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxState.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter State");
                TextBoxState.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(TextBoxCity.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter City");
                TextBoxCity.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(TextBoxAddress.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Address");
                TextBoxAddress.Focus();
                return(false);
            }
            if (DropDownListCountry.SelectedItem.Text == "Select Country")
            {
                Globals.MessageBoxShow(this, "Please Select Country");
                DropDownListCountry.Focus();
                return(false);
            }
            if (DropDownListGender.SelectedItem.Text == "Gender")
            {
                Globals.MessageBoxShow(this, "Please Select Gender");
                DropDownListGender.Focus();
                return(false);
            }
            return(true);
        }
Пример #3
0
 protected void Btn_calculate_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txt_weight.Text) || string.IsNullOrEmpty(txt_time.Text) || string.IsNullOrEmpty(txt_amount.Text) ||
         string.IsNullOrEmpty(txt_servings.Text) || string.IsNullOrEmpty(txt_servings.Text) || string.IsNullOrEmpty(DropDownListGender.ToString()))
     {
         MsgBox("All fields need to be full!");
     }
     else
     {
         resultBAC = BACcalculator.countBloodAlcoholContent(convertedWeight, convertedAmount, inputTime,
                                                            inputAlcohol, r, inputServings);
         note = BACcalculator.bacResultMessage(resultBAC);
         //Console.Write(note);
         MsgBox(note);
     }
 }
Пример #4
0
        protected void Btn_save_Click(object sender, EventArgs e)
        {
            Double.TryParse(txt_weight.Text, out inputWeight);
            if (inputWeight < 0 || inputWeight > 500)
            {
                MsgBox("Your weight can't be negative, please correct it.");
            }
            else
            {
                convertedWeight = BACcalculator.convertWeightToPounds(inputWeight);
            }

            Double.TryParse(txt_time.Text, out inputTime);
            if (inputTime < 0 || inputTime > 24)
            {
                MsgBox("Time input is wrong, please correct it");
            }

            Double.TryParse(txt_alcohol.Text, out inputAlcohol);
            if (inputAlcohol < 0 || inputAlcohol > 100)
            {
                MsgBox("Percentage of alcohol can't be less tha 0% or more than 100%, please correct it");
            }

            Double.TryParse(txt_amount.Text, out inputAmount);
            if (inputAmount < 0)
            {
                MsgBox("Consumed amount of beverage can't be negative, please correct it");
            }
            else
            {
                convertedAmount = BACcalculator.convertAmountToOunces(inputAmount);
            }

            int.TryParse(txt_servings.Text, out inputServings);
            if (inputServings < 0)
            {
                MsgBox("Total number of servings can't be negative, please correct it");
            }

            if (DropDownListGender.SelectedIndex == -1)
            {
                MsgBox("You have to select your gender");
            }
            else if (DropDownListGender.SelectedItem.ToString() == "Female")
            {
                r = 0.66;
            }

            else if (DropDownListGender.SelectedItem.ToString() == "Male")
            {
                r = 0.73;
            }

            if (string.IsNullOrEmpty(txt_weight.Text) || string.IsNullOrEmpty(txt_time.Text) || string.IsNullOrEmpty(txt_amount.Text) ||
                string.IsNullOrEmpty(txt_servings.Text) || string.IsNullOrEmpty(txt_servings.Text) || string.IsNullOrEmpty(DropDownListGender.ToString()))
            {
                MsgBox("All fields need to be full!");
            }
            else
            {
                MsgBox("All data is successfully saved, you can now calculate your BAC");
            }
        }