Example #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (bdsVehiculos.Current != null)
            {
                oVehiculo = (Modelo.Vehiculo)bdsVehiculos.Current;

                DialogResult result = MessageBox.Show("¿Esta seguro que desea eliminar el Vehículo " + oVehiculo.Patente + "?", "Cuidado", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    if (oVehiculo.Gasto.Count < 1)
                    {
                        ctrlVehiculos.EliminarVehiculo(oVehiculo);
                    }
                    else
                    {
                        DialogResult result2 = MessageBox.Show("El Vehículo seleccionado tiene gastos asignados en su historial.\n ¿Desea eliminarlo de todas formas junto a sus gastos relacionados?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (result2 == System.Windows.Forms.DialogResult.Yes)
                        {
                            foreach (Modelo.Gasto oGasto in oVehiculo.Gasto.ToList())
                            {
                                ctrlGastos.EliminarGasto(oGasto);
                            }
                            ctrlVehiculos.EliminarVehiculo(oVehiculo);
                        }
                    }
                    ArmarGrilla();
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un Vehículo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (ValidarCampos())
            {
                oVehiculo = new Modelo.Vehiculo();


                oVehiculo.Patente = txtPatente.Text.ToUpper();
                if (txtPatenteTaxi.Text != "")
                {
                    oVehiculo.PatenteTaxi = Convert.ToInt32(txtPatenteTaxi.Text);
                }
                oVehiculo.Marca       = txtMarca.Text.ToUpper();
                oVehiculo.Modelo      = txtModelo.Text.ToUpper();
                oVehiculo.Año         = Convert.ToInt32(txtAño.Text);
                oVehiculo.Color       = txtColor.Text.ToUpper();
                oVehiculo.Kilometraje = Convert.ToInt32(txtKilometraje.Text);

                if (frmModo == "ALTA")
                {
                    if (ctrlVehiculos.VerificarVehiculo(oVehiculo))
                    {
                        if (ctrlVehiculos.VerificarPatenteTaxi(oVehiculo))
                        {
                            ctrlVehiculos.AgregarVehiculo(oVehiculo);
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show("La patente de taxi solicitada se encuentra activa en otro vehiculo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("La patente solicitada ya pertenece a otro vehiculo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                if (frmModo == "MODIFICACION")
                {
                    if (ChapaTaxi != oVehiculo.PatenteTaxi)
                    {
                        if (ctrlVehiculos.VerificarPatenteTaxi(oVehiculo))
                        {
                            ctrlVehiculos.ModificarVehiculo(oVehiculo);
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show("La patente de taxi solicitada se encuentra activa en otro vehiculo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        ctrlVehiculos.ModificarVehiculo(oVehiculo);
                        this.DialogResult = DialogResult.OK;
                    }
                }
            }
        }
        public bool VerificarPatenteTaxi(Modelo.Vehiculo oVehiculo)
        {
            List <Modelo.Vehiculo> Lista = Modelo.Datos.ObtenerInstancia().Vehiculos.Where(oVeh => oVeh.PatenteTaxi == oVehiculo.PatenteTaxi).ToList();

            if (Lista.Count > 0)
            {
                return(false);
            }
            return(true);
        }
Example #4
0
 private void LlenarCampos(Modelo.Vehiculo oVehiculo)
 {
     txtPatente.Text     = oVehiculo.Patente;
     txtPatenteTaxi.Text = oVehiculo.PatenteTaxi.ToString();
     txtMarca.Text       = oVehiculo.Marca;
     txtModelo.Text      = oVehiculo.Modelo;
     txtAño.Text         = oVehiculo.Año.ToString();
     txtColor.Text       = oVehiculo.Color;
     txtKilometraje.Text = oVehiculo.Kilometraje.ToString();
 }
        public void CargarTiposdeGasto()
        {
            List <Modelo.TipodeGasto> Lista = Modelo.Datos.ObtenerInstancia().TiposdeGasto.ToList();

            if (Lista.Count == 0)
            {
                Modelo.TipodeGasto a = new Modelo.TipodeGasto();
                a.Descripcion = "INFRACCION";
                Modelo.Datos.ObtenerInstancia().TiposdeGasto.AddObject(a);
                Modelo.TipodeGasto b = new Modelo.TipodeGasto();
                b.Descripcion = "TALLER";
                Modelo.Datos.ObtenerInstancia().TiposdeGasto.AddObject(b);
                Modelo.TipodeGasto c = new Modelo.TipodeGasto();
                c.Descripcion = "PATENTE";
                Modelo.Datos.ObtenerInstancia().TiposdeGasto.AddObject(c);
                Modelo.TipodeGasto d = new Modelo.TipodeGasto();
                d.Descripcion = "SEGURO";
                Modelo.Datos.ObtenerInstancia().TiposdeGasto.AddObject(d);
                Modelo.TipodeGasto e = new Modelo.TipodeGasto();
                e.Descripcion = "CUBIERTAS";
                Modelo.Datos.ObtenerInstancia().TiposdeGasto.AddObject(e);

                Modelo.Datos.ObtenerInstancia().SaveChanges();

                Modelo.Vehiculo f = new Modelo.Vehiculo();
                f.Patente     = "APD-463";
                f.Marca       = "FIAT";
                f.Modelo      = "DUNA";
                f.PatenteTaxi = 927;
                f.Año         = 1996;
                f.Color       = "BLANCO";
                f.Kilometraje = 130000;
                Modelo.Datos.ObtenerInstancia().Vehiculos.AddObject(f);

                Modelo.Gasto g = new Modelo.Gasto();
                g.Descripcion      = "Cambio de 4 neumaticos";
                g.Estado           = "PENDIENTE";
                g.FechaVencimiento = DateTime.Today;
                g.Monto            = 450;
                g.Vehiculo         = f; // Modelo.Datos.ObtenerInstancia().Vehiculos.FirstOrDefault();
                g.TipodeGasto      = e; // Modelo.Datos.ObtenerInstancia().TiposdeGasto.FirstOrDefault(); =
                g.Usuario          = "Sistema";
                g.FechayHora       = DateTime.Now;
                g.Operacion        = "ALTA";
                Modelo.Datos.ObtenerInstancia().Gastos.AddObject(g);

                Modelo.Datos.ObtenerInstancia().SaveChanges();
            }
        }
Example #6
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            if (bdsVehiculos.Current != null)
            {
                oVehiculo = (Modelo.Vehiculo)bdsVehiculos.Current;

                frmVehiculo  ofrmVehiculo = new frmVehiculo("CONSULTA", oVehiculo);
                DialogResult drABIERTO    = ofrmVehiculo.ShowDialog();
                if (drABIERTO == DialogResult.OK)
                {
                    ArmarGrilla();
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un Vehículo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            lblSinResultados.Visible = false;
            string Id = txtIdFiltro.Text;

            Modelo.Vehiculo oVehiculoF = null;
            if (cbxVehiculoFiltro.SelectedItem != null)
            {
                oVehiculoF = (Modelo.Vehiculo)bdsVehiculos.Current;
            }

            Modelo.Chofer oChoferF = null;
            if (cbxChoferFiltro.SelectedItem != null)
            {
                oChoferF = (Modelo.Chofer)bdsChoferes.Current;
            }

            //string Monto = txtMontoFiltro.Text;
            string Turno = "";

            if (cbxTurnoFiltro.Text != "")
            {
                Turno = cbxTurnoFiltro.Text.ToUpper();
            }
            //string Descripcion = txtDescripcionFiltro.Text.ToUpper();

            DateTime VenceDesde = dtpFechaDesdeFiltro.MinDate;
            DateTime VenceHasta = dtpFechaHastaFiltro.MaxDate;

            if (chkFechasFiltro.Checked == true)
            {
                VenceDesde = dtpFechaDesdeFiltro.Value.Date;
                VenceHasta = dtpFechaHastaFiltro.Value.Date;
            }


            //bdsTurnos.DataSource = ctrlTurnos.ListarTurnosFiltrados(Id, oVehiculoF, oTipodeTurnoF, Monto, Estado, Descripcion, VenceDesde, VenceHasta);

            if (bdsTurnos.Count == 0)
            {
                lblSinResultados.Visible = true;
            }
            // MessageBox.Show("No se encontraron resultados con los parámetros de busqueda introducidos", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Example #8
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (bdsVehiculos.Current != null)
            {
                oVehiculo = (Modelo.Vehiculo)bdsVehiculos.Current;

                frmVehiculo  ofrmVehiculo = new frmVehiculo("MODIFICACION", oVehiculo);
                DialogResult drABIERTO    = ofrmVehiculo.ShowDialog();
                if (drABIERTO == DialogResult.OK)
                {
                    MessageBox.Show("El Vehiculo ha sido modificado correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ArmarGrilla();
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un Vehículo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #9
0
        public frmVehiculo(string modo, Modelo.Vehiculo oVehiculo)
        {
            InitializeComponent();
            frmModo = modo;

            if (frmModo == "MODIFICACION")
            {
                txtPatente.Enabled = false;
            }

            if (frmModo == "CONSULTA")
            {
                grpDetalle.Enabled = false;
                btnGuardar.Enabled = false;
            }

            ChapaTaxi = Convert.ToInt32(oVehiculo.PatenteTaxi);
            LlenarCampos(oVehiculo);
        }
        public List <Modelo.Gasto> ListarGastosFiltrados(string Id, Modelo.Vehiculo oVehiculoF, Modelo.TipodeGasto oTipodeGastoF, string Monto, string Estado, string Descripcion, DateTime VenceDesde, DateTime VenceHasta)
        {
            List <Modelo.Gasto> Filtrado = Modelo.Datos.ObtenerInstancia().Gastos.ToList();

            if (Id.ToString() != "")
            {
                Filtrado = Filtrado.Where(oGas => oGas.Id == Convert.ToInt32(Id)).ToList();
            }
            if (oVehiculoF != null)
            {
                Filtrado = Filtrado.Where(oGas => oGas.Vehiculo == oVehiculoF).ToList();
            }
            if (oTipodeGastoF != null)
            {
                Filtrado = Filtrado.Where(oGas => oGas.TipodeGasto == oTipodeGastoF).ToList();
            }
            if (Monto.ToString() != "")
            {
                Filtrado = Filtrado.Where(oGas => oGas.Monto == Convert.ToDecimal(Monto)).ToList();
            }
            if (Estado != "")
            {
                Filtrado = Filtrado.Where(oGas => oGas.Estado == Estado).ToList();
            }
            if (Descripcion != "")
            {
                Filtrado = Filtrado.Where(oGas => oGas.Descripcion.Contains(Descripcion)).ToList();
            }
            if (VenceDesde.ToString() != null)
            {
                Filtrado = Filtrado.Where(oGas => oGas.FechaVencimiento > VenceDesde).ToList();
            }
            if (VenceHasta.ToString() != null)
            {
                Filtrado = Filtrado.Where(oGas => oGas.FechaVencimiento < VenceHasta).ToList();
            }

            return(Filtrado);
        }
 public void ModificarVehiculo(Modelo.Vehiculo oVehiculo)
 {
     Modelo.Datos.ObtenerInstancia().Vehiculos.ApplyCurrentValues(oVehiculo);
     Modelo.Datos.ObtenerInstancia().SaveChanges();
 }
 public void EliminarVehiculo(Modelo.Vehiculo oVehiculo)
 {
     Modelo.Datos.ObtenerInstancia().DeleteObject(oVehiculo);
     Modelo.Datos.ObtenerInstancia().SaveChanges();
 }
 public void AgregarVehiculo(Modelo.Vehiculo oVehiculo)
 {
     Modelo.Datos.ObtenerInstancia().AddToVehiculos(oVehiculo);
     Modelo.Datos.ObtenerInstancia().SaveChanges();
 }