예제 #1
0
 public static void AddParameter(Control o, SqlCommand c, String fieldname)
 {
     if (o is TextBox)
     {
         TextBox txt = (TextBox)o;
         if (txt.Text.Length > 0)
         {
             c.Parameters.AddWithValue(fieldname, txt.Text);
         }
         else
         {
             c.Parameters.AddWithValue(fieldname, DBNull.Value);
         }
     }
     else if (o is DateDropDown)
     {
         DateDropDown ddd = (DateDropDown)o;
         if (ddd.IsValid())
         {
             c.Parameters.AddWithValue(fieldname, ddd.Date);
         }
         else
         {
             c.Parameters.AddWithValue(fieldname, DBNull.Value);
         }
     }
     else if (o is DropDownList)
     {
         DropDownList dd = (DropDownList)o;
         if (dd.SelectedIndex > 0)
         {
             c.Parameters.AddWithValue(fieldname, dd.SelectedValue);
         }
         else
         {
             c.Parameters.AddWithValue(fieldname, DBNull.Value);
         }
     }
     else if (o is CheckBoxList)
     {
         CheckBoxList chk = (CheckBoxList)o;
         c.Parameters.AddWithValue(fieldname, MergeValues(chk));
     }
     else if (o is TrueFalseDropDown)
     {
         TrueFalseDropDown dd = (TrueFalseDropDown)o;
         if (dd.Value == null)
         {
             c.Parameters.AddWithValue(fieldname, DBNull.Value);
         }
         else
         {
             c.Parameters.AddWithValue(fieldname, dd.Value);
         }
     }
 }
예제 #2
0
        //public IWebElement ErrorCatch => Driver.FindElement(By.XPath("//*[@id='center_column']/div/ol/li"));


        public void FillForm(Registration user)
        {
            GenderRadioButtons[0].Click();
            FirstNameField.SendKeys(user.FirstName);
            LastNameField.SendKeys(user.LastName);
            PasswordField.SendKeys(user.Password);
            DateDropDown.SelectByValue(user.DateDropDown);
            monthsDropDown.SelectByValue(user.MonthsDropDown);
            yearDropDown.SelectByValue(user.YearDropDown);
            address.SendKeys(user.Address);
            city.SendKeys(user.City);
            StateDropDown.SelectByValue(user.StateDropDown);
            ZipCode.SendKeys(user.ZipCode);
            MobilePhone.SendKeys(user.MobilePhone);
            AliasAddress.SendKeys(user.AliasAddress);
            RegisterButton.Click();
        }
예제 #3
0
        public static void DisableControls(Control parent)
        {
            foreach (Control c in parent.Controls)
            {
                if (c is TextBox)
                {
                    TextBox d = (TextBox)c;
                    d.Enabled = false;
                }
                else if (c is DropDownList)
                {
                    DropDownList d = (DropDownList)c;
                    d.Enabled = false;
                }
                else if (c is DateDropDown)
                {
                    DateDropDown d = (DateDropDown)c;
                    d.Enabled = false;
                }
                else if (c is CheckBoxList)
                {
                    CheckBoxList d = (CheckBoxList)c;
                    foreach (ListItem f in d.Items)
                    {
                        f.Enabled = false;
                    }
                }
                else if (c is TrueFalseDropDown)
                {
                    TrueFalseDropDown d = (TrueFalseDropDown)c;
                    d.Enabled = false;
                }
                else if (c is DivisionDD)
                {
                    DivisionDD d = (DivisionDD)c;
                    d.Enabled = false;
                }

                DisableControls(c);
            }
        }
예제 #4
0
 public static void ClearControls(Control o)
 {
     foreach (Control c in o.Controls)
     {
         if (c is TextBox)
         {
             TextBox d = (TextBox)c;
             d.Text = String.Empty;
         }
         else if (c is DropDownList)
         {
             DropDownList d = (DropDownList)c;
             d.SelectedIndex = 0;
         }
         else if (c is DateDropDown)
         {
             DateDropDown d = (DateDropDown)c;
             d.ClearItems();
         }
         else if (c is CheckBoxList)
         {
             CheckBoxList d = (CheckBoxList)c;
             foreach (ListItem f in d.Items)
             {
                 f.Selected = false;
             }
         }
         else if (c is TrueFalseDropDown)
         {
             TrueFalseDropDown d = (TrueFalseDropDown)c;
             d.Clear();
         }
         else if (c is DivisionDD)
         {
             DivisionDD d = (DivisionDD)c;
             d.Clear();
         }
     }
 }