コード例 #1
0
 protected void DDLCamion_SelectedIndexChanged(object sender, EventArgs e)
 {
     //Obtenemos la capacidad del camión seleccionado
     if (DDLCamion.SelectedValue != "")
     {
         //Traemos la capacidad y la asignamos a txtCapCamion
         CamionVO Camion = BLLCamiones.GetCamionById(int.Parse(DDLCamion.SelectedValue));
         txtCapCamion.Text = Camion.Capacidad.ToString();
     }
     else
     {
         txtCapCamion.Text = "";
     }
 }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)            //Primera carga de la página
            {
                Util.Library.UtilControls.EnumToListBox(typeof(Marca), DDLMarca, false);
                Util.Library.UtilControls.EnumToListBox(typeof(Tipo), DDLTipoCamion, false);
                LlenarModelo();

                DDLMarca.Items.Insert(0, new ListItem("Selecciona Marca", ""));
                DDLTipoCamion.Items.Insert(0, new ListItem("Selecciona Modelo", ""));

                DDLMarca.SelectedIndex      = 0;
                DDLModelo.SelectedIndex     = 0;
                DDLTipoCamion.SelectedIndex = 0;

                string Id = Request.QueryString["Id"];
                if ((string.IsNullOrEmpty(Id)) || (!IsNumeric(Id)))
                {
                    Response.Redirect("ListaCamiones.aspx");
                }
                else
                {
                    CamionVO Camion = BLLCamiones.GetCamionById(int.Parse(Id));
                    if (Camion.IdCamion == int.Parse(Id))
                    {
                        lblIdCamion.Text            = Camion.IdCamion.ToString();
                        txtMatricula.Text           = Camion.Matricula;
                        txtCapacidad.Text           = Camion.Capacidad.ToString();
                        txtKilometraje.Text         = Camion.Kilometraje.ToString();
                        DDLTipoCamion.SelectedValue = Camion.TipoCamion;
                        DDLMarca.SelectedValue      = Camion.Marca;
                        DDLModelo.SelectedValue     = Camion.Modelo.ToString();
                        imgFotoCamion.ImageUrl      = Camion.UrlFoto;
                        UrlFoto.InnerText           = Camion.UrlFoto;
                        chkDisponibilidad.Checked   = Camion.Disponibilidad;
                    }
                    else
                    {
                        Response.Redirect("ListaCamiones.aspx");
                    }
                }
            }
        }
コード例 #3
0
 public static string DelCamion(int IdCamion)
 {
     try
     {
         CamionVO camion = DALCamiones.GetCamionById(IdCamion);
         if (camion.Disponibilidad)
         {
             DALCamiones.DelCamion(IdCamion);
             return("Camión Eliminado");
         }
         else
         {
             return("El camion no se puede eliminar se encuentra en ruta");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
コード例 #4
0
        }        //DeleteCamion

        public static CamionVO GetCamionById(int IdCamion)
        {
            try
            {
                //varibblee de tip string donde vamos a
                string Query = "GetCamionById";
                //instancia de
                SqlCommand cmd = new SqlCommand(Query, con);

                cmd.Connection = con;
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                // indiga que es un strore prcedudee
                cmd.CommandType = CommandType.StoredProcedure;
                //Paso de parametros
                cmd.Parameters.AddWithValue("@IdCamion", IdCamion);

                DataSet dsCamion = new DataSet();
                adapter.Fill(dsCamion);
                if (dsCamion.Tables[0].Rows.Count > 0)
                {
                    //encontro un registro
                    DataRow  dr     = dsCamion.Tables[0].Rows[0];
                    CamionVO camion = new CamionVO(dr);
                    return(camion);
                }
                else
                {
                    // la tabla esta vacía
                    CamionVO camion = new CamionVO();
                    return(camion);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }