protected void EliminarButton_Click(object sender, EventArgs e)
        {
            Motores motor = new Motores();

            ObtenerValores(motor);
            if (MotorIdTextBox.Text.Length == 0)
            {
                Validaciones.ShowToastr(this, "Advertencia", "Debe insertar un Id", "warning");
            }
            else
            {
                if (motor.Buscar(motor.MotorId))
                {
                    if (motor.Eliminar())
                    {
                        Validaciones.ShowToastr(this, "Exito", "Eliminado correctamente!", "success");
                        Limpiar();
                    }
                    else
                    {
                        Validaciones.ShowToastr(this, "Error", "Error al eliminar", "error");
                    }
                }
                else
                {
                    Validaciones.ShowToastr(this, "Advertencia", "Id no encontrado", "warning");
                    Limpiar();
                }
            }
        }
        protected void EliminarBtn_Click(object sender, EventArgs e)
        {
            Motores   motor    = new Motores();
            Utilerias utileria = new Utilerias();
            bool      suiche   = false;

            motor.Buscar(utileria.ConvertirValor(BuscarIdTextBox.Text));

            if (suiche)
            {
                if (motor.Eliminar())
                {
                    Utilerias2.ShowToastr(this, "", "Exito al elimiar!", "success");
                    Limpiar();
                }
                else
                {
                    Utilerias2.ShowToastr(this, "", "Error al eliminar", "error");
                    Limpiar();
                }
            }
            else
            {
                Utilerias2.ShowToastr(this, "", "Este id no existe", "Warning");
            }
        }
        protected void GuardarBtn_Click(object sender, EventArgs e)
        {
            Motores   motor    = new Motores();
            Utilerias utileria = new Utilerias();

            motor.Descripcion = DescripcionTextBox.Text;
            bool suiche = false;

            try {
                if (string.IsNullOrWhiteSpace(BuscarIdTextBox.Text))
                {
                    suiche = motor.Insertar();
                }
                else
                {
                    motor.MotorId = utileria.ConvertirValor(BuscarIdTextBox.Text);
                    suiche        = motor.Editar();
                }
                if (suiche)
                {
                    Utilerias2.ShowToastr(this, "", "Exito!", "success");
                    Limpiar();
                }
            } catch (Exception ex) { Utilerias2.ShowToastr(this, "Error", ex.Message, "error"); }
        }
Esempio n. 4
0
        //---------------------------------------------------------------------------------------------------------------------------------------
        /// <summary> Construye el objeto y obtiene los datos de la base de datos </summary>
        public RecambiosDatosModel(int id, HttpContext HttpCtx, DataInfo tipo) : base(HttpCtx, id)
        {
            if (tipo == DataInfo.All || tipo == DataInfo.Items)                 // Obtiene datos sobre los Items
            {
                Fabricantes = new Fabricantes(HttpCtx).ListIdName();

                var cat = new Categorias(HttpCtx);

                Categorias    = cat.ListIdName();
                SubCategorias = cat.getSubCategorias();

                Items = new Recambios(HttpCtx).FindByDatos("0/0/0/0/0/Order-4/Range-0-10000").Items;
            }

            if (tipo == DataInfo.All || tipo == DataInfo.Coches)                // Obtiene datos sobre los coches
            {
                Marcas  = new Marcas(HttpCtx).ListIdName();
                Modelos = new Modelos(HttpCtx).ListModelos();

                if (tipo != DataInfo.Coches)
                {
                    Motores = new Motores(HttpCtx).FindForCoche("en uso", null);
                }
                else
                {
                    Motores2 = new Motores(HttpCtx).ListMotores();
                }


                Coches = new RecambioUsos(0, HttpCtx).UsoInCoches().Coches;
            }
        }
        protected void ImprimirButton_Click(object sender, EventArgs e)
        {
            Motores motor = new Motores();

            Validaciones.dataset = "Motores";
            Validaciones.reporte = @"Reportes\MotoresReport.rdlc";
            Validaciones.data    = motor.Listado("*", Filtro(), "");
            Response.Write("<script type='text/javascript'>detailedresults=window.open('/Reportes/VisorReportes.aspx');</script>");
        }
Esempio n. 6
0
        public void MotoresDropDownList()
        {
            Motores motor = new Motores();

            MotorDropDownList.DataSource     = motor.Listado("*", "1=1", "");
            MotorDropDownList.DataTextField  = "Descripcion";
            MotorDropDownList.DataValueField = "MotorId";
            MotorDropDownList.DataBind();
            MotorDropDownList.Items.Insert(0, "Elige Motor");
        }
Esempio n. 7
0
        public JsonResult AddMotor(/* Motor motor*/)
        {
            Motor motor = GetMotor();

            try
            {
                motor.Id = 0;                                               // Fuerza a que se cree un registro nuevo
                int Id = new Motores(HttpContext).Change(motor);
                return(retJson.OkId(Id));
            }
            catch (Exception e) { return(retJson.NoModify(motor.Id, motor.Nombre, e)); }
        }
Esempio n. 8
0
        //---------------------------------------------------------------------------------------------------------------------------------------
        /// <summary> Construye el objeto y obtiene los datos de la base de datos </summary>
        public FindRecambioModel(HttpContext HttpCtx) : base(HttpCtx)
        {
            Marcas  = new Marcas(HttpCtx).ListIdName();
            Modelos = new Modelos(HttpCtx).ListModelos();
            Motores = new Motores(HttpCtx).FindForCoche("en uso", null);

            Fabricantes = new Fabricantes(HttpCtx).ListIdName();

            var cat = new Categorias(HttpCtx);

            Categorias    = cat.ListIdName();
            SubCategorias = cat.getSubCategorias();
        }
        protected string Filtro()
        {
            Motores motor  = new Motores();
            string  filtro = "1=1";

            if (FiltroTextBox.Text.Length > 0)
            {
                filtro = BuscarPorDropDownList.SelectedValue + " like '%" + FiltroTextBox.Text + "%'";
            }

            ConsultaGridView.DataSource = motor.Listado("MotorId, Descripcion", filtro, "");
            ConsultaGridView.DataBind();

            return(filtro);
        }
        protected void BuscarIdBtn_Click(object sender, EventArgs e)
        {
            Motores   motor    = new Motores();
            Utilerias utileria = new Utilerias();

            motor.MotorId = utileria.ConvertirValor(BuscarIdTextBox.Text);
            if (motor.Buscar(motor.MotorId))
            {
                DescripcionTextBox.Text = motor.Descripcion;
            }
            else
            {
                Utilerias2.ShowToastr(this, "", "Id no encontrado!", "Warning");
                Limpiar();
            }
        }
Esempio n. 11
0
        public JsonResult ModifyMotor(/*Motor motor*/)
        {
            Motor motor = GetMotor();

            try
            {
                int Id = new Motores(HttpContext).Change(motor);
                if (Id <= 0)
                {
                    return(retJson.NoExist(motor.Id, motor.Nombre));
                }

                return(retJson.OkId(Id));
            }
            catch (Exception e) { return(retJson.NoModify(motor.Id, motor.Nombre, e)); }
        }
Esempio n. 12
0
        public IConexion GetConexion(Motores motor)
        {
            switch (motor.ToString())
            {
            case "Oracle":
                return(new ConexionOracle());

            case "MySQL":
                return(new ConexionMySQL());

            case "PosgreSQL":
                return(new ConexionPosgreSQL());

            default:
                return(new ConexionVacia());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Validar();
                Motores motor = new Motores();
                if (Request.QueryString["MotorId"] != null)
                {
                    int id = 0;
                    int.TryParse(Request.QueryString["MotorId"].ToString(), out id);

                    if (motor.Buscar(id))
                    {
                        DevolverValores(motor);
                    }
                }
            }
        }
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            Motores motor = new Motores();

            ObtenerValores(motor);
            if (MotorIdTextBox.Text == "")
            {
                if (DescripcionTextBox.Text != "")
                {
                    if (motor.Insertar())
                    {
                        Limpiar();
                        Validaciones.ShowToastr(this, "Exito", "Insertado correctamente!", "success");
                    }
                    else
                    {
                        Validaciones.ShowToastr(this, "Error", "Error al insertar", "error");
                    }
                }
                else
                {
                    Validaciones.ShowToastr(this, "Advertencia", "Debe llenar todos los campos", "warning");
                }
            }
            else
            {
                if (DescripcionTextBox.Text != "")
                {
                    if (motor.Editar())
                    {
                        Limpiar();
                        Validaciones.ShowToastr(this, "Exito", "Modificado correctamente!", "success");
                    }
                    else
                    {
                        Validaciones.ShowToastr(this, "Error", "Error al modificar", "error");
                    }
                }
                else
                {
                    Validaciones.ShowToastr(this, "Advertencia", "Debe llenar todos los campos", "warning");
                }
            }
        }
Esempio n. 15
0
        public static List <Motores> getMotors()
        {
            List <Motores> motores = new List <Motores>();
            Motores        obj1    = new Motores
            {
                ArquivoBat     = @"C:\Users\Matheus Ferreira\Desktop\testeAPI.bat",
                IDProcesso     = "1",
                Ativo          = true,
                DataCriacao    = DateTime.Now,
                DateAlteracao  = DateTime.Now,
                Descricao      = "teste",
                ID             = 1,
                idCliente      = 0,
                Metodo         = "",
                Nome           = "APIIN",
                Status         = 4, //Ativo para publicação
                Url            = "localhost:5300",
                UsuarioCriacao = 1,
                UsuarioEdicao  = 1
            };
            Motores obj2 = new Motores
            {
                ArquivoBat     = @"C:\Users\Matheus Ferreira\Desktop\testeAPI2.bat",
                IDProcesso     = "1",
                Ativo          = true,
                DataCriacao    = DateTime.Now,
                DateAlteracao  = DateTime.Now,
                Descricao      = "teste",
                ID             = 1,
                idCliente      = 0,
                Metodo         = "",
                Nome           = "APIIN",
                Status         = 4, //Ativo para publicação
                Url            = "localhost:5300",
                UsuarioCriacao = 1,
                UsuarioEdicao  = 1
            };

            motores.Add(obj1);
            motores.Add(obj2);
            return(motores);
        }
        public void ObtenerDropDownList()
        {
            Marcas marca = new Marcas();

            MarcaDropDownList.DataSource     = marca.Listado(" * ", " 1=1 ", " ");
            MarcaDropDownList.DataTextField  = "Descripcion";
            MarcaDropDownList.DataValueField = "MarcaId";
            MarcaDropDownList.DataBind();
            MarcaDropDownList.Items.Insert(0, "Seleccionar--");

            Modelos modelo = new Modelos();

            ModeloDropDownList.DataSource     = modelo.Listado(" * ", " 1=1 ", " ");
            ModeloDropDownList.DataTextField  = "Descripcion";
            ModeloDropDownList.DataValueField = "ModeloId";
            ModeloDropDownList.DataBind();
            ModeloDropDownList.Items.Insert(0, "Seleccionar--");

            Motores motor = new Motores();

            MotorDropDownList.DataSource     = motor.Listado(" * ", " 1=1 ", " ");
            MotorDropDownList.DataTextField  = "Descripcion";
            MotorDropDownList.DataValueField = "MotorId";
            MotorDropDownList.DataBind();
            MotorDropDownList.Items.Insert(0, "Seleccionar--");

            Colores color = new Colores();

            ColorDropDownList.DataSource     = color.Listado(" * ", " 1=1 ", " ");
            ColorDropDownList.DataTextField  = "Descripcion";
            ColorDropDownList.DataValueField = "ColorId";
            ColorDropDownList.DataBind();
            ColorDropDownList.Items.Insert(0, "Seleccionar--");

            TipoVehiculos tipo = new TipoVehiculos();

            TipoDropDownList.DataSource     = tipo.Listado(" * ", " 1=1 ", " ");
            TipoDropDownList.DataTextField  = "Descripcion";
            TipoDropDownList.DataValueField = "TipoVehiculoId";
            TipoDropDownList.DataBind();
            TipoDropDownList.Items.Insert(0, "Seleccionar--");
        }
        protected void BuscarButton_Click(object sender, EventArgs e)
        {
            Motores motor = new Motores();

            ObtenerValores(motor);
            if (MotorIdTextBox.Text.Length == 0)
            {
                Validaciones.ShowToastr(this, "Advertencia", "Debe insertar un Id", "warning");
            }
            else
            {
                if (motor.Buscar(motor.MotorId))
                {
                    Limpiar();
                    DevolverValores(motor);
                }
                else
                {
                    Validaciones.ShowToastr(this, "Advertencia", "Id no encontrado", "warning");
                    Limpiar();
                }
            }
        }
 private void DevolverValores(Motores motor)
 {
     MotorIdTextBox.Text     = motor.MotorId.ToString();
     DescripcionTextBox.Text = motor.Descripcion;
 }
 private void ObtenerValores(Motores motor)
 {
     motor.MotorId     = Validaciones.Entero(MotorIdTextBox.Text);
     motor.Descripcion = DescripcionTextBox.Text;
 }
        public DataTable MostrarMotores()
        {
            Motores motor = new Motores();

            return(motor.Listado("*", "1=1", ""));
        }