protected void vendor_type_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                customer_registration_entity customer = new customer_registration_entity();
                customer_registration_bal    cust_bal = new customer_registration_bal();
                customer.Vendor_type = vendor_type.Text;
                DataSet ds             = cust_bal.populate_vendor_bl(customer);
                double  balance_amount = cust_bal.populate_balance_bl(customer);
                bal.Text = balance_amount.ToString();
                vendor_name.DataSource     = ds;
                vendor_name.DataTextField  = "vendor_name";
                vendor_name.DataValueField = "vendor_name";
                vendor_name.DataBind();
                vendor_name.Items.Insert(0, new ListItem("Select Vendor Name", "0"));
            }
            catch (Exception)
            {
                // Code that runs when an unhandled error occurs
                Exception exception = Server.GetLastError();

                // Response.Write("<h2>Global Page Error</h2>\n");

                // Response.Write("<p>" + exception.Message + "</p>\n");

                ExceptionClass.LogException(exception);

                Server.Transfer("~/ErrorPage.aspx?message=http " + exception.Message);

                // Clear the error from the server

                Server.ClearError();
            }
        }
        protected void country_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string c = country.Text;
                customer_registration_entity customer = new customer_registration_entity();
                customer_registration_bal    cust_bal = new customer_registration_bal();
                customer.Country_name = c;
                DataSet ds = cust_bal.populate_state_bl(customer);
                state.DataSource     = ds;
                state.DataTextField  = "state_name";
                state.DataValueField = "state_name";
                state.DataBind();
                state.Items.Insert(0, new ListItem("Select State", "0"));
            }
            catch (Exception)
            {
                // Code that runs when an unhandled error occurs
                Exception exception = Server.GetLastError();

                // Response.Write("<h2>Global Page Error</h2>\n");

                // Response.Write("<p>" + exception.Message + "</p>\n");

                ExceptionClass.LogException(exception);

                Server.Transfer("~/ErrorPage.aspx?message=http " + exception.Message);

                // Clear the error from the server

                Server.ClearError();
            }
        }
        protected void Button1_Click1(object sender, EventArgs e)
        {
            try
            {
                customer_registration_entity customer = new customer_registration_entity();
                customer.Customer_name          = Cust_name.Text;
                customer.Address_details        = address.Text;
                customer.Country_name           = country.Text;
                customer.State_name             = state.Text;
                customer.Contact_number         = (contact.Text);
                customer.Document_detail_number = doc_num.Text;
                customer.Email_id          = email.Text;
                customer.Registration_date = reg_date.Text;
                customer.Vendor_name       = vendor_name.Text;
                customer.Card_number       = card.Text;
                customer.Balance           = Convert.ToSingle(bal.Text);
                customer.Vendor_type       = vendor_type.Text;
                customer_registration_bal cust_bal = new customer_registration_bal();
                int a = cust_bal.validate_customer(customer);
                if (a == 1)
                {
                    int s = cust_bal.insert(customer);
                    if (s > 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Registered')", true);
                    }
                    else if (s == -1)
                    {
                        Label_Cus_Reg_State.Text = "Select Valid Country and State";
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Failure')", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Customer is already Registered')", true);
                }
            }
            catch (Exception)
            {
                // Code that runs when an unhandled error occurs
                Exception exception = Server.GetLastError();

                // Response.Write("<h2>Global Page Error</h2>\n");

                // Response.Write("<p>" + exception.Message + "</p>\n");

                ExceptionClass.LogException(exception);

                Server.Transfer("~/ErrorPage.aspx?message=http " + exception.Message);

                // Clear the error from the server

                Server.ClearError();
            }
        }
        protected void doc_num_TextChanged(object sender, EventArgs e)
        {
            try
            {
                customer_registration_entity customer = new customer_registration_entity();
                customer_registration_bal    cust_bal = new customer_registration_bal();
                customer.Document_name          = id_doc.Text;
                customer.Document_detail_number = doc_num.Text;
                if (doc_num.Text != "")
                {
                    LabelDocDetNum.Text = " ";
                    string s = cust_bal.validate_doc(customer);
                    if (s == "invalid")
                    {
                        LabelDocDetNum.Text = "The document number you entered is invalid.!!";
                    }
                    else
                    {
                        LabelDocDetNum.Text = " ";
                    }
                }
                else
                {
                    LabelDocDetNum.Text = "Document Number is Required";
                }
            }
            catch (Exception)
            {
                // Code that runs when an unhandled error occurs
                Exception exception = Server.GetLastError();

                // Response.Write("<h2>Global Page Error</h2>\n");

                // Response.Write("<p>" + exception.Message + "</p>\n");

                ExceptionClass.LogException(exception);

                Server.Transfer("~/ErrorPage.aspx?message=http " + exception.Message);

                // Clear the error from the server

                Server.ClearError();
            }
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            cust_id.Text = GridView1.SelectedRow.Cells[1].Text;
            try
            {
                obj1.Customer_id = Convert.ToInt32(cust_id.Text);


                SqlDataReader rd1 = obj2.get_details_from_text_bl(obj1);
                if (rd1.HasRows)
                {
                    Label_U_Cust.Text = " ";
                    rd1.Read();
                    vendor_name1            = (rd1["vendor_name"].ToString());
                    vendor_type1            = (rd1["vendor_type"].ToString());
                    customer_name1          = (rd1["customer_name"].ToString());
                    contact_number1         = (rd1["contact_number"].ToString());
                    balance1                = (Convert.ToDecimal(rd1["balance"]));
                    email_id1               = (rd1["email_id"].ToString());
                    addres_details1         = (rd1["addres_details"].ToString());
                    country_id1             = (rd1["country_id"].ToString());
                    document_detail_number1 = (rd1["document_detail_number"].ToString());
                    registration_date1      = (rd1["registration_date"].ToString());
                    card_number1            = (rd1["card_number"].ToString());
                    vname_id.Enabled        = false;
                    vtype_id.Enabled        = false;
                    obj1.Country_id         = country_id1;
                    SqlDataReader rd2 = obj2.get_country_state_bl(obj1);

                    if (rd2.HasRows)
                    {
                        rd2.Read();
                        country_name1 = (string)rd2["country_name"];
                        state_name1   = (string)rd2["state_name"];
                    }

                    vname_id.Text    = vendor_name1;
                    vtype_id.Text    = vendor_type1;
                    cname_id.Text    = customer_name1;
                    contact_id.Text  = contact_number1;
                    balance_txt.Text = balance1.ToString();
                    email_id.Text    = email_id1;
                    add_id.Text      = addres_details1;
                    country_id.Text  = country_id1;
                    DropDownList_UCust_Country.SelectedIndex = DropDownList_UCust_Country.Items.IndexOf(DropDownList_UCust_Country.Items.FindByValue(country_name1));
                    {
                        string c = DropDownList_UCust_Country.Text;
                        customer_registration_entity customer = new customer_registration_entity();
                        customer_registration_bal    cust_bal = new customer_registration_bal();
                        customer.Country_name = c;
                        DataSet ds = cust_bal.populate_state_bl(customer);
                        DropDownList_UCust_State.DataSource     = ds;
                        DropDownList_UCust_State.DataTextField  = "state_name";
                        DropDownList_UCust_State.DataValueField = "state_name";
                        DropDownList_UCust_State.DataBind();
                        DropDownList_UCust_State.Items.Insert(0, new ListItem("Select State", "0"));
                    }
                    DropDownList_UCust_State.SelectedIndex = DropDownList_UCust_State.Items.IndexOf(DropDownList_UCust_State.Items.FindByValue(state_name1));
                    document_id.Text     = document_detail_number1;
                    registration_id.Text = registration_date1;
                    card_number.Text     = card_number1;
                    cust_id.Enabled      = false;

                    //rd2.Close();
                }
                else
                {
                    Label_U_Cust.Text = "Enter Valid Customer ID";
                    cust_id.Enabled   = true;
                }
            }
            catch (Exception)
            {
                // Code that runs when an unhandled error occurs
                Exception exception = Server.GetLastError();

                // Response.Write("<h2>Global Page Error</h2>\n");

                // Response.Write("<p>" + exception.Message + "</p>\n");

                ExceptionClass.LogException(exception);

                Server.Transfer("~/ErrorPage.aspx?message=http " + exception.Message);

                // Clear the error from the server

                Server.ClearError();
            }
        }
        protected void DropDownListVendor_id_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                obj1.Vendor_id = DropDownListVendor_id.SelectedValue;

                SqlDataReader rd1 = obj2.insert1(obj1);
                if (rd1.HasRows)
                {
                    rd1.Read();
                    Company_Registration_Number1 = (rd1["Company_Registration_Number"].ToString());
                    Vendor_Type1                 = (rd1["Vendor_Type"].ToString());
                    Vendor_Name1                 = (rd1["Vendor_Name"].ToString());
                    Certificate_Name1            = (rd1["Certificate_Name"].ToString());
                    Certificate_Issue_Date1      = (rd1["Certificate_Issue_Date"].ToString());
                    Certificate_Validation_Date1 = (rd1["certificate_validity_date"].ToString());
                    Year_Of_Establishment1       = (rd1["Year_Of_Establishment"].ToString());
                    Country1 = rd1["country_name"].ToString();
                    State1   = rd1["state_name"].ToString();

                    Address1        = (rd1["address_details"].ToString());
                    Contact_Number1 = (rd1["Contact_Number"].ToString());
                    Email_Id1       = (rd1["Email_Id"].ToString());
                    Website1        = (rd1["Website"].ToString());
                    Employee_Count1 = (rd1["employees_count"].ToString());
                    Customer_Count1 = (rd1["customer_count"].ToString());
                }


                c_r_n.Text            = Company_Registration_Number1;
                vendor_type.Text      = Vendor_Type1;
                vendor_name.Text      = Vendor_Name1;
                certificate_name.Text = Certificate_Name1;
                c_i_d.Text            = Certificate_Issue_Date1;
                c_v_d.Text            = Certificate_Validation_Date1;
                yoe.Text = Year_Of_Establishment1;

                DropDownList_UVend_Country.SelectedIndex = DropDownList_UVend_Country.Items.IndexOf(DropDownList_UVend_Country.Items.FindByValue(Country1));
                {
                    string d = DropDownList_UVend_Country.Text;
                    customer_registration_entity customer = new customer_registration_entity();
                    customer_registration_bal    cust_bal = new customer_registration_bal();
                    customer.Country_name = d;
                    DataSet ds = cust_bal.populate_state_bl(customer);
                    DropDownList_UVend_State.DataSource     = ds;
                    DropDownList_UVend_State.DataTextField  = "state_name";
                    DropDownList_UVend_State.DataValueField = "state_name";
                    DropDownList_UVend_State.DataBind();
                    DropDownList_UVend_State.Items.Insert(0, new ListItem("Select State", "0"));
                }
                DropDownList_UVend_State.SelectedIndex = DropDownList_UVend_State.Items.IndexOf(DropDownList_UVend_State.Items.FindByValue(State1));
                address.Text                  = Address1;
                contact_number.Text           = Contact_Number1;
                email_id.Text                 = Email_Id1;
                website.Text                  = Website1;
                emp_count.Text                = Employee_Count1;
                cust_count.Text               = Customer_Count1;
                DropDownListVendor_id.Enabled = false;
            }
            catch (Exception)
            {
                // Code that runs when an unhandled error occurs
                Exception exception = Server.GetLastError();

                // Response.Write("<h2>Global Page Error</h2>\n");

                // Response.Write("<p>" + exception.Message + "</p>\n");

                ExceptionClass.LogException(exception);

                Server.Transfer("~/ErrorPage.aspx?message=http " + exception.Message);

                // Clear the error from the server

                Server.ClearError();
            }
        }