protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = GV_Pilots.Rows[e.RowIndex];
            int idPilot= Convert.ToInt32(GV_Pilots.DataKeys[e.RowIndex].Values[0]);
            string mail = (row.FindControl("txtEmail") as TextBox).Text;
            string name = (row.FindControl("txtFstName") as TextBox).Text;
            string lstName = (row.FindControl("txtLstName") as TextBox).Text;
            string cert = (row.FindControl("txtCert") as TextBox).Text;
            string flightTime = (row.FindControl("txtTVuelo") as TextBox).Text;
            string certDate = (row.FindControl("txtCertDate") as TextBox).Text;

            using (DroidikaContextDataContext ctx = new DroidikaContextDataContext())
            {
                dPilot pil = (from p in ctx.dPilots
                              where p.id == idPilot
                                select p).FirstOrDefault();
                pil.email = mail;
                pil.fstName = name;
                pil.lstName = lstName;
                pil.certificate = char.Parse(cert);
                pil.flightTime = Int32.Parse(flightTime);
                pil.certificateDate = DateTime.Parse(certDate);
                ctx.SubmitChanges();
            }
            GV_Pilots.EditIndex = -1;
            this.BindGrid();
        }
Ejemplo n.º 2
0
        protected void Insert(object sender, EventArgs e)
        {
            lblMensaje.Text = "";
             if (txtBrand.Text != "" && txtCostUSD.Text != "" && txtModel.Text != "")
             {

                 using (DroidikaContextDataContext ctx = new DroidikaContextDataContext())
                 {
                     dCatDrone drone = new dCatDrone
                     {
                         brand = txtBrand.Text,
                         model = txtModel.Text,
                         costUsd = decimal.Parse(txtCostUSD.Text),
                         flightTime = Int32.Parse(txtFlightTime.Text)
                     };
                     ctx.dCatDrones.InsertOnSubmit(drone);
                     ctx.SubmitChanges();
                 }

                 this.BindGrid();
             }
             else
             {
                 lblMensaje.Text = "Favor de introducir los campos requeridos.";
             }
        }
 protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int idCatCam = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);
     using (DroidikaContextDataContext ctx = new DroidikaContextDataContext())
     {
         dCatCamera cam = (from c in ctx.dCatCameras
                           where c.id == idCatCam
                           select c).FirstOrDefault();
         ctx.dCatCameras.DeleteOnSubmit(cam);
         ctx.SubmitChanges();
     }
     this.BindGrid();
 }
        protected void Insert(object sender, EventArgs e)
        {
            using (DroidikaContextDataContext ctx = new DroidikaContextDataContext())
            {
                dCatCamera cam = new dCatCamera
                {
                    brand = txtBrand.Text,
                    model = txtModel.Text,
                    costUsd = decimal.Parse(txtCostUSD.Text),
                };
                ctx.dCatCameras.InsertOnSubmit(cam);
                ctx.SubmitChanges();
            }

            this.BindGrid();
        }
Ejemplo n.º 5
0
 protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     GridViewRow row = GridView1.Rows[e.RowIndex];
     int idCatDrones = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);
     string brand = (row.FindControl("txtBrand") as TextBox).Text;
     string model = (row.FindControl("txtModel") as TextBox).Text;
     string costUsd = (row.FindControl("txtCostUSD") as TextBox).Text;
     string flightTime = (row.FindControl("txtFlightTime") as TextBox).Text;
     using (DroidikaContextDataContext ctx = new DroidikaContextDataContext())
     {
         dCatDrone drone = (from c in ctx.dCatDrones
                               where c.id == idCatDrones
                              select c).FirstOrDefault();
         drone.brand = brand;
         drone.model = model;
         drone.costUsd = decimal.Parse(costUsd);
         drone.flightTime = Int32.Parse(flightTime);
         ctx.SubmitChanges();
     }
     GridView1.EditIndex = -1;
     this.BindGrid();
 }