public ListaFactura()
        {
            InitializeComponent();
            this.ControlBox    = false;
            this.Text          = "FACTURAS";
            this.StartPosition = FormStartPosition.Manual;
            this.Location      = new Point(50, 20);
            formListaFactura   = this;
            gridParams();
            cmbEstado();
            objOtDAO        = new OtDAO();
            objDocumentoDao = new DocumentoDAO();
            DateTime d1, d2;

            objMonedaDao = new MonedaDAO();
            objMonedaDao.tipoCambio();
            d2 = DateTime.Now;
            d1 = new DateTime(2018, 10, 1);
            dpickerInicio.Value     = d1;
            objListaDocumentoCab    = objDocumentoDao.listarCabecera(d1, d2, txt_Ruc.Text, "01", Ventas.UNIDADNEGOCIO);
            grd_Facturas.DataSource = objListaDocumentoCab;
            grd_Facturas.Refresh();
            grd_Facturas.CellClick += Grd_Facturas_CellClick;
            sumatorias();
            cmb_Estado.SelectedIndexChanged += Cmb_Estado_SelectedIndexChanged;
        }
Exemple #2
0
        private void FacturaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            facturaToolStripMenuItem.Enabled = false;
            ListaFactura Check = new ListaFactura();

            Check.Show();
        }
        private void btn_Regresar_Click(object sender, EventArgs e)
        {
            this.Hide();
            ListaFactura.operacionFactura = "Q";
            ListaFactura Check = new ListaFactura();

            Check.Show();
        }
 public MotivoAnulacion(String tipo)
 {
     InitializeComponent();
     objDocumentoDao = new DocumentoDAO();
     cargarCombo();
     tipoDocu = tipo;
     if (tipo == "F")
     {
         formFac = ListaFactura.formListaFactura;
     }
     else if (tipo == "B")
     {
         formBol = ListaBoleta.formListaBoleta;
     }
     else if (tipo == "C")
     {
         formCred = ListaNotaCredito.formListaCredito;
     }
     else if (tipo == "D")
     {
         formDeb = ListaNotaDebito.formListaDebito;
     }
 }
        private void btn_SaveData_Click(object sender, EventArgs e)
        {
            btn_SaveData.Enabled = false;
            if (objListDocumentoDet.Count == 0)
            {
                MessageBox.Show("No puede guardar sin Detalle");
                return;
            }
            bool binsertar, bupdate, bdetalle = true;
            bool bupdatedet = true;

            objDocumentoCab = new DocumentoCab();
            objDocumentoCab.DocumentoCabSerie                = txt_Serie.Text;
            objDocumentoCab.DocumentoCabNro                  = txt_Numero.Text;
            objDocumentoCab.DocumentoCabClienteCod           = txt_codcliente.Text;
            objDocumentoCab.DocumentoCabFecha                = dpick_Fecha.Value;
            objDocumentoCab.DocumentoCabGlosa                = txt_GlosaCab.Text;
            objDocumentoCab.DocumentoCabIGV                  = convertToDouble(txt_IGV.Text);
            objDocumentoCab.DocumentoCabTotalSinIGV          = convertToDouble(txt_ValorVenta.Text);
            objDocumentoCab.DocumentoCabTotal                = convertToDouble(txt_TotalPagar.Text);
            objDocumentoCab.DocumentoCabTipoDoc              = "01";
            objDocumentoCab.DocumentoCabTipoPago             = Convert.ToInt32(cmb_Pago.SelectedValue);
            objDocumentoCab.DocumentoCabTipoMoneda           = cmb_Moneda.SelectedValue.ToString();
            objDocumentoCab.DocumentoCabUsuAdd               = Ventas.UsuarioSession;
            objDocumentoCab.DocumentoCabFechaVcto            = dpck_Fechavcto.Value;
            objDocumentoCab.DocumentoCabFechaDocRef          = new DateTime(2000, 1, 1);
            objDocumentoCab.DocumentoCabDetraccion           = convertToDouble(txt_Detraccion.Text);
            objDocumentoCab.DocumentoCabDetraccionPorcentaje = convertToDouble(txt_Porcentaje.Text);
            objDocumentoCab.DocumentoCabGuia                 = txt_Guia.Text;
            objDocumentoCab.DocumentoCabOrdenCompra          = txt_Pedido.Text;
            objDocumentoCab.DocumentoCabTabla                = txt_Tabla.Text;
            objDocumentoCab.DocumentoCabOtCod                = txt_OT.Text;
            objDocumentoCab.Intercorp = txt_intercorp.Text;

            if (!String.IsNullOrEmpty(txt_itemOt.Text))
            {
                objDocumentoCab.DocumentoCabItemOt = Convert.ToInt32(txt_itemOt.Text);
            }
            else
            {
                objDocumentoCab.DocumentoCabItemOt = 0;
            }
            if (Modificar == "G")
            {
                binsertar = objDocumento.insertarCabecera(objDocumentoCab, Ventas.UNIDADNEGOCIO);

                string msg = "";
                if (binsertar)
                {
                }
                else
                {
                    msg = "Hubo un problema al guardar";
                    MessageBox.Show(msg);
                    btn_SaveData.Enabled = true;

                    return;
                }
                for (int i = 0; i < objListDocumentoDet.Count; i++)
                {
                    bdetalle = objDocumento.insertDetalle(objListDocumentoDet[i]);
                    if (bdetalle == false)
                    {
                        MessageBox.Show("Error al guardar");
                        btn_SaveData.Enabled = true;
                        break;
                    }
                }
                if (bdetalle)
                {
                    MessageBox.Show("Factura Guardada exitosamente");

                    btn_SaveData.Enabled = true;
                }
                DialogResult dialogResult = MessageBox.Show("Enviar a Sunat?", "ENVIAR DOCUMENTOS", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    objDocumentoElectronicoCab = objDocumento.getDocumentoElectronicoCab(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO);
                    String NroExtranjero = " ";
                    if (cmb_tipoFac.SelectedValue.ToString() == "20")
                    {
                        NroExtranjero = cmb_tipoFac.SelectedValue.ToString();
                        objListDocumentoElectronicoDet = objDocumento.getDocumentoElectronicoDet(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO);
                    }
                    else
                    {
                        objListDocumentoElectronicoDet = objDocumento.getDocumentoElectronicoDet(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO);
                    }
                    String rutatext = objProceso.generarText(objDocumentoElectronicoCab, objListDocumentoElectronicoDet);
                    String mess     = objProceso.sendTxt(rutatext);

                    String   mensajeMostrar = "";
                    String[] array          = mess.Split('|');

                    List <String> objListaString = array.ToList();
                    if (objListaString.Count < 10)
                    {
                        mensajeMostrar = objListaString[1];
                        objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar);
                        // objDocumento.updateEstadoAnulado(txt_Serie.Text, txt_Numero.Text);
                    }
                    else
                    {
                        mensajeMostrar = objListaString[9];
                        if (mensajeMostrar == "true")
                        {
                            mensajeMostrar = "Documento Enviado";
                            objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar);
                            // objDocumento.updateEstadoAceptado(txt_Serie.Text, txt_Numero.Text);
                            objDocumento.updateEstadoEnviado(txt_Serie.Text, txt_Numero.Text);
                        }
                        else
                        {
                            objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar);
                        }
                    }


                    MessageBox.Show(mensajeMostrar);
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
            }
            else
            /*cuando se actualiza cuple esta funcion */
            {
                /*procedure para actualizar la cabecera*/
                bupdate = objDocumento.updateCabecera(objDocumentoCab);
                string msg = "";
                if (bupdate)
                {
                }
                else
                {
                    msg = "Hubo un problema al guardar";
                    MessageBox.Show(msg);
                    btn_SaveData.Enabled = true;
                    return;
                }
                /// delete
                objDocumento.deleteDetDoc(objDocumentoCab.DocumentoCabSerie, objDocumentoCab.DocumentoCabNro);
                /*for para insertar el detalle*/
                for (int i = 0; i < objListDocumentoDet.Count; i++)
                {
                    bupdatedet = objDocumento.insertDetalle(objListDocumentoDet[i]);
                    if (bupdatedet == false)
                    {
                        MessageBox.Show("Error al guardar");
                        btn_SaveData.Enabled = true;
                        break;
                    }
                }
                if (bupdatedet)
                {
                    MessageBox.Show("Factura Guardada exitosamente");

                    btn_SaveData.Enabled = true;
                }
            }
            //nuevoRegistro();
            this.Hide();
            ListaFactura.operacionFactura = "Q";
            ListaFactura Check = new ListaFactura();

            Check.Show();
        }