Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- public partial class _12 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- RellenarGridView();
- }
- protected void RellenarGridView()
- {
- DataClassesDataContext db = new DataClassesDataContext();
- var qry = from ship in db.Shippers
- select ship;
- GridView1.DataSource = qry;
- GridView1.DataBind();
- }
- protected void Actualizar(int id)
- {
- DataClassesDataContext db = new DataClassesDataContext();
- var qry = (from ship in db.Shippers
- where ship.ShipperID == id
- select ship).Single();
- qry.CompanyName = txtBxCompanyName.Text;
- qry.Phone = txtBxPhone.Text;
- db.SubmitChanges();
- }
- protected void Insertar()
- {
- DataClassesDataContext db = new DataClassesDataContext();
- Shippers ship = new Shippers();
- ship.CompanyName = txtBxCompanyName.Text;
- ship.Phone = txtBxPhone.Text;
- db.Shippers.InsertOnSubmit(ship);
- db.SubmitChanges();
- }
- protected void Eliminar(int id)
- {
- DataClassesDataContext db = new DataClassesDataContext();
- var qry = (from ship in db.Shippers
- where ship.ShipperID == id
- select ship).Single();
- db.Shippers.DeleteOnSubmit(qry);
- db.SubmitChanges();
- }
- protected void Button1_Click1(object sender, EventArgs e)
- {
- Actualizar(Convert.ToInt32(txtId.Text));
- RellenarGridView();
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- Insertar();
- RellenarGridView();
- }
- protected void Button3_Click(object sender, EventArgs e)
- {
- Eliminar(Convert.ToInt32(txtId.Text));
- RellenarGridView();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement