コード例 #1
0
        private void btn_ver_Click(object sender, EventArgs e)
        {
            operacionFactura = "V";
            try
            {
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                numeroDocumento = objListaDocumentoCab[index].DocumentoCabNro;
                numeroSerie     = objListaDocumentoCab[index].DocumentoCabSerie;
                objDocumentoCab = objListaDocumentoCab[index];
                this.Hide();

                Factura Check = new Factura();
                Check.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex.Message);
            }
        }
コード例 #2
0
        private void btn_ver_Click(object sender, EventArgs e)
        {
            operacionFactura = "V";
            try
            {
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                numeroDocumento = objListaDocumentoCab[index].DocumentoCabNro;
                numeroSerie     = objListaDocumentoCab[index].DocumentoCabSerie;
                objDocumentoCab = objListaDocumentoCab[index];
                this.Hide();

                NotaDeDebito Check = new NotaDeDebito();
                Check.Show();
            }
            catch
            {
                MessageBox.Show("No ha seleccionado ningún registro");
            }
        }
コード例 #3
0
        private void Grd_Facturas_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = grd_Facturas.SelectedCells[0].RowIndex;

            numeroDocumento   = objListaDocumentoCab[index].DocumentoCabNro;
            numeroSerie       = objListaDocumentoCab[index].DocumentoCabSerie;
            lbl_Sunat.Visible = true;
            lbl_Sunat.Text    = objDocumentoDao.getSunatObs(numeroSerie, numeroDocumento);
            objDocumentoCab   = objListaDocumentoCab[index];
            switch (objDocumentoCab.EstadoSunat)
            {
            case 0:
                btn_EnviarSunat.Enabled  = false;
                btn_Anular.Enabled       = false;
                btn_ConAnulacion.Enabled = true;
                btn_Consultar.Enabled    = true;
                break;

            case 1:
                btn_EnviarSunat.Enabled  = true;
                btn_Anular.Enabled       = false;
                btn_ConAnulacion.Enabled = false;
                btn_Consultar.Enabled    = false;
                break;

            case 2:
                btn_EnviarSunat.Enabled  = false;
                btn_Anular.Enabled       = false;
                btn_ConAnulacion.Enabled = false;
                btn_Consultar.Enabled    = true;
                break;

            case 3:
                btn_EnviarSunat.Enabled  = false;
                btn_Anular.Enabled       = true;
                btn_Consultar.Enabled    = true;
                btn_ConAnulacion.Enabled = false;
                break;
            }
        }
コード例 #4
0
        private void btn_pdf_Click(object sender, EventArgs e)
        {
            try
            {
                btn_pdf.Enabled = false;
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                objDocumentoCab = objListaDocumentoCab[index];
                String codigoagenerar = "20300166611|07" + "|" +
                                        objDocumentoCab.DocumentoCabSerie + "|" + objDocumentoCab.DocumentoCabNro + "|" + objDocumentoCab.DocumentoCabIGV.ToString("C").Substring(3).Trim() + "|"
                                        + objDocumentoCab.DocumentoCabTotal.ToString("C").Substring(3).Trim() + "|" + objDocumentoCab.DocumentoCabFecha.ToString("dd-MM-yyyy") + "|" + "6|" + objDocumentoCab.DocumentoCabClienteDocumento + "|";
                String nombreArchivo = objDocumentoCab.DocumentoCabSerie + "-" + objDocumentoCab.DocumentoCabNro;
                String qr            = objProceso.genearQr(nombreArchivo, codigoagenerar);


                formatearFactura(qr);
                NotaFecha cr = new NotaFecha();

                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr.SetDataSource(objListNotaReporte);

                saveFileDialog1.FileName = "20300166611-07-" + objDocumentoCab.DocumentoCabSerie +
                                           "-" + objDocumentoCab.DocumentoCabNro + ".pdf";
                saveFileDialog1.DefaultExt = "pdf";
                saveFileDialog1.Filter     = "Pdf files (*.pdf)|*.pdf";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @saveFileDialog1.FileName);
                }
                btn_pdf.Enabled = true;
            }
            catch
            {
                MessageBox.Show("No ha seleccionado ningún registro");
                btn_pdf.Enabled = true;
            }


            // System.Web.HttpResponse res = new System.Web.HttpResponse();
        }
コード例 #5
0
 public void setDatos(DocumentoCab objCab)
 {
     objDocumentoCab    = objCab;
     txt_Cliente.Text   = objDocumentoCab.DocumentoCabCliente;
     txt_Direccion.Text = objDocumentoCab.DocumentoCabClienteDireccion;
     txt_Ruc.Text       = objDocumentoCab.DocumentoCabClienteDocumento;
     txt_Telefono.Text  = objDocumentoCab.DocumentoCabClienteTelefono;
     // dpick_Fecha.Value = objDocumentoCab.DocumentoCabFecha;
     dpck_Fechavcto.Value    = objDocumentoCab.DocumentoCabFechaVcto;
     txt_Aval.Text           = objDocumentoCab.DocumentoCabClienteAval;
     txt_DireccionAval.Text  = objDocumentoCab.DocumentoCabClienteDireccionAval;
     txt_RucAval.Text        = objDocumentoCab.DocumentoCabClienteRucAval;
     txt_TelefAval.Text      = objDocumentoCab.DocumentoCabClienteTelefonoAval;
     txt_Serie.Text          = objDocumentoCab.DocumentoCabSerie;
     txt_Numero.Text         = objDocumentoCab.DocumentoCabNro;
     txt_AvalCod.Text        = objDocumentoCab.DocumentoCabClienteCodAval;
     txt_codcliente.Text     = objDocumentoCab.DocumentoCabClienteCod;
     objListaLetraDet        = objDocumentoDao.listarLetraDetRenovacion(txt_Serie.Text, txt_Numero.Text);
     grdDocumento.DataSource = objListaLetraDet;
     grdDocumento.Refresh();
     llenarSumatorias();
 }
コード例 #6
0
        private void btn_excel_Click(object sender, EventArgs e)
        {
            try
            {
                btn_excel.Enabled = false;
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                objDocumentoCab = objListaDocumentoCab[index];
                String codigoagenerar = "20300166611|01" + "|" +
                                        objDocumentoCab.DocumentoCabSerie + "|" + objDocumentoCab.DocumentoCabNro + "|" + objDocumentoCab.DocumentoCabIGV.ToString("C").Substring(3).Trim() + "|"
                                        + objDocumentoCab.DocumentoCabTotal.ToString("C").Substring(3).Trim() + "|" + objDocumentoCab.DocumentoCabFecha.ToString("dd-MM-yyyy") + "|" + "6|" + objDocumentoCab.DocumentoCabClienteDocumento + "|";
                String nombreArchivo = objDocumentoCab.DocumentoCabSerie + "-" + objDocumentoCab.DocumentoCabNro;
                String qr            = objProceso.genearQr(nombreArchivo, codigoagenerar);


                formatearFactura(qr);
                FacturaFecha cr = new FacturaFecha();

                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr.SetDataSource(objListFacturaReporte);

                saveFileDialog1.FileName = "20300166611-07-" + objDocumentoCab.DocumentoCabSerie +
                                           "-" + objDocumentoCab.DocumentoCabNro + ".xls";
                saveFileDialog1.DefaultExt = "xls";
                saveFileDialog1.Filter     = "Excel files (*.xls)|*.xls";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, @saveFileDialog1.FileName);
                }
                btn_excel.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR :" + ex.Message);
                btn_excel.Enabled = true;
            }
        }
コード例 #7
0
ファイル: Boleta.cs プロジェクト: JoseCR19/ContabilidadMimco
        private void btn_SaveData_Click(object sender, EventArgs e)
        {
            btn_SaveData.Enabled = false;
            bool binsertar, bdetalle = 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     = "03";
            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.DocumentoCabGuia        = txt_Guia.Text;
            objDocumentoCab.DocumentoCabOrdenCompra = txt_Pedido.Text;

            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("Boleta 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);
                objListDocumentoElectronicoDet = objDocumento.getDocumentoElectronicoDet(txt_Serie.Text, txt_Numero.Text, Ventas.UNIDADNEGOCIO);
                String rutatext = objProceso.generarText(objDocumentoElectronicoCab, objListDocumentoElectronicoDet);
                String mess     = objProceso.sendTxt(rutatext);
                objDocumento.updateEstadoEnviado(txt_Serie.Text, txt_Numero.Text);
                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 Aceptado";
                        objDocumento.updateObservacionSunat(txt_Serie.Text, txt_Numero.Text, mensajeMostrar);
                        objDocumento.updateEstadoAceptado(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
            }
            //nuevoRegistro();
            this.Hide();
            ListaBoleta.operacionFactura = "Q";
            ListaBoleta Check = new ListaBoleta();

            Check.Show();
        }
コード例 #8
0
        private void btn_imprimir_Click(object sender, EventArgs e)
        {
            string root = @"N:\PDF";

            if (!Directory.Exists(root))
            {
                Directory.CreateDirectory(root);
            }
            try
            {
                btn_imprimir.Enabled = false;
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                objDocumentoCab = objListaDocumentoCab[index];
                String codigoagenerar = "20300166611|01" + "|" +
                                        objDocumentoCab.DocumentoCabSerie + "|" + objDocumentoCab.DocumentoCabNro + "|" + objDocumentoCab.DocumentoCabIGV.ToString("C").Substring(3).Trim() + "|"
                                        + objDocumentoCab.DocumentoCabTotal.ToString("C").Substring(3).Trim() + "|" + objDocumentoCab.DocumentoCabFecha.ToString("dd-MM-yyyy") + "|" + "6|" + objDocumentoCab.DocumentoCabClienteDocumento + "|";
                String nombreArchivo = objDocumentoCab.DocumentoCabSerie + "-" + objDocumentoCab.DocumentoCabNro;
                String qr            = objProceso.genearQr(nombreArchivo, codigoagenerar);


                formatearFactura(qr);
                FacturaFecha cr  = new FacturaFecha();
                string       rut = @"N:\PDF\20300166611-" + objDocumentoCab.DocumentoCabSerie + "-" + objDocumentoCab.DocumentoCabNro + ".pdf";
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                if (File.Exists(rut))
                {
                    File.Delete(rut);
                }
                cr.SetDataSource(objListNotaReporte);
                cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, rut);
                using (PrintDialog Dialog = new PrintDialog())
                {
                    Dialog.ShowDialog();

                    ProcessStartInfo printProcessInfo = new ProcessStartInfo()
                    {
                        Verb           = "print",
                        CreateNoWindow = true,
                        FileName       = rut,
                        WindowStyle    = ProcessWindowStyle.Hidden
                    };

                    Process printProcess = new Process();
                    printProcess.StartInfo = printProcessInfo;
                    printProcess.Start();

                    printProcess.WaitForInputIdle();

                    Thread.Sleep(3000);

                    if (false == printProcess.CloseMainWindow())
                    {
                        printProcess.Kill();
                    }
                }
                btn_imprimir.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                btn_imprimir.Enabled = true;
            }
        }
コード例 #9
0
        private void btn_SaveData_Click(object sender, EventArgs e)
        {
            btn_SaveData.Enabled = false;
            bool binsertar, bdetalle = 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.DocumentoCabClienteCodAval = txt_AvalCod.Text;
            objDocumentoCab.DocumentoCabUsuAdd         = Ventas.UsuarioSession;
            objDocumentoCab.DocumentoCabTotal          = convertToDouble(txt_Total.Text);
            objDocumentoCab.DocumentoCabTipoDoc        = "LT";
            objDocumentoCab.DocumentoCabTipoPago       = Convert.ToInt32(cmb_Pago.SelectedValue);
            try
            {
                objDocumentoCab.DocumentoCabDividir = Convert.ToInt32(txt_Dividir.Text);
            }
            catch
            {
                objDocumentoCab.DocumentoCabDividir = 0;
            }

            objDocumentoCab.DocumentoCabFecha     = dpick_Fecha.Value;
            objDocumentoCab.DocumentoCabFechaVcto = dpck_Fechavcto.Value;

            objDocumentoCab.DocumentoCabDetraccion           = convertToDouble(txt_TotalDetraccion.Text);
            objDocumentoCab.DocumentoCabDetraccionPorcentaje = convertToDouble(txt_Porcentaje.Text);
            objDocumentoCab.DocumentoCabAbono      = convertToDouble(txt_TotalCanjeado.Text);
            objDocumentoCab.DocumentoCabSaldo      = objDocumentoCab.DocumentoCabTotal - (objDocumentoCab.DocumentoCabAbono + objDocumentoCab.DocumentoCabDetraccion);
            objDocumentoCab.DocumentoCabTipoMoneda = txt_CodMoneda.Text;
            objDocumentoCab.DocumentoCabSerieRef   = txt_SerieDcto.Text;
            objDocumentoCab.DocumentoCabNroRef     = txt_NumeroDcto.Text;

            if (Modificar == "M")
            {
                binsertar = objDocumentoDao.updateLetraCab(objDocumentoCab, Ventas.UNIDADNEGOCIO, Ventas.UsuarioSession);

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

                    return;
                }
                objDocumentoDao.deleteLetraDet(objDocumentoCab.DocumentoCabSerie, objDocumentoCab.DocumentoCabNro);
                for (int i = 0; i < objListaLetraDet.Count; i++)
                {
                    bdetalle = objDocumentoDao.insertLetraDet(objListaLetraDet[i]);
                    if (bdetalle == false)
                    {
                        MessageBox.Show("Error al guardar");
                        btn_SaveData.Enabled = true;
                        break;
                    }
                }
                if (bdetalle)
                {
                    MessageBox.Show("Letra Guardada exitosamente");
                    nuevoRegistro();
                    btn_SaveData.Enabled = true;
                }
            }
            else
            {
                binsertar = objDocumentoDao.insertarLetraCab(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 < objListaLetraDet.Count; i++)
                {
                    bdetalle = objDocumentoDao.insertLetraDet(objListaLetraDet[i]);
                    if (bdetalle == false)
                    {
                        MessageBox.Show("Error al guardar");
                        btn_SaveData.Enabled = true;
                        break;
                    }
                }
                if (bdetalle)
                {
                    MessageBox.Show("Letra Guardada exitosamente");
                    nuevoRegistro();
                    btn_SaveData.Enabled = true;
                }
            }

            this.Hide();
            objListaLetraDet = null;
            ListaLetraCambio.operacionLetra = "Q";
            ListaLetraCambio Check = new ListaLetraCambio();

            Check.Show();
        }
コード例 #10
0
        private void btn_excel_Click(object sender, EventArgs e)
        {
            try
            {
                btn_excel.Enabled = false;
                // String fileName = @"C:\FACTURACION\EXCEL\";
                //String path = @"C:\FACTURACION\EXCEL";
                String fileName = @"N:\EXCEL\";
                String path     = @"N:\EXCEL";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                objDocumentoCab = objListaDocumentoCab[index];
                formatearLetra();
                Random rnd       = new Random();
                int    randomnum = rnd.Next(1000);


                fileName = fileName + objDocumentoCab.DocumentoCabSerie.Substring(0, 1) + " - " + objDocumentoCab.DocumentoCabNro + "-" + randomnum + ".xls";
                Letras cr = new Letras();


                cr.SetDataSource(objListaLetraReporte);

                ExportOptions              exportOpts      = new ExportOptions();
                ExcelFormatOptions         excelFormatOpts = new ExcelFormatOptions();
                DiskFileDestinationOptions diskOpts        = new DiskFileDestinationOptions();
                exportOpts = cr.ExportOptions;

                // Set the excel format options.
                excelFormatOpts.ExcelUseConstantColumnWidth = true;
                excelFormatOpts.ExcelTabHasColumnHeadings   = true;
                excelFormatOpts.ShowGridLines = true;
                exportOpts.ExportFormatType   = ExportFormatType.Excel;
                exportOpts.FormatOptions      = excelFormatOpts;

                // Set the disk file options and export.
                exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
                diskOpts.DiskFileName            = fileName;
                exportOpts.DestinationOptions    = diskOpts;

                cr.Export();
                FileInfo fi = new FileInfo(fileName);
                if (fi.Exists)
                {
                    System.Diagnostics.Process.Start(fileName);
                }
                else
                {
                    //file doesn't exist
                }

                btn_excel.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR :" + ex.Message);
                btn_excel.Enabled = true;
            }
        }
コード例 #11
0
        public List <DocumentoCab> listarDocCabAsientos(String tipodocu, String codent)
        {
            Conexion            _Conexion = new Conexion("Contabilidad");
            List <DocumentoCab> objLista  = new List <DocumentoCab>();
            DocumentoCab        obj;
            Database            db        = DatabaseFactory.CreateDatabase("Contabilidad");
            DbCommand           dbCommand = db.GetStoredProcCommand("sp_buscarDocumentoAsiento",
                                                                    new object[] { tipodocu, codent });

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    obj = new DocumentoCab();
                    obj.DocumentoCabCliente              = dataReader["Cli_RazonSocial"].ToString().Trim();
                    obj.DocumentoCabSerie                = dataReader["DOCcab_Serie"].ToString().Trim();
                    obj.DocumentoCabNro                  = dataReader["DOCcab_Codigo"].ToString();
                    obj.DocumentoCabMoneda               = dataReader["Mon_Descripcion"].ToString();
                    obj.DocumentoCabClienteDocumento     = dataReader["Cli_NDocumento"].ToString().Trim();
                    obj.DocumentoCabUsuAdd               = dataReader["DOCcab_UsuAdd"].ToString();
                    obj.DocumentoCabDetraccionPorcentaje = convertToDouble(dataReader["DOCcab_DetraccionPorcentaje"].ToString());
                    obj.DocumentoCabDetraccion           = convertToDouble(dataReader["DOCcab_Detraccion"].ToString());
                    obj.DocumentoCabTabla                = dataReader["tabla"].ToString();
                    string aux3 = dataReader["DOCcab_FechaAdd"].ToString();
                    if (!String.IsNullOrEmpty(aux3))
                    {
                        obj.DocumentoCabFechaAdd = Convert.ToDateTime(Convert.ToDateTime(aux3).ToShortDateString());
                    }
                    else
                    {
                        obj.DocumentoCabFechaAdd = new DateTime(2000, 1, 1);
                    }
                    string aux = dataReader["DOCcab_Fecha"].ToString();
                    if (!String.IsNullOrEmpty(aux))
                    {
                        obj.DocumentoCabFecha = Convert.ToDateTime(Convert.ToDateTime(aux).ToShortDateString());
                    }
                    else
                    {
                        obj.DocumentoCabFecha = new DateTime(2000, 1, 1);
                    }

                    string aux2 = dataReader["DOCcab_FechaVcto"].ToString();
                    if (!String.IsNullOrEmpty(aux2))
                    {
                        obj.DocumentoCabFechaVcto = Convert.ToDateTime(Convert.ToDateTime(aux2).ToShortDateString());
                    }
                    else
                    {
                        obj.DocumentoCabFechaVcto = new DateTime(2000, 1, 1);
                    }
                    obj.DocumentoCabIGV              = convertToDouble(dataReader["DOCcab_TotalIGV"].ToString());
                    obj.DocumentoCabTotalSinIGV      = convertToDouble(dataReader["DOCcab_TotalSinIGV"].ToString());
                    obj.DocumentoCabTotal            = convertToDouble(dataReader["DOCcab_Total"].ToString());
                    obj.DocumentoCabTipoMoneda       = dataReader["DOCcab_Moneda"].ToString();
                    obj.DocumentoCabPago             = dataReader["TPago_Descripcion"].ToString();
                    obj.DocumentoCabGlosa            = dataReader["DOCcab_Glosa"].ToString();
                    obj.DocumentoCabTipoNotaCredito  = dataReader["DOCcab_TipoNotaCredito"].ToString();
                    obj.DocumentoCabTipoNotaDebito   = dataReader["DOCcab_TipoNotaDebito"].ToString();
                    obj.DocumentoCabClienteDireccion = dataReader["Cli_Direccion"].ToString().Trim();
                    obj.DocumentoCabTipoPago         = Convert.ToInt32(dataReader["DOCcab_TipoPago"].ToString());
                    obj.DocumentoCabNotaCredito      = dataReader["TCredito_Descripcion"].ToString();
                    obj.DocumentoCabNotaDebito       = dataReader["TDebito_Descripcion"].ToString();
                    obj.DocumentoCabTipoDocRef       = dataReader["DOCcab_TipoDocRef"].ToString();
                    obj.DocumentoCabSerieRef         = dataReader["DOCcab_SerieRef"].ToString().Trim();
                    obj.DocumentoCabNroRef           = dataReader["DOCcab_NumeroRef"].ToString().Trim();
                    obj.DocumentoCabTipoDoc          = dataReader["TipoDoc"].ToString().Trim();
                    string aux4 = dataReader["FechaRef"].ToString();
                    if (!String.IsNullOrEmpty(aux4))
                    {
                        obj.DocumentoCabFechaDocRef = Convert.ToDateTime(Convert.ToDateTime(aux4).ToShortDateString());
                    }
                    else
                    {
                        obj.DocumentoCabFechaDocRef = new DateTime(2000, 1, 1);
                    }
                    obj.DocumentoCabOrdenCompra = dataReader["DOCcab_OrdenCompra"].ToString();
                    obj.DocumentoCabGuia        = dataReader["DOCCAB_GUIA"].ToString();
                    obj.EstadoSunat             = Convert.ToInt32(dataReader["EstadoSunat"].ToString());
                    objLista.Add(obj);
                }
            }
            return(objLista);
        }
コード例 #12
0
        private void Grd_Facturas_Click(object sender, EventArgs e)
        {
            int index = grd_Facturas.SelectedCells[0].RowIndex;

            objDocumentoCab = objListaDocumentoCab[index];
        }
コード例 #13
0
ファイル: Factura.cs プロジェクト: JoseCR19/ContabilidadMimco
        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();
        }
コード例 #14
0
ファイル: Factura.cs プロジェクト: JoseCR19/ContabilidadMimco
        public Factura()
        {
            InitializeComponent();
            Modificar          = "G";
            this.StartPosition = FormStartPosition.Manual;
            this.Location      = new Point(50, 20);
            this.ControlBox    = false;
            this.Text          = "FACTURAS";
            formFactura        = this;
            objMonedaDao       = new MonedaDAO();
            objMonedaDao.tipoCambio();
            objEjercicio   = new Ejercicio();
            objTipoPagoDao = new TipoPagoDAO();
            objDocumento   = new DocumentoDAO();
            objProceso     = new Proceso();
            comboMoneda();
            comboPago();
            cmbejercicio();
            chk_Detraccion.CheckedChanged += Chk_Detraccion_CheckedChanged;
            cmb_Pago.SelectedIndexChanged += Cmb_Pago_SelectedIndexChanged;
            gridParams();
            txt_Porcentaje.TextChanged += Txt_Porcentaje_TextChanged;
            txt_Porcentaje.Text         = "0";
            if (ListaFactura.operacionFactura == "V")
            {
                if (ListaFactura.objDocumentoCab.EstadoSunat == 0)
                {
                    lbl_Anulado.Visible = true;
                }
                else if (ListaFactura.objDocumentoCab.EstadoSunat == 1)
                {
                    btn_Modificar.Visible = true;
                }
                habilitarBotones(false, false);
                habilitarCampos(false);
                txt_Guia.Enabled       = false;
                txt_OT.Enabled         = false;
                txt_Pedido.Enabled     = false;
                txt_GlosaCab.Enabled   = false;
                btn_BuscarOT.Enabled   = false;
                btn_Limpiar.Enabled    = false;
                btn_SaveData.Enabled   = false;
                btn_Buscar.Enabled     = false;
                dpck_Fechavcto.Enabled = false;
                dpick_Fecha.Enabled    = false;
                cmb_Moneda.Enabled     = false;
                cmb_Pago.Enabled       = false;

                if (ListaFactura.objDocumentoCab.DocumentoCabTipoMoneda == "USD")
                {
                    lbl_Moneda.Text = "$";
                }
                else
                {
                    lbl_Moneda.Text = "S/";
                }
                objDocumentoDet = new DocumentoDet();

                if (objDocumentoDet.DocumentoProdUM == "NIU")
                {
                    txt_umcod.Text = "039";
                }
                else
                {
                    txt_umcod.Text = "040";
                }

                txt_Cliente.Text         = ListaFactura.objDocumentoCab.DocumentoCabCliente;
                txt_Ruc.Text             = ListaFactura.objDocumentoCab.DocumentoCabClienteDocumento;
                txt_Serie.Text           = ListaFactura.objDocumentoCab.DocumentoCabSerie;
                txt_Numero.Text          = ListaFactura.objDocumentoCab.DocumentoCabNro;
                txt_GlosaCab.Text        = ListaFactura.objDocumentoCab.DocumentoCabGlosa;
                txt_Direccion.Text       = ListaFactura.objDocumentoCab.DocumentoCabClienteDireccion;
                cmb_Moneda.SelectedValue = ListaFactura.objDocumentoCab.DocumentoCabTipoMoneda;
                objListDocumentoDet      = objDocumento.listarDetalle(ListaFactura.numeroDocumento, ListaFactura.numeroSerie, Ventas.UNIDADNEGOCIO);
                dpick_Fecha.Value        = ListaFactura.objDocumentoCab.DocumentoCabFecha;
                tipoCambio(dpick_Fecha.Value.ToShortDateString());
                cmb_Pago.SelectedValue = ListaFactura.objDocumentoCab.DocumentoCabTipoPago;
                txt_Detraccion.Text    = ListaFactura.objDocumentoCab.DocumentoCabDetraccion.ToString();
                txt_Porcentaje.Text    = ListaFactura.objDocumentoCab.DocumentoCabDetraccionPorcentaje.ToString();
                txt_Guia.Text          = ListaFactura.objDocumentoCab.DocumentoCabGuia;
                txt_intercorp.Text     = ListaFactura.objDocumentoCab.Intercorp;
                txt_Pedido.Text        = ListaFactura.objDocumentoCab.DocumentoCabOrdenCompra;
                txt_codcliente.Text    = ListaFactura.objDocumentoCab.DocumentoCabClienteCod;
                grd_Detalle.DataSource = objListDocumentoDet;
                grd_Detalle.Refresh();
                llenarSumatorias();
            }
            else
            {
                if (Ventas.UNIDADNEGOCIO == "01")
                {
                    txt_Serie.Text = "F001";
                }
                else
                {
                    txt_Serie.Text = "F005";
                }

                txt_Numero.Text      = objDocumento.correlativoFactura("01", Ventas.UNIDADNEGOCIO, txt_Serie.Text);
                dpck_Fechavcto.Value = DateTime.Now.AddMonths(1);
                habilitarCampos(false);
                tipoCambio(DateTime.Now.ToShortDateString());
                objDocumentoCab     = new DocumentoCab();
                objListDocumentoDet = new List <DocumentoDet>();
                ContadorItem        = 1;
            }

            rb_OT.Select();



            dpick_Fecha.TextChanged += Dpick_Fecha_TextChanged;

            txt_PrecioUnitario.TextChanged += Txt_PrecioUnitario_TextChanged;
            txt_Cantidad.TextChanged       += Txt_Cantidad_TextChanged;
            txt_Percepcion.Text             = "0";
            grd_Detalle.CellClick          += Grd_Detalle_CellClick;

            cmb_Moneda.SelectedValueChanged += Cmb_Moneda_SelectedValueChanged;
        }