Пример #1
0
        protected void CountryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                HRSCustomersBLL customerBLLObject = new HRSCustomersBLL();
                var             states            = customerBLLObject.GetState(Convert.ToInt32(CountryDropDownList.SelectedItem.Value));
                StateDropDownList.DataSource     = states;
                StateDropDownList.DataTextField  = "Value";
                StateDropDownList.DataValueField = "Key";
                StateDropDownList.DataBind();
                StateDropDownList.Focus();

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$(function () {");
                sb.Append(" $('#Register').modal('show');});");
                sb.Append("</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModelScript", sb.ToString(), false);
                StateDropDownList.Focus();
            }
            catch (Exception ex)
            {
                Utility.ExceptionUtility.ExceptionLog(ex);
                throw;
            }
        }
    protected void CountryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList countryDropDownList = (DropDownList)sender;

        try
        {
            ServiceAccess serviceLoader = ServiceAccess.GetInstance();

            StateDropDownList.Items.Clear();
            int countryId = Convert.ToInt32(countryDropDownList.SelectedValue);

            if (countryId == 0)
            {
                StateDropDownList.Items.Add(new ListItem("&lt;Select a State&gt;", "0"));
            }
            else
            {
                CommonService.CommonService     commonService = serviceLoader.GetCommon();
                IList <CommonService.StateInfo> states        = commonService.GetStates(countryId);

                StateDropDownList.DataSource     = states;
                StateDropDownList.DataValueField = "StateId";
                StateDropDownList.DataTextField  = "Name";
                StateDropDownList.DataBind();
            }
        }
        catch (Exception ex)
        {
            log.Error("UNKNOWN ERROR:", ex);
        }
    }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int.TryParse(Request.QueryString["id"], out CarrierID);
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GHMConnectionString"].ConnectionString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("spGetCarrierAddress", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id", CarrierID);
                SqlDataReader rdr = cmd.ExecuteReader();
                rdr.Read();
                rdr.Close();
                conn.Close();
            }
            string getstates = "SELECT * from State";

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GHMConnectionString"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(getstates, conn);
                conn.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                StateDropDownList.DataSource     = rdr;
                StateDropDownList.DataTextField  = "Name";
                StateDropDownList.DataValueField = "Id";
                StateDropDownList.DataBind();
                rdr.Close();
                conn.Close();
            }
        }
Пример #4
0
        protected void AddressDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int i = Int32.Parse(AddressDropDownList.SelectedValue.ToString());

            if (i == 0)
            {
                DescriptionTextBox.Text           = "";
                Address1TextBox.Text              = "";
                Address2TextBox.Text              = "";
                Address3TextBox.Text              = "";
                CityTextBox.Text                  = "";
                ZipTextBox.Text                   = "";
                CountryDropDownList.SelectedValue = "1";
                StateDropDownList.SelectedValue   = "1";
            }
            else
            {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GHMConnectionString"].ConnectionString))
                {
                    SqlCommand cmd = new SqlCommand("spGetAddressDetails", conn);

                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@id", i);

                    conn.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();

                    rdr.Read();
                    DescriptionTextBox.Text           = rdr["AddressDescription"].ToString();
                    Address1TextBox.Text              = rdr["AddressLine1"].ToString();
                    Address2TextBox.Text              = rdr["AddressLine2"].ToString();
                    Address3TextBox.Text              = rdr["AddressLine3"].ToString();
                    CityTextBox.Text                  = rdr["City"].ToString();
                    ZipTextBox.Text                   = rdr["Zip"].ToString();
                    CountryDropDownList.SelectedValue = rdr["CountryID"].ToString();
                    if (CountryDropDownList.SelectedValue == "2")
                    {
                        StateLabel.Text = "Province:";
                        string getprovinces = "SELECT * from Province";
                        using (SqlConnection conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["GHMConnectionString"].ConnectionString))
                        {
                            SqlCommand cmd2 = new SqlCommand(getprovinces, conn2);
                            conn2.Open();
                            SqlDataReader rdr2 = cmd2.ExecuteReader();
                            StateDropDownList.DataSource     = rdr2;
                            StateDropDownList.DataTextField  = "Name";
                            StateDropDownList.DataValueField = "Id";
                            StateDropDownList.DataBind();
                            rdr2.Close();
                            conn2.Close();
                        }
                    }
                    StateDropDownList.SelectedValue = rdr["StateID"].ToString();

                    rdr.Close();
                    conn.Close();
                }
            }
        }
Пример #5
0
 protected void CountryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         HRSCustomersBLL customerBLLObject = new HRSCustomersBLL();
         var             states            = customerBLLObject.GetState(Convert.ToInt32(CountryDropDownList.SelectedItem.Value));
         StateDropDownList.DataSource     = states;
         StateDropDownList.DataTextField  = "Value";
         StateDropDownList.DataValueField = "Key";
         StateDropDownList.DataBind();
         StateDropDownList.Focus();
     }
     catch (Exception ex)
     {
         Utility.ExceptionUtility.ExceptionLog(ex);
         throw;
     }
 }
Пример #6
0
 protected void CountryDropDownList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (CountryDropDownList.SelectedValue == "1")
     {
         StateLabel.Text = "State:";
         string getstates = "SELECT * from State";
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GHMConnectionString"].ConnectionString))
         {
             SqlCommand cmd = new SqlCommand(getstates, conn);
             conn.Open();
             SqlDataReader rdr = cmd.ExecuteReader();
             StateDropDownList.DataSource     = rdr;
             StateDropDownList.DataTextField  = "Name";
             StateDropDownList.DataValueField = "Id";
             StateDropDownList.DataBind();
             rdr.Close();
             conn.Close();
         }
         return;
     }
     if (CountryDropDownList.SelectedValue == "2")
     {
         StateLabel.Text = "Province:";
         string getprovinces = "SELECT * from Province";
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GHMConnectionString"].ConnectionString))
         {
             SqlCommand cmd = new SqlCommand(getprovinces, conn);
             conn.Open();
             SqlDataReader rdr = cmd.ExecuteReader();
             StateDropDownList.DataSource     = rdr;
             StateDropDownList.DataTextField  = "Name";
             StateDropDownList.DataValueField = "Id";
             StateDropDownList.DataBind();
             rdr.Close();
             conn.Close();
         }
         return;
     }
 }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string constring = ConfigurationManager.ConnectionStrings["RKCS"].ConnectionString;

            using (SqlConnection con = new SqlConnection(constring))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("Select count(*) from Volunteers", con);
                count           = Convert.ToInt32(cmd.ExecuteScalar());
                CountLabel.Text = count.ToString();
                if (!IsPostBack)
                {
                    SqlDataAdapter    da    = new SqlDataAdapter("Select * from State", con);
                    SqlCommandBuilder build = new SqlCommandBuilder(da);
                    DataSet           ds    = new DataSet();
                    da.Fill(ds, "State");
                    StateDropDownList.DataSource     = ds;
                    StateDropDownList.DataTextField  = "StateName";
                    StateDropDownList.DataValueField = "StateId";
                    StateDropDownList.DataBind();
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //load option for Gender
                try
                {
                    using (SqlConnection connection = GetConnection())
                    {
                        SqlCommand    command = new SqlCommand("Select * from options where qid = 1", connection);
                        SqlDataReader reader  = command.ExecuteReader();
                        GenderDropdownList.DataSource     = reader;
                        GenderDropdownList.DataTextField  = "description";
                        GenderDropdownList.DataValueField = "oid";
                        GenderDropdownList.DataBind();
                        GenderDropdownList.Items.Insert(0, new ListItem("Please select", "Default value"));
                    }
                }
                catch (SqlException ex)
                {
                    Console.WriteLine("Error: " + ex);
                }

                //load option for State
                try
                {
                    using (SqlConnection connection = GetConnection())
                    {
                        SqlCommand    command = new SqlCommand("Select * from options where qid = 3", connection);
                        SqlDataReader reader  = command.ExecuteReader();

                        StateDropDownList.DataSource     = reader;
                        StateDropDownList.DataTextField  = "description";
                        StateDropDownList.DataValueField = "oid";
                        StateDropDownList.DataBind();
                        StateDropDownList.Items.Insert(0, new ListItem("Please select", "Default value"));
                    }
                }
                catch (SqlException ex)
                {
                    Console.WriteLine("Error: " + ex);
                }

                //load option for Bank
                try
                {
                    using (SqlConnection connection = GetConnection())
                    {
                        SqlCommand    command = new SqlCommand("Select * from options where qid = 7", connection);
                        SqlDataReader reader  = command.ExecuteReader();
                        BankDropdownList.DataSource     = reader;
                        BankDropdownList.DataTextField  = "description";
                        BankDropdownList.DataValueField = "oid";
                        BankDropdownList.DataBind();
                        BankDropdownList.Items.Insert(0, new ListItem("Please select", "Default value"));
                    }
                }
                catch (SqlException ex)
                {
                    Console.WriteLine("Error: " + ex);
                }

                //load option for Service
                try
                {
                    using (SqlConnection connection = GetConnection())
                    {
                        SqlCommand    command = new SqlCommand("Select * from options where qid = 13", connection);
                        SqlDataReader reader  = command.ExecuteReader();

                        ServiceDropdownList.DataSource     = reader;
                        ServiceDropdownList.DataTextField  = "description";
                        ServiceDropdownList.DataValueField = "oid";
                        ServiceDropdownList.DataBind();
                        ServiceDropdownList.Items.Insert(0, new ListItem("Please select", "Default value"));
                    }
                }
                catch (SqlException ex)
                {
                    Console.WriteLine("Error: " + ex);
                }
            }
        }