Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                renta.MontoAtraso    = decimal.Parse(tbxMontoAtraso.Text);
                renta.MontoDia       = decimal.Parse(tbxMontoDia.Text);
                renta.Comentarios    = tbxComentarios.Text;
                renta.FechaRenta     = DateTime.Parse(dtpFecha.Text);
                renta.FechaDevolucon = DateTime.Parse(dtpFechaDevolucion.Text);
                renta.CantidadDias   = tbxCantidadDias.Text;

                if (cbEstado.Text.Trim() == "Activo")
                {
                    renta.Estado = "A";
                }
                else if (cbEstado.Text.Trim() == "Inactivo")
                {
                    renta.Estado = "I";
                }

                if (tbxMontoAtraso.Text.Trim() == "" || tbxComentarios.Text.Trim() == "" || dtpFechaDevolucion.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor, introduzca todos los campos.");
                }
                else
                {
                    renta.IdCliente  = int.Parse(cbCliente.SelectedValue.ToString());
                    renta.IdEmpleado = int.Parse(cbEmpleado.SelectedValue.ToString());
                    renta.IdVehiculo = int.Parse(cbVehiculo.SelectedValue.ToString());

                    using (RentCarEntities db = new RentCarEntities())
                    {
                        if (renta.IdRentaDevolucion == 0)
                        {
                            //db.RENTADEVOLUCION.Add(renta);
                            //MessageBox.Show("Devolución Added!");
                            //RefillComboVehiculo();
                            //RefillComboCliente();
                            //RefillComboEmpleado();
                        }
                        else
                        {
                            db.Entry(renta).State = EntityState.Modified;
                            MessageBox.Show("Succesfully Confirmed");
                        }

                        db.SaveChanges();
                    }
                    Clear();
                    ReFill();
                    RefillComboVehiculo();
                    RefillComboCliente();
                    RefillComboEmpleado();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            try
            {
                modelo.Despcricion = txbModelo.Text;
                if (cbEstado.Text == "Activo")
                {
                    modelo.Estado = "A";
                }
                else if (cbEstado.Text == "Inactivo")
                {
                    modelo.Estado = "I";
                }

                if (txbModelo.Text.Trim() == "" || cbMarca.Text.Trim() == "" || cbEstado.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor, introduzca todos los campos.");
                }
                else
                {
                    modelo.IdMarca = int.Parse(cbMarca.SelectedValue.ToString());

                    using (RentCarEntities db = new RentCarEntities())
                    {
                        if (modelo.IdModelo == 0)
                        {
                            db.MODELO.Add(modelo);
                            MessageBox.Show("Marca Added!");
                        }
                        else
                        {
                            db.Entry(modelo).State = EntityState.Modified;
                            MessageBox.Show("Marca Updated!");
                            btnSave.Text = "Save";
                        }

                        db.SaveChanges();
                    }
                    Clear();
                    ReFill();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                marca.Despcricion = txbDescripcion.Text;

                if (cbEstado.Text == "Activo")
                {
                    marca.Estado = "A";
                }
                else if (cbEstado.Text == "Inactivo")
                {
                    marca.Estado = "I";
                }

                if (txbDescripcion.Text.Trim() == "" || cbEstado.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor, introducir todos los campos.");
                }
                else
                {
                    using (RentCarEntities db = new RentCarEntities())
                    {
                        if (marca.IdMarca == 0)
                        {
                            db.MARCA.Add(marca);
                            MessageBox.Show("Marca Added!");
                        }
                        else
                        {
                            db.Entry(marca).State = EntityState.Modified;
                            MessageBox.Show("Marca Updated!");
                            btnSave.Text = "Save";
                        }

                        db.SaveChanges();
                    }
                    Clear();
                    ReFill();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                emp.Nombre            = tbxNombre.Text;
                emp.Documento         = tbxCedula.Text;
                emp.Usuario           = tbxUsuario.Text;
                emp.Password          = tbxPass.Text;
                emp.PorcientoComision = tbxComision.Text;
                emp.FechaIngreso      = DateTime.Parse(dtpIngreso.Text);

                if (cbTanda.Text == "Matutina")
                {
                    emp.Tanda = "M";
                }
                else if (cbTanda.Text == "Vespertina")
                {
                    emp.Tanda = "V";
                }
                else if (cbTanda.Text == "Nocturna")
                {
                    emp.Tanda = "N";
                }

                if (cbEstado.Text == "Activo")
                {
                    emp.Estado = "A";
                }
                else if (cbEstado.Text == "Inactivo")
                {
                    emp.Estado = "I";
                }

                if (tbxNombre.Text.Trim() == "" || tbxCedula.Text.Trim() == "" || tbxUsuario.Text.Trim() == "" || tbxPass.Text.Trim() == "" ||
                    tbxComision.Text.Trim() == "" || dtpIngreso.Text.Trim() == "" || cbEstado.Text.Trim() == "" || cbTanda.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor, introduzca todos los campos.");
                }
                else
                {
                    using (RentCarEntities db = new RentCarEntities())
                    {
                        if (emp.IdEmpleado == 0)
                        {
                            if (emp.Documento.Length != 11)
                            {
                                MessageBox.Show("Por favor, ingrese una cédula válida");
                            }
                            else if (emp.Documento.Length == 11)
                            {
                                emp.FechaSalida = null;
                                db.EMPLEADO.Add(emp);
                                MessageBox.Show("Empleado Added!");
                            }
                        }
                        else
                        {
                            if (disabled)
                            {
                                emp.FechaSalida = DateTime.Parse(dtpSalida.Text);
                            }

                            if (emp.Documento.Length != 11)
                            {
                                MessageBox.Show("Por favor, ingrese una cédula válida");
                            }
                            else if (emp.Documento.Length == 11)
                            {
                                db.Entry(emp).State = EntityState.Modified;
                                MessageBox.Show("Empleado Updated!");
                                btnSave.Text        = "Save";
                                btnDisabled.Visible = false;
                                dtpSalida.Enabled   = false;
                            }
                        }

                        db.SaveChanges();
                    }
                    ReFill();
                    Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                vehiculo.Despcricion = tbxDescripcion.Text;
                vehiculo.NoChasis    = int.Parse(tbxChasis.Text);
                vehiculo.NoMotor     = int.Parse(tbxMotor.Text);
                vehiculo.NoPlaca     = int.Parse(tbxPlaca.Text);
                if (cbEstado.Text == "Disponible")
                {
                    vehiculo.Estado = "D";
                }
                else if (cbEstado.Text == "Rentado")
                {
                    vehiculo.Estado = "R";
                }
                else if (cbEstado.Text == "En mantenimiento")
                {
                    vehiculo.Estado = "M";
                }
                else if (cbEstado.Text == "Inactivo")
                {
                    vehiculo.Estado = "I";
                }

                if (tbxDescripcion.Text.Trim() == "" || cbMarca.Text.Trim() == "" || cbEstado.Text.Trim() == "" || cbModelo.Text.Trim() == "" || cbTCombustible.Text.Trim() == "" ||
                    cbTVehiculo.Text.Trim() == "" || tbxChasis.Text.Trim() == "" || tbxMotor.Text.Trim() == "" || tbxPlaca.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor, introduzca todos los campos.");
                }
                else
                {
                    vehiculo.IdMarca           = int.Parse(cbMarca.SelectedValue.ToString());
                    vehiculo.IdModelo          = int.Parse(cbModelo.SelectedValue.ToString());
                    vehiculo.IdTipoCombustible = int.Parse(cbTCombustible.SelectedValue.ToString());
                    vehiculo.IdTipoVehiculo    = int.Parse(cbTVehiculo.SelectedValue.ToString());

                    using (RentCarEntities db = new RentCarEntities())
                    {
                        if (vehiculo.IdVehiculo == 0)
                        {
                            db.Vehiculo.Add(vehiculo);
                            MessageBox.Show("Marca Added!");
                        }
                        else
                        {
                            db.Entry(vehiculo).State = EntityState.Modified;
                            MessageBox.Show("Marca Updated!");
                            btnSave.Text = "Save";
                        }

                        db.SaveChanges();
                    }
                    Clear();
                    ReFill();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Ralladuras
                if (rbRalladurasSi.Checked)
                {
                    inspeccion.Ralladuras = "S";
                }
                else if (rbRalladurasNo.Checked)
                {
                    inspeccion.Ralladuras = "N";
                }
                //Goma de Respuesto
                if (rbGomaSi.Checked)
                {
                    inspeccion.GomaRepuesto = "S";
                }
                else if (rbGomaNo.Checked)
                {
                    inspeccion.GomaRepuesto = "N";
                }
                // Gato
                if (rbGatoSi.Checked)
                {
                    inspeccion.Gato = "S";
                }
                else if (rbGatoNo.Checked)
                {
                    inspeccion.Gato = "N";
                }
                // Cristal Roto
                if (rbCristalSi.Checked)
                {
                    inspeccion.RoturaCristal = "S";
                }
                else if (rbCristalNo.Checked)
                {
                    inspeccion.RoturaCristal = "N";
                }
                // Neumatico 1
                if (rbNeumatico1B.Checked)
                {
                    inspeccion.EstadoNeumatico1 = "B";
                }
                else if (rbNeumatico1M.Checked)
                {
                    inspeccion.EstadoNeumatico1 = "M";
                }
                //Neumatico 2
                if (rbNeumatico2B.Checked)
                {
                    inspeccion.EstadoNeumatico2 = "B";
                }
                else if (rbNeumatico2M.Checked)
                {
                    inspeccion.EstadoNeumatico2 = "M";
                }
                //Neumatico 3
                if (rbNeumatico3B.Checked)
                {
                    inspeccion.EstadoNeumatico3 = "B";
                }
                else if (rbNeumatico3M.Checked)
                {
                    inspeccion.EstadoNeumatico3 = "M";
                }
                //Neumatico 4
                if (rbNeumatico4B.Checked)
                {
                    inspeccion.EstadoNeumatico4 = "B";
                }
                else if (rbNeumatico4M.Checked)
                {
                    inspeccion.EstadoNeumatico4 = "M";
                }
                //Estado
                if (cbEstado.Text.Trim() == "Activo")
                {
                    inspeccion.Estado = "A";
                }
                else if (cbEstado.Text.Trim() == "Inactivo")
                {
                    inspeccion.Estado = "I";
                }

                inspeccion.CantidadCombustible = cbCantidadC.Text;
                inspeccion.Fecha = DateTime.Parse(dtpFecha.Text);

                if ((rbRalladurasSi.Checked == false && rbRalladurasNo.Checked == false) || (rbGomaSi.Checked == false && rbGomaNo.Checked == false) ||
                    (rbCristalSi.Checked == false && rbCristalNo.Checked == false) || (rbNeumatico1B.Checked == false && rbNeumatico1M.Checked == false) ||
                    (rbNeumatico2B.Checked == false && rbNeumatico2M.Checked == false) || (rbNeumatico3B.Checked == false && rbNeumatico3M.Checked == false) ||
                    (rbNeumatico4B.Checked == false && rbNeumatico4M.Checked == false) || dtpFecha.Text.Trim() == "" || cbVehiculo.Text.Trim() == "" || cbEmpleado.Text.Trim() == "" ||
                    cbCliente.Text.Trim() == "" || cbEstado.Text.Trim() == "" || cbCantidadC.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor, introduzca todos los campos.");
                }
                else
                {
                    inspeccion.IdVehiculo = int.Parse(cbVehiculo.SelectedValue.ToString());
                    inspeccion.IdCliente  = int.Parse(cbCliente.SelectedValue.ToString());
                    inspeccion.IdEmpleado = int.Parse(cbEmpleado.SelectedValue.ToString());

                    using (RentCarEntities db = new RentCarEntities())
                    {
                        if (inspeccion.IdInspeccion == 0)
                        {
                            db.INSPECCION.Add(inspeccion);
                            MessageBox.Show("Marca Added!");
                        }
                        else
                        {
                            db.Entry(inspeccion).State = EntityState.Modified;
                            MessageBox.Show("Marca Updated!");
                            btnSave.Text = "Save";
                        }

                        db.SaveChanges();
                    }
                    Clear();
                    ReFill();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                cliente.Nombre         = tbxNombre.Text;
                cliente.Documento      = tbxDocumento.Text;
                cliente.TarjetaCredito = tbxTarjeta.Text;
                cliente.LimiteCredito  = tbxLimite.Text;

                if (cbTPersona.Text == "Física")
                {
                    cliente.TipoPersona = "F";
                }
                else if (cbTPersona.Text == "Jurídica")
                {
                    cliente.TipoPersona = "J";
                }

                if (cbEstado.Text == "Activo")
                {
                    cliente.Estado = "A";
                }
                else if (cbEstado.Text == "Inactivo")
                {
                    cliente.Estado = "I";
                }

                if (tbxNombre.Text.Trim() == "" || tbxDocumento.Text.Trim() == "" || tbxTarjeta.Text.Trim() == "" || tbxLimite.Text.Trim() == "" ||
                    cbTPersona.Text.Trim() == "" || cbEstado.Text.Trim() == "")
                {
                    MessageBox.Show("Por favor, introduzca todos los campos.");
                }
                else
                {
                    using (RentCarEntities db = new RentCarEntities())
                    {
                        if (cliente.IdCliente == 0)
                        {
                            if (cliente.TipoPersona == "J" && cliente.Documento.Length != 9)
                            {
                                MessageBox.Show("Por favor, ingrese una RNC válido");
                            }
                            else if (cliente.TipoPersona == "F" && cliente.Documento.Length != 11)
                            {
                                MessageBox.Show("Por favor, ingrese una cédula válida");
                            }
                            else if (cliente.TarjetaCredito.Length != 16)
                            {
                                MessageBox.Show("Por favor, ingrese una tarjeta de crédito válida");
                            }
                            else if (int.Parse(tbxLimite.Text) < 0)
                            {
                                MessageBox.Show("Por favor, ingrese un límite válido");
                            }
                            else
                            {
                                db.CLIENTE.Add(cliente);
                                MessageBox.Show("Marca Added!");
                            }
                        }
                        else
                        {
                            if (cliente.TipoPersona == "J" && cliente.Documento.Length != 9)
                            {
                                MessageBox.Show("Por favor, ingrese una RNC válido");
                            }
                            else if (cliente.TipoPersona == "F" && cliente.Documento.Length != 11)
                            {
                                MessageBox.Show("Por favor, ingrese una cédula válida");
                            }
                            else if (cliente.TarjetaCredito.Length != 16)
                            {
                                MessageBox.Show("Por favor, ingrese una tarjeta de crédito válida");
                            }
                            else if (int.Parse(tbxLimite.Text) < 0)
                            {
                                MessageBox.Show("Por favor, ingrese un límite válido");
                            }
                            else
                            {
                                db.Entry(cliente).State = EntityState.Modified;
                                MessageBox.Show("Marca Updated!");
                                btnSave.Text = "Save";
                            }
                        }

                        db.SaveChanges();
                    }
                    ReFill();
                    Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }