Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)            //Primera carga de la página
     {
         string Id = Request.QueryString["Id"];
         if ((string.IsNullOrEmpty(Id)) || (!IsNumeric(Id)))
         {
             Response.Redirect("ListaChoferes.aspx");
         }
         else
         {
             ChoferVO Chofer = BLLChofer.GetChoferById(int.Parse(Id));
             if (Chofer.IdChofer == int.Parse(Id))
             {
                 lblIdChofer.Text          = Chofer.IdChofer.ToString();
                 txtNombre.Text            = Chofer.Nombre;
                 txtApPaterno.Text         = Chofer.ApPaterno.ToString();
                 txtApMaterno.Text         = Chofer.ApMaterno.ToString();
                 txtTelefono.Text          = Chofer.Telefono.ToString();
                 inFechaNacimiento.Value   = Chofer.FechaNacimiento.ToString();
                 txtLicencia.Text          = Chofer.Licencia.ToString();
                 imgFotoChofer.ImageUrl    = Chofer.Urlfoto;
                 UrlFoto.InnerText         = Chofer.Urlfoto;
                 chkDisponibilidad.Checked = Chofer.Disponibilidad;
             }
             else
             {
                 Response.Redirect("ListaChoferes.aspx");
             }
         }
     }
 }
Beispiel #2
0
 public static string DelChofer(int IdChofer)
 {
     try
     {
         ChoferVO camion = DALChofer.GetChoferById(IdChofer);
         if (camion.Disponibilidad)
         {
             DALChofer.DelChofer(IdChofer);
             return("Chofer Eliminado");
         }
         else
         {
             return("El Chofer se encuentra en una ruta o no está disponible");
         }
     }
     catch (Exception ex) { return(ex.Message); }
 }        //DelCamion
        public static ChoferVO GetChoferById(int IdChofer)
        {
            try
            {
                string     Query = "GetChoferById";
                SqlCommand cmd   = new SqlCommand(Query, conn);
                cmd.Connection = conn;
                //DataTable Obtiene la Tabla
                SqlDataAdapter da = new SqlDataAdapter(cmd);                //Obtiene lo de un Select Command
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdChofer", IdChofer);

                DataSet dsChofer = new DataSet();                //Realiza una representacion en memoria
                da.Fill(dsChofer);
                if (dsChofer.Tables[0].Rows.Count > 0)
                {
                    //Encontro el Registro
                    DataRow  dr     = dsChofer.Tables[0].Rows[0];
                    ChoferVO chofer = new ChoferVO(dr);
                    return(chofer);
                }
                else
                {
                    //No se encontro el Camion
                    ChoferVO chofer = new ChoferVO();
                    return(chofer);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }        //GetCamionById