public void insert(customer_class cc)
        {
            SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False");
            SqlDataAdapter da = new SqlDataAdapter("select * from customer",con);
            DataSet ds = new DataSet();
            da.Fill(ds,"customer");
            DataRow dr = ds.Tables[0].NewRow();
            dr[0] = cc._id;
            dr[1] = cc._name;
            dr[2] = cc._father;
            dr[3] = cc._address;
            dr[4] = "empty";
            dr[5] = cc._email;
            dr[6] = cc._contact;
            dr[7] = cc._dob;
            dr[8] = cc._pin;
            dr[9] = cc._dist;
            dr[10] = cc._dealer_id;
            dr[11] = 0;
            dr[12] = 6; 
            dr[13] = "PENDING";
            dr[14] = DateTime.Today.ToString("dd/MM/yyyy") ;  


            ds.Tables[0].Rows.Add(dr);
            SqlCommandBuilder cb = new SqlCommandBuilder(da);
            da.Update(ds.Tables[0]);  
  
 
 
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if ((TextBox1.Text =="" ) || (TextBox3.Text == "") || (TextBox4.Text == "") || (TextBox5.Text == "") || (TextBox6.Text == "") || (TextBox7.Text == "") || (DropDownList1.SelectedItem.ToString() == "Select") || (DropDownList2.SelectedItem.ToString() == "Select") || (DropDownList3.SelectedItem.ToString() == "Select"))
            {

                Label13.Text = "Error in submitting application! Please resubmit!";
            }
            else
            {

                customer_keeper ck = new customer_keeper();
                int id = ck.get_id();
                customer_class cc = new customer_class();
                cc._id = id;
                cc._name = TextBox1.Text;
                cc._father = TextBox4.Text;
                cc._address = TextBox3.Text;
                cc._email = TextBox2.Text;
                cc._contact = TextBox6.Text;
                cc._dist = DropDownList3.SelectedItem.ToString();
                cc._pin = TextBox5.Text;
                cc._dob = TextBox7.Text;  

                dealer_keeper dk = new dealer_keeper();
                int dealer = dk.GetDealerID(cc._dist);
                cc._dealer_id = dealer;

                ck.insert(cc);

                Label12.Text = "Your New connection request has been submitted for Validation.";
                Label13.Text = "Customer ID " + id.ToString();

            }
            
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["cc"] = new customer_class();  
            }

        }
        public void update(customer_class cc)
        {
            SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False");
            SqlDataAdapter da = new SqlDataAdapter("select * from customer", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "customer");
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (int.Parse(dr[0].ToString()) == cc._id)
                {
                    dr.BeginEdit();
                    dr[1] = cc._name;
                    dr[2] = cc._father;
                    dr[3] = cc._address;
                    dr[4] = cc._pass;
                    dr[5] = cc._email;
                    dr[6] = cc._contact;
                    dr[7] = cc._dob;
                    dr[8] = cc._pin;
                    dr[9] = cc._dist;
                    dr[10] = cc._dealer_id;
                    dr[11] = cc._booking_count;
                    dr[12] = cc._subsidy_count;
                    dr[13] = cc._status;
                    dr[14] = cc._renewal; 
                    dr.EndEdit(); 
                }

            }
            SqlCommandBuilder cb = new SqlCommandBuilder(da);
            da.Update(ds.Tables[0]);


        }
        public customer_class GetData(int id)
        {
            customer_class cc = new customer_class();
            SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False");
            SqlDataAdapter da = new SqlDataAdapter("select * from customer", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "customer");

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (int.Parse(dr[0].ToString()) == id)
                {
                    cc._id = id;
                    cc._name = dr[1].ToString();
                    cc._father = dr[2].ToString();
                    cc._address = dr[3].ToString();
                    cc._pass = dr[4].ToString();
                    cc._email = dr[5].ToString();
                    cc._contact = dr[6].ToString();
                    cc._dob = dr[7].ToString();
                    cc._pin = dr[8].ToString();
                    cc._dist = dr[9].ToString();
                    cc._dealer_id = int.Parse(dr[10].ToString());
                    cc._booking_count = int.Parse(dr[11].ToString());
                    cc._subsidy_count = int.Parse(dr[12].ToString());
                    cc._status = dr[13].ToString();
                    cc._renewal = (DateTime )dr[14] ;

                }
            }
            return cc;
        }