Exemple #1
0
        private void btnSearch(object sender, EventArgs e)
        {
            frmBuscarLavarropas frm = new frmBuscarLavarropas();

            frm.ShowDialog();

            if (frm.getResultados.Count != 0)
            {
                using (MABEntities db = new MABEntities())
                {
                    List <object> lavarropas = new List <object>();

                    foreach (int id in frm.getResultados)
                    {
                        var lavarropa = db.Lavarropas.Find(id);

                        if (!lavarropas.Contains(lavarropa))
                        {
                            db.Entry(lavarropa).Reference("Cliente").Load();
                            db.Entry(lavarropa).Collection("Reparacion").Load();

                            lavarropas.Add(lavarropa);
                        }
                    }
                    ucDGVTabla.dataSource(lavarropas);

                    ucDGVTabla.Columns["Id"].Visible         = false;
                    ucDGVTabla.Columns["Cliente"].Visible    = false;
                    ucDGVTabla.Columns["ClienteId"].Visible  = false;
                    ucDGVTabla.Columns["Reparacion"].Visible = false;
                }
            }
        }
Exemple #2
0
        private void btnBuscar(object sender, EventArgs e)
        {
            if (reparacion != null)
            {
                MessageBox.Show("La busqueda se realiza sobre todos los repuestos", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            frmBuscarRepuesto frm = new frmBuscarRepuesto();

            frm.ShowDialog();

            if (frm.getRepuestos.Count != 0)
            {
                using (MABEntities db = new MABEntities())
                {
                    List <Models.Repuestos> repuestos = new List <Models.Repuestos>();

                    foreach (int id in frm.getRepuestos)
                    {
                        var repuesto = db.Repuestos.Find(id);

                        if (!repuestos.Contains(repuesto))
                        {
                            db.Entry(repuesto).Collection("Reparaciones").Load();

                            repuestos.Add(repuesto);
                        }
                    }

                    ucDGVTabla.dataSource(repuestos);

                    ucDGVTabla.Columns["Reparaciones"].Visible = false;
                }
            }
        }
Exemple #3
0
        private void eliminarSeleccionado(object sender, EventArgs e)
        {
            if (ucDGVTabla.selectedRow() != null)
            {
                long telefono = Convert.ToInt64(ucDGVTabla.selectedRow().Cells["Telefono"].Value);

                using (MABEntities db = new MABEntities())
                {
                    var Telefono = (from tel in db.Telefonos
                                    where tel.telefono == telefono
                                    where tel.estado != false
                                    select tel).First();

                    DialogResult resp = MessageBox.Show(
                        "Esta a punto de eliminar el Telefono " + Telefono.telefono + Environment.NewLine +
                        "del Cliente " + Telefono.Cliente.nombre + " " + Telefono.Cliente.apellido + Environment.NewLine +
                        "¿Quiere continuar con la eliminacion?", "Estas a Punto de eliminar un Telefono", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (resp == DialogResult.Yes)
                    {
                        Telefono.estado = false;

                        db.Entry(Telefono).State = System.Data.Entity.EntityState.Modified;

                        db.SaveChanges();
                    }
                }
            }

            refrescarTelefonos(cliente.Id);
        }
Exemple #4
0
        private void modificarEntrega(object sender, EventArgs e)
        {
            if (dtpFechaEntrega.Value > DateTime.Now)
            {
                dtpFechaEntrega.Value = DateTime.Now;
            }

            if (cctbMonto.Text != string.Empty)
            {
                entrega.monto = Convert.ToDouble(cctbMonto.Text);
                entrega.fecha = dtpFechaEntrega.Value;

                using (MABEntities db = new MABEntities())
                {
                    db.Entry(entrega).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    MessageBox.Show("Entrega modificada Correctamente");
                }
            }
            else
            {
                MessageBox.Show("Falta completar el campo de monto", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #5
0
        private void guardarModificacion(object sender, EventArgs e)
        {
            if (dtpFechaEgreso.Value > DateTime.Now)
            {
                dtpFechaEgreso.Value = DateTime.Now;
            }

            if (cctbMesesGarantia.Text == string.Empty)
            {
                cctbMesesGarantia.Text = "3";
            }

            if (cctbManoObra.Text != string.Empty && cctbTotalRepuestos.Text != string.Empty)
            {
                reparacion.estadoReparacion    = (estadosReparacion)cboEstadoReparacion.SelectedItem;
                reparacion.mesesGarantia       = Convert.ToInt32(cctbMesesGarantia.Text);
                reparacion.fechaEgreso         = dtpFechaEgreso.Value;
                reparacion.reparacionRealizada = cctbReparacionRealizada.Text;
                reparacion.manoDeObra          = Convert.ToInt32(cctbManoObra.Text);
                reparacion.totalRepuestos      = Convert.ToInt32(cctbTotalRepuestos.Text);

                using (MABEntities db = new MABEntities())
                {
                    db.Entry(reparacion).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    MessageBox.Show("Reparacion finalizada correctamente");
                }
            }
            else
            {
                MessageBox.Show("Faltan campos por completar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #6
0
        private void modificarNumero(object sender, EventArgs e)
        {
            if (cctbNumTelefono.Text != string.Empty)
            {
                if (Convert.ToInt64(cctbNumTelefono.Text) != Telefono.telefono)
                {
                    using (MABEntities db = new MABEntities())
                    {
                        Telefono.telefono = Convert.ToInt64(cctbNumTelefono.Text);

                        db.Entry(Telefono).State = System.Data.Entity.EntityState.Modified;

                        db.SaveChanges();

                        MessageBox.Show("Telefono Modificado Correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("El numero de telefono no ha cambiado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("El campo Telefono es invalido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #7
0
        private void btnModificar(object sender, EventArgs e)
        {
            if (reparacion != null)
            {
                int idRepuestoOriginal = Convert.ToInt32(ucDGVTabla.selectedRow().Cells["Id"].Value);

                /** Desde aca se hace un guardar que voy a tener que modificar, claramente */

                frmSeleccionarRepuesto frm = new frmSeleccionarRepuesto();
                frm.ShowDialog();

                int idRepuestoNuevo = frm.repuestoSeleccionado;

                if (idRepuestoNuevo != -1)
                {
                    using (MABEntities db = new MABEntities())
                    {
                        Models.ReparacionesRepuestos repaRepu = db.ReparacionesRepuestos.Find(reparacion.Id, idRepuestoOriginal);

                        db.Entry(repaRepu).State = System.Data.Entity.EntityState.Deleted;
                        db.SaveChanges();

                        Models.ReparacionesRepuestos nuevoRepaRepu = new Models.ReparacionesRepuestos();

                        nuevoRepaRepu.ReparacionesId = reparacion.Id;
                        nuevoRepaRepu.RepuestosId    = idRepuestoNuevo;

                        db.ReparacionesRepuestos.Add(nuevoRepaRepu);
                        db.SaveChanges();
                    }
                }

                cargarDGV(reparacion.Id);
            }
            else
            {
                if (ucDGVTabla.selectedRow() != null)
                {
                    int idRepuesto = Convert.ToInt32(ucDGVTabla.selectedRow().Cells["Id"].Value);

                    frmModificarRepuesto frm = new frmModificarRepuesto(idRepuesto);
                    frm.ShowDialog();

                    if (reparacion != null)
                    {
                        cargarDGV(reparacion.Id);
                    }
                    else
                    {
                        cargarDGV(null);
                    }
                }
            }
        }
Exemple #8
0
        private void agregarTelefono(object sender, EventArgs e)
        {
            int  idCliente   = cliente.Id;
            long numTelefono = Convert.ToInt64(cctbTelefono.Text);

            if (cctbTelefono.Text != string.Empty && cctbTelefono.TextLength <= 10)
            {
                Models.Telefonos telefono;

                using (MABEntities db = new MABEntities())
                {
                    telefono = (from tel in db.Telefonos
                                where tel.ClienteId == idCliente
                                where tel.telefono == numTelefono
                                select tel).FirstOrDefault();

                    /**
                     * TODO: Tengo que revisar esto, porque mepa que telefono deberia preguntarse al verre. si es null,
                     * dejarlo pasar por el if, sino por el else
                     */
                    if (telefono == null)
                    {
                        telefono = new Models.Telefonos();

                        telefono.ClienteId = cliente.Id;
                        telefono.telefono  = Convert.ToInt64(cctbTelefono.Text);
                        telefono.estado    = true;

                        db.Telefonos.Add(telefono);
                        db.SaveChanges();

                        MessageBox.Show("Telefono agregado correcamente", "Guardado Correctamente", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        cctbTelefono.Text = "";
                        cctbTelefono.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Se a encontrado un numero igual que pertenecio a este cliente. \n" +
                                        "Se procedera a recuperar el telefono.", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        telefono.estado = true;

                        db.Entry(telefono).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                MessageBox.Show("Debe ingresar un numero de telefono valido (Max: 10 Caracteres)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #9
0
        private void guardarCambios(object sender, EventArgs e)
        {
            if (cctbFallaAReparar.Text != string.Empty)
            {
                if (cctbReparacionRealizada.Text == string.Empty)
                {
                    cctbReparacionRealizada.Text = "";
                }
                if (cctbManoObra.Text == string.Empty)
                {
                    cctbManoObra.Text = "0";
                }
                if (cctbValorRepuestos.Text == string.Empty)
                {
                    cctbValorRepuestos.Text = "0";
                }

                if ((estadosReparacion)cboEstadoReparacion.SelectedItem == estadosReparacion.Finalizada)
                {
                    reparacion.fechaEgreso   = dtpFechaEgreso.Value;
                    reparacion.mesesGarantia = Convert.ToInt32(nudGarantia.Value);
                }

                using (MABEntities db = new MABEntities())
                {
                    reparacion.estadoReparacion    = (estadosReparacion)cboEstadoReparacion.SelectedItem;
                    reparacion.fechaIngreso        = dtpFechaIngreso.Value;
                    reparacion.errorAReparar       = cctbFallaAReparar.Text;
                    reparacion.reparacionRealizada = cctbReparacionRealizada.Text;
                    reparacion.manoDeObra          = Convert.ToDouble(cctbManoObra.Text);
                    reparacion.totalRepuestos      = Convert.ToDouble(cctbValorRepuestos.Text);

                    db.Entry(reparacion).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    MessageBox.Show("Reparacion Modificada correctamente");
                }
            }
            else
            {
                MessageBox.Show("Hay campos que faltan completar", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #10
0
        private void confirmarCambios(object sender, EventArgs e)
        {
            if ((cctbApellido.Text != string.Empty) && (cctbDireccion.Text != string.Empty))
            {
                cliente.nombre    = cctbNombre.Text;
                cliente.apellido  = cctbApellido.Text;
                cliente.direccion = cctbDireccion.Text;

                using (MABEntities db = new MABEntities())
                {
                    db.Entry(cliente).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    MessageBox.Show("Cliente modificado Correctamente", "Guardado Correctamente", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Faltan campos por completar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #11
0
        private void modificarRepuesto(object sender, EventArgs e)
        {
            if (cctbNombre.Text != string.Empty && cctbDescripcion.Text != string.Empty && cctbPrecio.Text != string.Empty && cctbStock.Text != string.Empty)
            {
                repuesto.nombre      = cctbNombre.Text;
                repuesto.descripcion = cctbDescripcion.Text;
                repuesto.disponibles = Convert.ToInt32(cctbStock.Text);
                repuesto.precio      = Convert.ToDouble(cctbPrecio.Text);

                using (MABEntities db = new MABEntities())
                {
                    db.Entry(repuesto).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    MessageBox.Show("Repuesto modificado Correctamente");
                }
            }
            else
            {
                MessageBox.Show("Faltan campos por completar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #12
0
        private void modificarLavarropas(object sender, EventArgs e)
        {
            if ((cctbMarca.Text != string.Empty) && (cctbModelo.Text != string.Empty) && (cctbEstadoGeneral.Text != string.Empty))
            {
                using (MABEntities db = new MABEntities())
                {
                    lavarropas.marca         = cctbMarca.Text;
                    lavarropas.modelo        = cctbModelo.Text;
                    lavarropas.estadoGeneral = cctbEstadoGeneral.Text;

                    db.Entry(lavarropas).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    MessageBox.Show("Lavarropas modificado correctamente");
                }
            }
            else
            {
                MessageBox.Show(
                    "Hay campos incompletos. Por favor completelos para continuar",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error
                    );
            }
        }