private void LlenarGrid() { DataTable dt = new DataTable(); A.Idproducto = Convert.ToInt32(Program.Idproduct); dt = A.AlmacenesProductos(); try { dtgAlmacen.Rows.Clear(); for (int x = 0; x < dt.Rows.Count; x++) { dtgAlmacen.Rows.Add(dt.Rows[x][0]); dtgAlmacen.Rows[x].Cells[0].Value = dt.Rows[x][0].ToString(); dtgAlmacen.Rows[x].Cells[1].Value = dt.Rows[x][1].ToString(); dtgAlmacen.Rows[x].Cells[2].Value = dt.Rows[x][2].ToString(); dtgAlmacen.Rows[x].Cells[3].Value = dt.Rows[x][3].ToString(); } dtgAlmacen.ClearSelection(); } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnRegistrar_Click(object sender, EventArgs e) { try { errorProvider1.Clear(); if (Utilidades.ValidarForm(this, errorProvider1) == false) { return; } string mensaje = ""; DataTable dt = new DataTable(); if (dtgFacturacion.Rows.Count > 0) { F.Fecha = dtpFecha.Value; F.Documento = txtDocumento.Text; F.Nota = txtNota.Text; F.Idcaja = Convert.ToInt16(txtCaja.Text); F.Idusuario = Program.Idusuario; F.Idmoneda = Convert.ToInt16(cbMoneda.SelectedValue); F.Idtipof = Convert.ToInt16(cbTipoF.SelectedValue); F.Idmetodop = Convert.ToInt16(cbMetodop.SelectedValue); F.Idcliente = Convert.ToInt16(txtCodigoCliente.Text); F.Idsucursal = Program.Idsucursal; mensaje = F.RegistrarFactura(); if (mensaje == "1") { for (int x = 0; x < dtgFacturacion.Rows.Count; x++) { A.Idproducto = Convert.ToInt16(dtgFacturacion.Rows[x].Cells[1].Value); dt = A.AlmacenesProductos(); F.Idfactura = Program.Idfactura; F.Idproducto = Convert.ToInt32(dtgFacturacion.Rows[x].Cells[1].Value); F.Idalmacen = Convert.ToInt32(dt.Rows[0][0]); F.Idunidad = Convert.ToInt32(dtgFacturacion.Rows[x].Cells[3].Value); F.Cantidad = Convert.ToDouble(dtgFacturacion.Rows[x].Cells[2].Value); F.Precio = Convert.ToDouble(dtgFacturacion.Rows[x].Cells[6].Value); F.Importe = Convert.ToDouble(dtgFacturacion.Rows[x].Cells[7].Value); F.Itbis = Convert.ToDouble(dtgFacturacion.Rows[x].Cells[8].Value); mensaje = F.RegistrarDetalleFactura(); dt.Rows.Clear(); } if (mensaje == "1") { MessageBoxEx.Show("Registrado con éxito", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information); dtgFacturacion.Rows.Clear(); Limpiar(); txtNota.Clear(); if (chbNCF.Checked == true) { N.Tipocf = "2"; N.Secuencia = Program.Ncf; N.ActualizarSecuencia(); } chbNCF.Checked = false; if (cbTipoF.Text == "Credito") { Cc.Idcliente = Convert.ToInt16(txtCodigoCliente.Text); Cc.Idfactura = Program.Idfactura; Cc.Monto = total1; Cc.Registrar(); } else { C.Idcaja = Convert.ToInt16(txtCaja.Text); C.Idusuario = Program.Idusuario; C.Monto = total1; C.Tipo = Convert.ToInt16(cbMetodop.SelectedValue); C.Idmoneda = Convert.ToInt16(cbMoneda.SelectedValue); C.RegistrarActualizarCuadreCaja(); } txtCodigoCliente.Clear(); txtCliente.Clear(); frmReporte obj = new frmReporte(); obj.Valor = 8; obj.Reporte = "factura.rdlc"; obj.Idfactura = Program.Idfactura; lbTotal.Text = "0.00"; Autocompletar(); obj.ShowDialog(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }