Exemple #1
0
 //ACTUALIZAR
 public void actualizarRuta(int indice, RUTA ruta)
 {
     using (TransactionScope transaction = new TransactionScope())
     {
         var objRuta = modeloEntidades.RUTAs.Where(qq => qq.IDRUTA == indice).Single();
         modeloEntidades.Entry(objRuta).CurrentValues.SetValues(ruta);
         modeloEntidades.SaveChanges();
         transaction.Complete();
     }
 }
Exemple #2
0
 //INSERTAR
 public void insertarRuta(RUTA ruta)
 {
     using (TransactionScope transaction = new TransactionScope())
     {
         using (modeloEntidades)
         {
             modeloEntidades.RUTAs.Add(ruta);
             modeloEntidades.SaveChanges();
             transaction.Complete();
         }
     }
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            String strError = "";
            Boolean bolError = false;

            if (txtLugarLlegada.Text == "")
            {
                strError += "El lugar de llegada es obligatorio\n";
                bolError = true;
            }
            if (txtLugarSalida.Text == "")
            {
                strError += "El lugar de salida es obligatorio\n";
                bolError = true;
            }

            if (!bolError)
            {
                if (MessageBox.Show("¿Actualizar la Ruta?", "Actualizar Ruta", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    RUTA ruta = new RUTA();
                    ruta.IDRUTA = Int32.Parse(dgvRutas.Rows[dgvRutas.SelectedRows[0].Index].Cells[0].Value.ToString());
                    ruta.LUGARLLEGADA = txtLugarLlegada.Text;
                    ruta.LUGARSALIDA = txtLugarSalida.Text;
                    ruta.CODRUTA = txtLugarLlegada.Text.Substring(0, 3) + "-" + txtLugarSalida.Text.Substring(0, 3);
                    (new clsRutaBLL()).actualizarRuta((int) ruta.IDRUTA, ruta);

                }

                MessageBox.Show("La ruta ha sido actualizada satisfactoriamente");
                cargarRutasDataGridView();
                limpiarTodo();
                habilitarControles(false);
                //dgvEmpleado.ClearSelection();
            }
            else
            {
                MessageBox.Show(strError);
            }
        }