/*Este metodo se encagara de realizar el update del registro*/
        protected void grvClientes_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row         = grvClientes.Rows[e.RowIndex];
            int         customer_id = Convert.ToInt32(grvClientes.DataKeys[e.RowIndex].Values[0]);
            string      firstName   = (row.FindControl("txtfirst_name") as TextBox).Text;
            string      lastName    = (row.FindControl("txtlast_name") as TextBox).Text;
            string      phone       = (row.FindControl("txtphone") as TextBox).Text;
            string      email       = (row.FindControl("txtemail") as TextBox).Text;
            string      street      = (row.FindControl("txtstreet") as TextBox).Text;
            string      city        = (row.FindControl("txtcity") as TextBox).Text;
            string      state       = (row.FindControl("txtstate") as TextBox).Text;
            string      zip_code    = (row.FindControl("txtzip_code") as TextBox).Text;

            var customers = new DataAccess.customers
            {
                customer_id = customer_id,
                first_name  = firstName,
                last_name   = lastName,
                phone       = phone,
                email       = email,
                street      = street,
                city        = city,
                state       = state,
                zip_code    = zip_code
            };

            BusinessModel.Customers.UpdateCustomers(customers);
            grvClientes.EditIndex = -1;
            this.GetCustormers();
        }
Example #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string firstName = txtFirst_name.Text;
            string lastName  = txtLastName.Text;
            string phone     = txtPhone.Text;
            string email     = txtEmail.Text;
            string street    = txtStreet.Text;
            string city      = txtCity.Text;
            string state     = txtState.Text;
            string zip_code  = txtZipCode.Text;

            var customers = new DataAccess.customers
            {
                first_name = firstName,
                last_name  = lastName,
                phone      = phone,
                email      = email,
                street     = street,
                city       = city,
                state      = state,
                zip_code   = zip_code
            };

            BusinessModel.Customers.AddCustomers(customers);
            Response.Write("<script>alert('Data has been Added..');window.location = 'Customers.aspx';</script>");
        }