Esempio n. 1
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (this.dgvAutomoviles.RowCount >= 1)
     {
         if (MessageBox.Show("Realmente quiere elimar este registro?", "Aviso...!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             automoviles nAutomovil = new automoviles();
             nAutomovil.pkAutomovil    = frmMainAutomoviles.PKAUTOMOVIL;
             nAutomovil.sFoto1         = this.dgvAutomoviles.CurrentRow.Cells[1].Value.ToString();
             nAutomovil.sFoto2         = this.dgvAutomoviles.CurrentRow.Cells[2].Value.ToString();
             nAutomovil.sFoto3         = this.dgvAutomoviles.CurrentRow.Cells[3].Value.ToString();
             nAutomovil.sMarca         = this.dgvAutomoviles.CurrentRow.Cells[4].Value.ToString();
             nAutomovil.sModelo        = this.dgvAutomoviles.CurrentRow.Cells[5].Value.ToString();
             nAutomovil.iAño           = Convert.ToInt32(this.dgvAutomoviles.CurrentRow.Cells[6].Value.ToString());
             nAutomovil.sNoSerie       = this.dgvAutomoviles.CurrentRow.Cells[7].Value.ToString();
             nAutomovil.sNoPlaca       = this.dgvAutomoviles.CurrentRow.Cells[8].Value.ToString();
             nAutomovil.sColor         = this.dgvAutomoviles.CurrentRow.Cells[9].Value.ToString();
             nAutomovil.sNacionalidad  = this.dgvAutomoviles.CurrentRow.Cells[10].Value.ToString();
             nAutomovil.dPrecio        = Convert.ToDouble(this.dgvAutomoviles.CurrentRow.Cells[11].Value.ToString());
             nAutomovil.sObservaciones = this.dgvAutomoviles.CurrentRow.Cells[12].Value.ToString();
             nAutomovil.bStatus        = false;
             ControladorAutomovil cAutomovil = new ControladorAutomovil();
             cAutomovil.Modificar(nAutomovil);
             this.cargarAutomoviles(Convert.ToInt32(cmbPropietarios.SelectedValue));
         }
     }
 }
Esempio n. 2
0
        public void GuardarVenta()
        {
            ventas nventas = new ventas();

            nventas.fkAutomovil = Convert.ToInt32(this.dgvdetalleautomoviles.CurrentRow.Cells[0].Value);
            nventas.dPrecio     = Convert.ToDouble(this.dgvdetalleautomoviles.CurrentRow.Cells[6].Value);
            ContoladorVentas cventas = new ContoladorVentas();

            cventas.Guardar(nventas);

            compradores ncompradores = new Modelo.compradores();

            ncompradores.sNombre    = this.txtNombre.Text;
            ncompradores.sApellido  = this.txtApellidos.Text;
            ncompradores.sDireccion = this.txtDireccion.Text;
            ControladorComprador ccomprador = new Controlador.ControladorComprador();

            ccomprador.Guardar(ncompradores);

            detalleventas ndetalleventas = new Modelo.detalleventas();

            ndetalleventas.fkComprador  = ncompradores.pkComprador;
            ndetalleventas.sNombre      = ncompradores.sNombre;
            ndetalleventas.sApellido    = ncompradores.sApellido;
            ndetalleventas.dtFechaVenta = DateTime.Today;
            ndetalleventas.dTotal       = Convert.ToDouble(this.txtTotal.Text);
            ndetalleventas.dPago        = frmPagar.PAGO;
            ndetalleventas.dCambio      = frmPagar.CAMBIO;
            ndetalleventas.fkVenta      = nventas.pkVenta;
            ControladorDetalleVentas cdetalleventas = new ControladorDetalleVentas();

            cdetalleventas.Guardar(ndetalleventas);

            automoviles nautomovil = new automoviles();

            nautomovil.pkAutomovil   = Convert.ToInt32(this.dgvdetalleautomoviles.CurrentRow.Cells[0].Value);
            nautomovil.sNoSerie      = this.dgvdetalleautomoviles.CurrentRow.Cells[1].Value.ToString();
            nautomovil.sMarca        = this.dgvdetalleautomoviles.CurrentRow.Cells[2].Value.ToString();
            nautomovil.sModelo       = this.dgvdetalleautomoviles.CurrentRow.Cells[3].Value.ToString();
            nautomovil.sNoPlaca      = this.dgvdetalleautomoviles.CurrentRow.Cells[4].Value.ToString();
            nautomovil.sNacionalidad = this.dgvdetalleautomoviles.CurrentRow.Cells[5].Value.ToString();
            nautomovil.dPrecio       = Convert.ToDouble(this.dgvdetalleautomoviles.CurrentRow.Cells[6].Value);
            //nautomovil.sFoto1 = this.dgvdetalleautomoviles.CurrentRow.Cells[7].Value.ToString();
            //nautomovil.sFoto2 = this.dgvdetalleautomoviles.CurrentRow.Cells[8].Value.ToString();
            //nautomovil.sFoto3 = this.dgvdetalleautomoviles.CurrentRow.Cells[9].Value.ToString();
            nautomovil.sColor = this.dgvdetalleautomoviles.CurrentRow.Cells[10].Value.ToString();
            nautomovil.iAño   = Convert.ToInt32(this.dgvdetalleautomoviles.CurrentRow.Cells[11].Value);
            //nautomovil.sObservaciones = this.dgvdetalleautomoviles.CurrentRow.Cells[12].Value.ToString();
            nautomovil.bStatus = false;
            ControladorAutomovil catomovil = new ControladorAutomovil();

            catomovil.Modificar(nautomovil);
        }
Esempio n. 3
0
        public void GuardarDatos()
        {
            propietarios nPropietario = new Modelo.propietarios();

            nPropietario.sNombre    = txtNombre.Text;
            nPropietario.sApellido  = txtApellidos.Text;
            nPropietario.sDireccion = txtDireccion.Text;
            nPropietario.sTelefono  = txtTelefono.Text;
            nPropietario.sEmail     = txtEmail.Text;
            nPropietario.sIfe       = txtIfe.Text;
            this.guardarfoto();
            nPropietario.sFoto = filename;

            ControladorPropietario cPropietario = new ControladorPropietario();

            cPropietario.Guardar(nPropietario);

            wMain.CargarPropietarios();

            automoviles nAutomovil = new automoviles();

            this.guardarfoto1();
            this.guardarfoto2();
            this.guardarfoto3();
            nAutomovil.sFoto1         = filename1;
            nAutomovil.sFoto2         = filename2;
            nAutomovil.sFoto3         = filename3;
            nAutomovil.sMarca         = txtMarca.Text;
            nAutomovil.sModelo        = txtModelo.Text;
            nAutomovil.iAño           = Convert.ToInt32(txtAño.Text);
            nAutomovil.sNoSerie       = txtNoSerie.Text;
            nAutomovil.sNoPlaca       = txtNoPlacas.Text;
            nAutomovil.sColor         = txtColor.Text;
            nAutomovil.sNacionalidad  = txtNacionalidad.Text;
            nAutomovil.dPrecio        = Convert.ToDouble(txtPrecio.Text);
            nAutomovil.sObservaciones = txtObservacines.Text;

            ControladorAutomovil cAutomovil = new ControladorAutomovil();

            cAutomovil.Guardar(nAutomovil);

            propietarioautomoviles nPropietarioAutomovil = new propietarioautomoviles();

            nPropietarioAutomovil.fkPropietario = nPropietario.pkPropietario;
            nPropietarioAutomovil.fkAutomovil   = nAutomovil.pkAutomovil;

            ControladorPropietarioAutomovil cPropietarioAutomovil = new ControladorPropietarioAutomovil();

            cPropietarioAutomovil.Guardar(nPropietarioAutomovil);
        }
 /// <summary>
 /// Funcion que se utiliza para guardar datos en la tabla de automovil
 /// </summary>
 /// <param name="nAutomovil">variable de tipo automovil</param>
 public void Guardar(automoviles nAutomovil)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             ctx.Entry(nAutomovil).State = EntityState.Added;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 /// <summary>
 /// Funcion que se utiliza para eliminar un registro en la tabla de usuarios
 /// </summary>
 /// <param name="pkAutomovil">variable de tipo entera</param>
 public void Eliminar(int pkAutomovil)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             automoviles nAutomovil = ctx.automoviles.Single(r => r.pkAutomovil == pkAutomovil);
             ctx.Entry(nAutomovil).State = EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 /// <summary>
 /// Funcion que se utiliza para modificar un registro en la tabla de usuarios
 /// </summary>
 /// <param name="nAutomovil">variable de tipo usuarios</param>
 public void Modificar(automoviles nAutomovil)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             ctx.automoviles.Attach(nAutomovil);
             ctx.Entry(nAutomovil).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void frmModificarAutomoviles_Load(object sender, EventArgs e)
        {
            automoviles nAutomovil = ControladorAutomovil.getautomovilById(frmMainAutomoviles.PKAUTOMOVIL);

            this.pbFoto1.Load(nAutomovil.sFoto1);
            this.pbFoto2.Load(nAutomovil.sFoto2);
            this.pbFoto3.Load(nAutomovil.sFoto3);
            txtMarca.Text        = nAutomovil.sMarca;
            txtModelo.Text       = nAutomovil.sModelo;
            txtAño.Text          = nAutomovil.iAño.ToString();
            txtNoPlacas.Text     = nAutomovil.sNoPlaca.ToString();
            txtNoSerie.Text      = nAutomovil.sNoSerie.ToString();
            txtColor.Text        = nAutomovil.sColor;
            txtNacionalidad.Text = nAutomovil.sNacionalidad;
            txtPrecio.Text       = nAutomovil.dPrecio.ToString();
            txtObservacines.Text = nAutomovil.sObservaciones;
        }
Esempio n. 8
0
        public void cargarDetalleAutomoviles(int pkAutomovil)
        {
            automoviles     nautomovil = ControladorAutomovil.getautomovilById(pkAutomovil);
            DataGridViewRow nRen       = (DataGridViewRow)this.dgvdetalleautomoviles.Rows[0].Clone();

            nRen.Cells[0].Value  = nautomovil.pkAutomovil;
            nRen.Cells[1].Value  = nautomovil.sNoSerie;
            nRen.Cells[2].Value  = nautomovil.sMarca;
            nRen.Cells[3].Value  = nautomovil.sModelo;
            nRen.Cells[4].Value  = nautomovil.sNoPlaca;
            nRen.Cells[5].Value  = nautomovil.sNacionalidad;
            nRen.Cells[6].Value  = nautomovil.dPrecio;
            nRen.Cells[7].Value  = nautomovil.sFoto1;
            nRen.Cells[8].Value  = nautomovil.sFoto2;
            nRen.Cells[9].Value  = nautomovil.sFoto3;
            nRen.Cells[10].Value = nautomovil.sColor;
            nRen.Cells[11].Value = nautomovil.iAño;
            nRen.Cells[12].Value = nautomovil.sObservaciones;

            this.dgvdetalleautomoviles.Rows.Add(nRen);
        }
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (txtMarca.Text == "")
            {
                ErrorProvider.SetError(txtMarca, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtMarca, ErrorIconAlignment.MiddleRight);
                txtMarca.Focus();
            }
            else if (txtModelo.Text == "")
            {
                ErrorProvider.SetError(txtModelo, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtModelo, ErrorIconAlignment.MiddleLeft);
                txtModelo.Focus();
            }
            else if (txtNoSerie.Text == "")
            {
                ErrorProvider.SetError(txtNoSerie, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtNoSerie, ErrorIconAlignment.MiddleLeft);
                txtNoSerie.Focus();
            }
            else if (txtAño.Text == "")
            {
                ErrorProvider.SetError(txtAño, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtAño, ErrorIconAlignment.MiddleRight);
                txtAño.Focus();
            }
            else if (txtNoPlacas.Text == "")
            {
                ErrorProvider.SetError(txtNoPlacas, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtNoPlacas, ErrorIconAlignment.MiddleRight);
                txtNoPlacas.Focus();
            }
            else if (txtColor.Text == "")
            {
                ErrorProvider.SetError(txtColor, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtColor, ErrorIconAlignment.MiddleLeft);
                txtColor.Focus();
            }
            else if (txtNacionalidad.Text == "")
            {
                ErrorProvider.SetError(txtNacionalidad, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtNacionalidad, ErrorIconAlignment.MiddleRight);
                txtNacionalidad.Focus();
            }
            else if (txtPrecio.Text == "")
            {
                ErrorProvider.SetError(txtPrecio, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtPrecio, ErrorIconAlignment.MiddleLeft);
                txtPrecio.Focus();
            }
            else if (txtObservacines.Text == "")
            {
                ErrorProvider.SetError(txtObservacines, "Campo necesario");
                ErrorProvider.SetIconAlignment(txtObservacines, ErrorIconAlignment.MiddleRight);
                txtObservacines.Focus();
            }
            else
            {
                automoviles nAutomovil = new automoviles();
                nAutomovil.pkAutomovil = frmMainAutomoviles.PKAUTOMOVIL;
                guardarfoto1();
                guardarfoto2();
                guardarfoto3();
                nAutomovil.sFoto1         = filename1;
                nAutomovil.sFoto2         = filename2;
                nAutomovil.sFoto3         = filename3;
                nAutomovil.sMarca         = txtMarca.Text;
                nAutomovil.sModelo        = txtModelo.Text;
                nAutomovil.iAño           = Convert.ToInt32(txtAño.Text);
                nAutomovil.sNoSerie       = txtNoSerie.Text;
                nAutomovil.sNoPlaca       = txtNoPlacas.Text;
                nAutomovil.sColor         = txtColor.Text;
                nAutomovil.sNacionalidad  = txtNacionalidad.Text;
                nAutomovil.dPrecio        = Convert.ToInt32(txtPrecio.Text);
                nAutomovil.sObservaciones = txtObservacines.Text;

                ControladorAutomovil cAutomovil = new ControladorAutomovil();
                cAutomovil.Modificar(nAutomovil);

                this.Close();
            }
        }