コード例 #1
0
        private void DtGridFacturas_DoubleClick(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(dtGridFacturas.CurrentRow.Cells[0].Value.ToString());

            FrmVerFactura frmFactura = new FrmVerFactura(servicio, id);

            frmFactura.Show();
        }
コード例 #2
0
        private void BtnFacturar_Click(object sender, EventArgs e)
        {
            if (txtCedula.Text != "" && dtGridProductos.Rows.Count > 0)
            {
                if (servicio.VerificarCliente(Convert.ToInt32(txtCedula.Text)))
                {
                    string strFactura = servicio.AgregarFactura(Convert.ToInt32(txtCedula.Text));

                    int idFactura = 0;

                    if (int.TryParse(strFactura, out idFactura))
                    {
                        foreach (DataGridViewRow row in dtGridProductos.Rows)
                        {
                            int idProducto = Convert.ToInt32(row.Cells[0].Value.ToString());
                            int cantidad   = Convert.ToInt32(row.Cells[1].Value.ToString());
                            int precio     = Convert.ToInt32(row.Cells[3].Value.ToString());

                            string strDetalle = servicio.AgregarDetalleFactura(idFactura, idProducto, cantidad, precio);

                            if (strDetalle != "1")
                            {
                                MessageBox.Show("Detalle: " + strDetalle);
                            }
                        }

                        if (MessageBox.Show("La factura ha sido creada exitosamente, ¿quiere ver el reporte de la misma?", "Éxito", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            FrmVerFactura frmFactura = new FrmVerFactura(servicio, idFactura);
                            frmFactura.ShowDialog();
                        }

                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Factura: " + strFactura);
                    }
                }
                else
                {
                    if (MessageBox.Show("La cédula del cliente no está registrada, ¿quiere registrarla ahora mismo?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        FrmClientes frmClientes = new FrmClientes(servicio, Convert.ToInt32(txtCedula.Text));
                        frmClientes.ShowDialog();
                    }
                }
            }
            else
            {
                MessageBox.Show("Debe asociar un cliente y al menos existir un producto en la factura.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }