예제 #1
0
 private void btnGenerarFactura_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvDetalles.Rows.Count > 0)
         {
             foreach (DataGridViewRow row in dgvDetalles.Rows)
             {
                 CLS.DetalleFactura oDetalleFactura = new CLS.DetalleFactura();
                 oDetalleFactura.Cantidad       = row.Cells[0].Value.ToString();
                 oDetalleFactura.Precio         = row.Cells[2].Value.ToString();
                 oDetalleFactura.NombreProducto = row.Cells[1].Value.ToString();
                 oDetalleFactura.IDProducto     = row.Cells[6].Value.ToString();
                 //oDetalleFactura.IDFacturaDeVenta = txbNumFact.Text;
                 oDetalleFactura.Exento   = row.Cells[3].Value.ToString();
                 oDetalleFactura.Gravado  = row.Cells[5].Value.ToString();
                 oDetalleFactura.NoSujeto = row.Cells[4].Value.ToString();
                 oDetalleFactura.Insertar();
             }
         }
         else
         {
             CLS.MyMessageBox.ShowMessage("Tiene que llenar los campos vacios", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch
     {
         CLS.MyMessageBox.ShowMessage("Ocurrio un Error a la hora de GUARDAR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        private void btnGuardarFact_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    if (txbIDCliente.Text != "" && txbIDEmpleado.Text != "" && txbNumFact.Text != "" && dtpFecha.Text != "")
            //    {
            CLS.FacturaDeVenta oFacturaDeVenta = new CLS.FacturaDeVenta();
            oFacturaDeVenta.IDFacturaDeVenta = txbIDFactura.Text;
            oFacturaDeVenta.Fecha            = dtpFecha.Value.ToString("yyyy/MM/dd");
            oFacturaDeVenta.FormaDePago      = cbbFormaDePago.Text;
            oFacturaDeVenta.IDCliente        = txbIDCliente.Text;
            oFacturaDeVenta.IDEmpleado       = txbIDEmpleado.Text;
            oFacturaDeVenta.NumeroDeFactura  = txbNumFact.Text;
            oFacturaDeVenta.TotalAPagar      = txbTotalAPagar.Text;
            oFacturaDeVenta.Insertar();

            foreach (DataGridViewRow row in dgvDetalles.Rows)
            {
                String             IDFactura       = CacheController.Cache.CONSULTAR_ID_FACTURA().Rows[0]["IdFactura"].ToString();
                CLS.DetalleFactura oDetalleFactura = new CLS.DetalleFactura();
                oDetalleFactura.Cantidad         = row.Cells[0].Value.ToString();
                oDetalleFactura.Precio           = row.Cells[2].Value.ToString();
                oDetalleFactura.NombreProducto   = row.Cells[1].Value.ToString();
                oDetalleFactura.IDProducto       = row.Cells[6].Value.ToString();
                oDetalleFactura.IDFacturaDeVenta = IDFactura;
                oDetalleFactura.Exento           = row.Cells[3].Value.ToString();
                oDetalleFactura.Gravado          = row.Cells[5].Value.ToString();
                oDetalleFactura.NoSujeto         = row.Cells[4].Value.ToString();
                oDetalleFactura.Insertar();
            }
            //if (txbIDFactura.TextLength > 0)
            //{
            //    //ACTUALIZAR
            //    if (oFacturaDeVenta.Actualizar())
            //    {
            //        CLS.MyMessageBox.ShowMessage("Actualizado");
            //        Close();
            //            }
            //            else
            //            {
            //                CLS.MyMessageBox.ShowMessage("Falló la Actualización");
            //            }
            //        }
            //        else
            //        {
            //            //INSERTAR
            //            if (oFacturaDeVenta.Insertar())
            //            {
            //                MessageBox.Show("Insertado");
            //                Close();
            //            }
            //            else
            //            {
            //                CLS.MyMessageBox.ShowMessage("Falló la Inserción");
            //            }
            //        }
            //    }
            //    else
            //    {
            //        CLS.MyMessageBox.ShowMessage("Tiene que llenar los campos vacios", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    }
            //}
            //catch
            //{
            //    CLS.MyMessageBox.ShowMessage("Ocurrio un Error a la hora de GUARDAR", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
        }