Exemple #1
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 #2
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 #3
0
        private void btnAgregar(object sender, EventArgs e)
        {
            if (reparacion != null)
            {
                frmSeleccionarRepuesto frm = new frmSeleccionarRepuesto();
                frm.ShowDialog();

                int idRepuesto = frm.repuestoSeleccionado;

                if (idRepuesto != -1)
                {
                    using (MABEntities db = new MABEntities())
                    {
                        Models.ReparacionesRepuestos repuRepa = new ReparacionesRepuestos();

                        repuRepa.ReparacionesId = reparacion.Id;
                        repuRepa.RepuestosId    = idRepuesto;

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

                cargarDGV(reparacion.Id);
            }
            else
            {
                frmAgregarRepuesto frm = new frmAgregarRepuesto();
                frm.ShowDialog();

                cargarDGV(null);
            }
        }
Exemple #4
0
        private void guardarLavarropas(object sender, EventArgs e)
        {
            if ((cctbMarca.Text != string.Empty) && (cctbModelo.Text != string.Empty) && (cctbEstado.Text != string.Empty))
            {
                using (MABEntities db = new MABEntities())
                {
                    Models.Lavarropas Lavarropas = new Models.Lavarropas();

                    Lavarropas.marca         = cctbMarca.Text;
                    Lavarropas.modelo        = cctbModelo.Text;
                    Lavarropas.estadoGeneral = cctbEstado.Text;
                    Lavarropas.ClienteId     = Cliente.Id;

                    db.Lavarropas.Add(Lavarropas);
                    db.SaveChanges();

                    MessageBox.Show("Lavarropas agregado correctamente", "Guardado Correctamente", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    cctbMarca.Text  = "";
                    cctbModelo.Text = "";
                    cctbEstado.Text = "";

                    cctbMarca.Focus();
                }
            }
            else
            {
                MessageBox.Show("Hay campos que faltan completar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #5
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 #6
0
        private int guardarCliente()
        {
            Models.Clientes cliente;

            if ((cctbApellido.Text != string.Empty) && (cctbDireccion.Text != string.Empty))
            {
                using (MABEntities db = new MABEntities())
                {
                    cliente = new Models.Clientes();

                    cliente.nombre    = cctbNombre.Text;
                    cliente.apellido  = cctbApellido.Text;
                    cliente.direccion = cctbDireccion.Text;

                    db.Clientes.Add(cliente);
                    db.SaveChanges();

                    return(cliente.Id);
                }
            }
            else
            {
                MessageBox.Show("Faltan campos por completar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(-1);
        }
Exemple #7
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 #8
0
        private void agregarRepuesto(object sender, EventArgs e)
        {
            if (cctbNombre.Text != string.Empty && cctbDescripcion.Text != string.Empty && cctbStock.Text != string.Empty && cctbPrecio.Text != string.Empty)
            {
                using (MABEntities db = new MABEntities())
                {
                    Models.Repuestos repuesto = new Models.Repuestos();

                    repuesto.nombre      = cctbNombre.Text;
                    repuesto.descripcion = cctbDescripcion.Text;
                    repuesto.disponibles = Convert.ToInt32(cctbStock.Text);
                    repuesto.precio      = Convert.ToDouble(cctbPrecio.Text);

                    db.Repuestos.Add(repuesto);

                    db.SaveChanges();

                    MessageBox.Show("Repuesto agregado correctamente", "Guardado Correctamente", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    cctbNombre.Text      = "";
                    cctbDescripcion.Text = "";
                    cctbPrecio.Text      = "";
                    cctbStock.Text       = "";

                    cctbNombre.Focus();
                }
            }
            else
            {
                MessageBox.Show("Faltan campos por llenar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #9
0
        private void agregarReparacion(object sender, EventArgs e)
        {
            if ((cctbErrorAReparar.Text != string.Empty) && (dtpFechaIngreso.Value <= DateTime.Now))
            {
                using (MABEntities db = new MABEntities())
                {
                    Models.Reparaciones reparacion = new Models.Reparaciones();

                    reparacion.fechaIngreso        = dtpFechaIngreso.Value;
                    reparacion.fechaEgreso         = null;
                    reparacion.errorAReparar       = cctbErrorAReparar.Text;
                    reparacion.estadoReparacion    = estadosReparacion.EnCurso;
                    reparacion.mesesGarantia       = null;
                    reparacion.reparacionRealizada = "";
                    reparacion.manoDeObra          = 0;
                    reparacion.totalRepuestos      = 0;
                    reparacion.LavarropasId        = lavarropas.Id;

                    db.Reparaciones.Add(reparacion);
                    db.SaveChanges();

                    MessageBox.Show("Reparacion agregada correctamente", "Guardada Correctamente", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    cctbErrorAReparar.Text = "";
                    cctbErrorAReparar.Focus();
                }
            }
            else
            {
                MessageBox.Show("Hay campos que faltan completar o la fecha es incorrecta \n" +
                                "Por favor revise la informacion y vuelva a intentarlo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #10
0
        private void agregarEntrega(object sender, EventArgs e)
        {
            if (cctbMonto.Text != string.Empty)
            {
                Models.Entregas entrega = new Models.Entregas();

                entrega.ClientesId     = reparacion.Lavarropas.Cliente.Id;
                entrega.ReparacionesId = reparacion.Id;
                entrega.monto          = Convert.ToInt32(cctbMonto.Text);
                entrega.fecha          = dtpFechaEntrega.Value;

                using (MABEntities db = new MABEntities())
                {
                    db.Entregas.Add(entrega);
                    db.SaveChanges();

                    DialogResult resp = MessageBox.Show("Entrega Creada Correctamente \n ¿Desea crear un Comprobante de Recibo?",
                                                        "Guardado Correctamente", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                    if (resp == DialogResult.Yes)
                    {
                        frmComprobanteDeRecibo frm = new frmComprobanteDeRecibo(entrega);
                        frm.ShowDialog();
                    }

                    cctbMonto.Text = "";
                    cctbMonto.Focus();
                }
            }
            else
            {
                MessageBox.Show("Falta llenar el monto de la entrega", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #11
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 #12
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 #13
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 #14
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 #15
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 #16
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
                    );
            }
        }