Пример #1
0
 private void tbEliminar_Click(object sender, EventArgs e)
 {
     if (txtidFactura.Text == "")
     {
         MessageBox.Show("Debe ingresar el id que decea eliminar");
         DialogResult dr = MessageBox.Show("Decea eliminar el registro", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.No)
         {
             txtidFactura.Focus();
             return;
         }
         DatosFacturas.EliminarFactura(Convert.ToInt32(txtidFactura.Text));
         MessageBox.Show(DatosFacturas.Mensaje);
         txtidFactura.Focus();
         txtidFactura.Text = "";
         llenarGrid.LlenarGridWindows(dgFacturas);
     }
 }
Пример #2
0
        private void tbConsultar_Click(object sender, EventArgs e)
        {
            if (txtidFactura.Text == "")
            {
                MessageBox.Show("Debe ingresar un id de factura", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtidFactura.Focus();
                return;
            }
            Factura factura = DatosFacturas.ConsultarFactura(Convert.ToInt32(txtidFactura.Text));

            cbFadtura.SelectedValue  = Convert.ToInt32(factura.IDFactura.ToString());
            txtidFactura.Text        = factura.IDLinea.ToString();
            cbProducto.SelectedValue = Convert.ToInt32(factura.IDProducto.ToString());
            txtdescripcion.Text      = factura.Descripcion.ToString();
            txtprecio.Text           = factura.Precio.ToString();
            txtcantidad.Text         = factura.Cantidad.ToString();
            MessageBox.Show(DatosFacturas.Mensaje);
            txtidFactura.Focus();
        }
Пример #3
0
        private void tbActualizar_Click(object sender, EventArgs e)
        {
            if (txtidFactura.Text == "")
            {
                MessageBox.Show("Debe ingresar un id o realizar una consulta para actualizar..!");
                txtidFactura.Focus();
                return;
            }
            Factura factura = new Factura();

            factura.IDFactura   = Convert.ToInt32(cbFadtura.SelectedValue);
            factura.IDProducto  = Convert.ToInt32(cbProducto.SelectedValue);
            factura.Descripcion = txtdescripcion.Text;
            factura.Precio      = Convert.ToDecimal(txtprecio.Text);
            factura.Cantidad    = Convert.ToInt32(txtcantidad.Text);
            DatosFacturas.ActualizarFactura(factura);
            MessageBox.Show(DatosFacturas.Mensaje);
            llenarGrid.LlenarGridWindows(dgFacturas);
            txtidFactura.Focus();
            Limpiar();
        }
Пример #4
0
        private void tbNuevo_Click(object sender, EventArgs e)
        {
            if (cbFadtura.SelectedIndex == -1)
            {
                MessageBox.Show("Debe seleccionar una factura");
                cbFadtura.Focus();
                return;
            }
            if (cbProducto.SelectedIndex == -1)
            {
                MessageBox.Show("Debe seleccionar un producto");
                cbProducto.Focus();
                return;
            }
            if (txtdescripcion.Text == "")
            {
                MessageBox.Show("Debe ingresar una descripción de la factura.!");
                txtdescripcion.Focus();
                return;
            }
            if (txtprecio.Text == "")
            {
                MessageBox.Show("Debe ingresar un  valor para la factura.!");
                txtprecio.Focus();
                return;
            }
            decimal precio;

            try
            {
                precio = Convert.ToDecimal(txtprecio.Text);
            }
            catch (Exception)
            { precio = 0; }
            if (precio == 0)
            {
                MessageBox.Show("Debe ingresar un valor en $ en el precio.!!");
            }
            if (txtcantidad.Text == "")
            {
                MessageBox.Show("Debe  ingresar una cantida.!!");
            }
            int cantidad;

            try
            {
                cantidad = Convert.ToInt32(txtcantidad.Text);
            }
            catch (Exception)
            { cantidad = 0; }
            if (cantidad == 0)
            {
                MessageBox.Show("Ingrese un valor en númerico en la cantidad");
            }

            Factura factura = new Factura();

            factura.IDFactura   = Convert.ToInt32(cbFadtura.SelectedValue);
            factura.IDProducto  = Convert.ToInt32(cbProducto.SelectedValue);
            factura.Descripcion = txtdescripcion.Text;
            factura.Precio      = Convert.ToDecimal(txtprecio.Text);
            factura.Cantidad    = Convert.ToInt32(txtcantidad.Text);
            DatosFacturas.NuevoFactura(factura);
            MessageBox.Show(DatosFacturas.Mensaje);
            llenarGrid.LlenarGridWindows(dgFacturas);
            txtidFactura.Focus();
            Limpiar();
        }