示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("De verdad desea eliminar los datos de la cuenta seleccionada", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
                    facturasdao.IDCuentaPac = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                    string resultado = facturasdao.eliminadatospac();
                    if (resultado == "Correcto")
                    {
                        cargacuentas();
                        limpiatextos();
                    }
                    else
                    {
                        MessageBox.Show(resultado);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 private void button10_Click(object sender, EventArgs e)
 {
     if ((comboBox2.SelectedIndex != -1))
     {
         DAO.FelWebServiceDAO webservice   = new EquimarFac.DAO.FelWebServiceDAO();
         string[]             respuesta    = new string[5];
         DAO.FacturasDAO      facturasdao1 = new EquimarFac.DAO.FacturasDAO();
         facturasdao1.Nombre      = comboBox2.Text;
         dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
         foreach (DataGridViewRow row in dataGridView2.Rows)
         {
             webservice.CuentaFEL   = row.Cells[1].Value.ToString();
             webservice.emisorRFC   = row.Cells[0].Value.ToString();
             webservice.PasswordFEL = row.Cells[2].Value.ToString();
         }
         respuesta = webservice.consultarcreditos();
         if (respuesta[0] == "True")
         {
             MessageBox.Show(" Creditos usados " + respuesta[3] + " Creditos restantes " + respuesta[4]);
         }
         else
         {
             MessageBox.Show(" Error: " + respuesta[1] + " " + respuesta[2]);
         }
     }
     else
     {
         MessageBox.Show("Es necesario escoger una cuenta primero");
     }
 }
        private void button6_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow.Cells["ClaveCFDI"].Value.ToString() != "")
            {
                DAO.FelWebServiceDAO webservice = new EquimarFac.DAO.FelWebServiceDAO();
                webservice.UUID = dataGridView1.CurrentRow.Cells["ClaveCFDI"].Value.ToString();
                string[]        respuesta    = new string[3];
                DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
                facturasdao1.Nombre      = comboBox2.Text;
                dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    webservice.CuentaFEL   = row.Cells[1].Value.ToString();
                    webservice.emisorRFC   = row.Cells[0].Value.ToString();
                    webservice.PasswordFEL = row.Cells[2].Value.ToString();
                }
                respuesta = webservice.GenerarFacturaBidimensional();

                if (respuesta[0] == "True")
                {
                    Image imagen = Base64ToImage(respuesta[2]);
                    imagen.Save("C:\\Facturas CFDI\\FacturasCBD\\" + dataGridView1.CurrentRow.Cells[2].Value.ToString() + ".png");
                    MessageBox.Show("Guardado correctamente");
                }
                else
                {
                    MessageBox.Show(respuesta[1].ToString());
                }
            }
            else
            {
                MessageBox.Show("Genere el CFDI primero");
            }
        }
示例#4
0
 public string insertafacturaparcial()
 {
     try
     {
         //(this.Fecha, this.ClienteFactura, this.Moneda, this.tipodecambio, this.FechaTipoCambio_datetime, this.metodoDePago, this.Cuenta)
         DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
         facturasdao.Fecha          = Convert.ToDateTime(dateTimePicker4.Value.ToShortDateString());
         facturasdao.ClienteFactura = int.Parse(lbl_idCliente.Text);
         facturasdao.Moneda         = comboBox3.Text;
         if (textBox18.Text != "")
         {
             facturasdao.TipoDeCambio_decimal = decimal.Parse(textBox18.Text);
         }
         else
         {
             facturasdao.TipoDeCambio_decimal = 0;
         }
         facturasdao.FechaTipoCambio_datetime = DateTime.Now.Date;
         facturasdao.metodoDePago             = comboBox1.Text;
         facturasdao.Cuenta = textBox2.Text;
         return(facturasdao.insertaparcialcompra());
     }
     catch
     {
         return("Error, vuelva a intentarlo");
     }
 }
 public void cargacuentas()
 {
     DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
     dataGridView2.DataSource = facturasdao.devuelvedatospac();
     foreach (DataGridViewRow row in dataGridView2.Rows)
     {
         comboBox2.Items.Add(row.Cells[1].Value.ToString());
     }
 }
示例#6
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow.Cells["Folio"].Value.ToString() != "")
            {
                DAO.FelWebServiceDAO webservice = new EquimarFac.DAO.FelWebServiceDAO();
                webservice.UUID = dataGridView1.CurrentRow.Cells["UUID"].Value.ToString();
                string[]        respuesta    = new string[4];
                DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
                facturasdao1.Nombre      = comboBox2.Text;
                dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    webservice.CuentaFEL   = row.Cells[1].Value.ToString();
                    webservice.emisorRFC   = row.Cells[0].Value.ToString();
                    webservice.PasswordFEL = row.Cells[2].Value.ToString();
                }
                respuesta = webservice.obtenerpdf();
                if (respuesta[0] == "True")
                {
                    byte[] bytes = Convert.FromBase64String(respuesta[3]);
                    //Step 2 is saving the byte array to disk:

                    try
                    {
                        System.IO.FileStream stream;
                        if (comboBox4.SelectedIndex == 1)
                        {
                            stream =
                                new FileStream(@"C:\\Facturas CFDI\\FacturasPDFCanceladas\\" + dataGridView1.CurrentRow.Cells[1].Value.ToString() + ".pdf", FileMode.CreateNew);
                        }
                        else
                        {
                            stream =
                                new FileStream(@"C:\\Facturas CFDI\\FacturasPDF\\NC " + dataGridView1.CurrentRow.Cells[1].Value.ToString() + ".pdf", FileMode.CreateNew);
                        }
                        System.IO.BinaryWriter writer =
                            new BinaryWriter(stream);
                        writer.Write(bytes, 0, bytes.Length);
                        writer.Close();
                        MessageBox.Show("Correcto guardado");
                    }
                    catch
                    {
                        MessageBox.Show("Esta nota de credito ya existe o la carpeta de guardado no existe");
                    }
                }
                else
                {
                    MessageBox.Show(respuesta[1]);
                }
            }
            else
            {
                MessageBox.Show("Genere el CFDI primero");
            }
        }
 private void button7_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentRow.Cells[2].Value.ToString() != "")
     {
         try
         {
             DialogResult result = MessageBox.Show("¿De verdad desea cancelar esta factura?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (result == DialogResult.Yes)
             {
                 DAO.FelWebServiceDAO webservice = new EquimarFac.DAO.FelWebServiceDAO();
                 webservice.UUID = dataGridView1.CurrentRow.Cells["ClaveCFDI"].Value.ToString();
                 string[]        respuesta    = new string[3];
                 DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
                 facturasdao1.Nombre      = comboBox2.Text;
                 dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
                 foreach (DataGridViewRow row in dataGridView2.Rows)
                 {
                     webservice.CuentaFEL   = row.Cells[1].Value.ToString();
                     webservice.emisorRFC   = row.Cells[0].Value.ToString();
                     webservice.PasswordFEL = row.Cells[2].Value.ToString();
                 }
                 respuesta = webservice.cancelacdfi();
                 if (((respuesta[0] == "True")) && ((respuesta[2] != null)))
                 {
                     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
                     facturas.IDFactura = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value);
                     facturas.ConceptoT = respuesta[2];
                     string resultado = facturas.cancelafactura();
                     if (resultado != "Correcto")
                     {
                         MessageBox.Show("Error de guardado en la base de datos" + respuesta[1].ToString());
                     }
                     else
                     {
                         MessageBox.Show("Operacion exitosa" + ' ' + respuesta[1].ToString());
                         actualizagrid();
                     }
                 }
                 else
                 {
                     MessageBox.Show("Error " + respuesta[1].ToString());
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error :" + ex);
         }
     }
     else
     {
         MessageBox.Show("Una factura no emitida en CFDI se cancela con el boton de cancelar factura");
     }
 }
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Canceladas")
     {
         DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
         dataGridView1.DataSource = facturas.devuelvefacturascanceladas();
     }
     else
     {
         actualizagrid();
     }
 }
示例#9
0
 public void actualizagrid()
 {
     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
     if (comboBox1.Text == "Canceladas")
     {
         dataGridView1.DataSource = facturas.devuelvecomprascanceladas();
     }
     else
     {
         dataGridView1.DataSource = facturas.devuelvecompras();
     }
 }
示例#10
0
        //private void button9_Click(object sender, EventArgs e)
        //{
        //    DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
        //    facturas.IDFServicios = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
        //    string resultado = facturas.eliminaserviciosfac();
        //    if (resultado != "Correcto")
        //    {
        //        MessageBox.Show(resultado);
        //    }
        //    else
        //    {
        //        actualizagrid();
        //        calculatotales();
        //    }
        //}

        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
                facturasdao.IDFactura = int.Parse(lbl_idfactura.Text);
                facturasdao.Subtotal  = decimal.Parse(textBox13.Text);
                facturasdao.Iva       = decimal.Parse(textBox14.Text);
                facturasdao.Total     = decimal.Parse(textBox15.Text);



                if (textBox16.Text != "")
                {
                    facturasdao.Descuento_decimal = ((decimal.Parse(textBox16.Text) * decimal.Parse("100")) / ((decimal.Parse(textBox16.Text))));
                }
                else
                {
                    // facturasdao.descuento = "";
                    // facturasdao.PorcentajeDescuento_decimal = int.Parse(textBox16.Text);
                }

                facturasdao.motivodescuento = textBox17.Text;

                string resultado = facturasdao.actualizacompratermina();
                if (resultado != "Correcto")
                {
                    MessageBox.Show(resultado);
                }
                else
                {
                    string resultado2 = descargainventarios();
                    if (resultado2 == "Correcto")
                    {
                        MessageBox.Show("Correcto");
                        GUI.CatalogosForms.Compras facturasgui = new Compras();
                        facturasgui.MdiParent = this.MdiParent;
                        facturasgui.Show();

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show(resultado2);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Hubo algun error en la informacion " + ex);
            }
        }
示例#11
0
 public void actualizagrid()
 {
     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
     if (comboBox1.Text == "Canceladas")
     {
         dataGridView1.DataSource = facturas.devuelvefacturascanceladas();
     }
     else
     {
         dataGridView1.DataSource = facturas.devuelvefacturas();
     }
     this.dataGridView1.Sort(dataGridView1.Columns[0], ListSortDirection.Descending);
 }
示例#12
0
 private void button7_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentRow.Cells[1].Value.ToString() != "")
     {
         try
         {
             DialogResult result = MessageBox.Show("¿De verdad desea cancelar esta nota de credito?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (result == DialogResult.Yes)
             {
                 DAO.FelWebServiceDAO webservice = new EquimarFac.DAO.FelWebServiceDAO();
                 webservice.UUID = dataGridView1.CurrentRow.Cells["UUID"].Value.ToString();
                 string[]        respuesta    = new string[3];
                 DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
                 facturasdao1.Nombre      = comboBox2.Text;
                 dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
                 foreach (DataGridViewRow row in dataGridView2.Rows)
                 {
                     webservice.CuentaFEL   = row.Cells[1].Value.ToString();
                     webservice.emisorRFC   = row.Cells[0].Value.ToString();
                     webservice.PasswordFEL = row.Cells[2].Value.ToString();
                 }
                 respuesta = webservice.cancelacdfi();
                 if (respuesta[0] == "True")
                 {
                     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
                     facturas.IDNotaCredito = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value);
                     facturas.ConceptoT     = respuesta[2];
                     string resultado = facturas.cancelanotasdecreditocfdi();
                     if (resultado != "Correcto")
                     {
                         MessageBox.Show("Error :" + resultado[1].ToString());
                     }
                     else
                     {
                         MessageBox.Show("Operacion exitosa" + ' ' +
                                         respuesta[1].ToString());
                         carganotasgrid();
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error " + ex.ToString());
         }
     }
     else
     {
         MessageBox.Show("Para cancelar un CFDI es necesario emitirlo primero");
     }
 }
        private void ReporteFactura_Load(object sender, EventArgs e)
        {
            DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
            facturasdao.IDFactura = factura;

            GUI.CatalogosForms.Plantillas.Factura_rpt report = new EquimarFac.GUI.CatalogosForms.Plantillas.Factura_rpt();


            report.SetDataSource(facturasdao.reportefacturas());
            report.Subreports["ServiciosSubRpt"].SetDataSource(facturasdao.reporteservicios());
            //report.ParameterFields["Desc", "ServiciosSubRPT"].ToString() = "0.0";
            crystalReportViewer1.ReportSource = report;
            crystalReportViewer1.Refresh();
        }
示例#14
0
        private void ReporteNotas_Load(object sender, EventArgs e)
        {
            DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
            facturasdao.IDFactura = idfactura;

            GUI.CatalogosForms.Plantillas.NotaCredito report = new EquimarFac.GUI.CatalogosForms.Plantillas.NotaCredito();


            report.SetDataSource(facturasdao.notacreditoimpresion());
            report.Subreports["NotaDetalleSubRPT"].SetDataSource(facturasdao.notacreditoimpresiondetalle());

            crystalReportViewer1.ReportSource = report;

            crystalReportViewer1.Refresh();
        }
示例#15
0
        private void button8_Click(object sender, EventArgs e)
        {
            DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
            facturas.IDFServicios = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
            string resultado = facturas.eliminaservicioscompra();

            if (resultado != "Correcto")
            {
                MessageBox.Show(resultado);
            }
            else
            {
                actualizagrid();
                calculatotales();
            }
        }
示例#16
0
 private void button7_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox5.Text != "")
         {
             //(this.IDFactura, this.IDFServicios, this.Cantidad, this.Importe)
             DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
             facturasdao.IDFactura    = int.Parse(lbl_idfactura.Text);
             facturasdao.IDFServicios = int.Parse(dataGridView2.CurrentRow.Cells[0].Value.ToString());
             facturasdao.Cantidad     = int.Parse(textBox5.Text);
             facturasdao.Importe      = decimal.Parse(dataGridView2.CurrentRow.Cells[3].Value.ToString());
             string resultado = facturasdao.insertaservicioscompra();
             if (resultado != "Correcto")
             {
                 MessageBox.Show(resultado);
             }
             else
             {
                 actualizagrid();
                 calculatotales();
             }
         }
         else
         {
             DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
             facturasdao.IDFactura    = int.Parse(lbl_idfactura.Text);
             facturasdao.IDFServicios = int.Parse(dataGridView2.CurrentRow.Cells[0].Value.ToString());
             facturasdao.Cantidad     = 1;
             facturasdao.Importe      = decimal.Parse(dataGridView2.CurrentRow.Cells[3].Value.ToString());
             string resultado = facturasdao.insertaservicioscompra();
             if (resultado != "Correcto")
             {
                 MessageBox.Show(resultado);
             }
             else
             {
                 actualizagrid();
                 calculatotales();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#17
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (button1.Text == "Nuevo")
         {
             DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
             facturasdao.Nombre   = textBox1.Text;
             facturasdao.Usuario  = textBox3.Text;
             facturasdao.Cuenta   = textBox2.Text;
             facturasdao.Password = textBox4.Text;
             string resultado = facturasdao.insertadatospac();
             if (resultado == "Correcto")
             {
                 cargacuentas();
                 limpiatextos();
             }
             else
             {
                 MessageBox.Show(resultado);
             }
         }
         else
         {
             DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
             facturasdao.Nombre      = textBox1.Text;
             facturasdao.Usuario     = textBox3.Text;
             facturasdao.Cuenta      = textBox2.Text;
             facturasdao.Password    = textBox4.Text;
             facturasdao.IDCuentaPac = int.Parse(lblid.Text);
             string resultado = facturasdao.modificadatospac();
             if (resultado == "Correcto")
             {
                 cargacuentas();
                 limpiatextos();
             }
             else
             {
                 MessageBox.Show(resultado);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#18
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex == 4)
     {
         DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
         dataGridView1.DataSource = facturas.devuelvenotascanceladas280616();
     }
     if (comboBox1.SelectedIndex == 3)
     {
         DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
         dataGridView1.DataSource = facturas.devuelvefacturascanceladas();
     }
     if ((comboBox1.SelectedIndex != 4) && (comboBox1.SelectedIndex != 3))
     {
         actualizagrid();
     }
 }
示例#19
0
        private void button8_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿De verdad desea enviar esta factura? Se enviara al Email que tiene registrado del cliente", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                if (dataGridView1.CurrentRow.Cells[2].Value.ToString() != "")
                {
                    DAO.FelWebServiceDAO felweb    = new EquimarFac.DAO.FelWebServiceDAO();
                    DAO.CatalogosDAO     catalogos = new EquimarFac.DAO.CatalogosDAO();
                    catalogos.nombre         = dataGridView1.CurrentRow.Cells["Cliente"].Value.ToString();
                    dataGridView2.DataSource = catalogos.devuelveclientepornombre();
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        felweb.Email = row.Cells[18].Value.ToString();
                    }
                    felweb.UUID = dataGridView1.CurrentRow.Cells["ClaveCFDI"].Value.ToString();
                    string[]        resultado    = new string[2];
                    DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
                    facturasdao1.Nombre      = comboBox2.Text;
                    dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        felweb.CuentaFEL   = row.Cells[1].Value.ToString();
                        felweb.emisorRFC   = row.Cells[0].Value.ToString();
                        felweb.PasswordFEL = row.Cells[2].Value.ToString();
                    }
                    resultado = felweb.enviacfdicorreo();
                    if (resultado[0] == "True")
                    {
                        MessageBox.Show("Enviado");
                    }
                    else
                    {
                        MessageBox.Show(resultado[1]);
                    }
                }
                else
                {
                    MessageBox.Show("Genere el CFDI primero");
                }
            }
        }
示例#20
0
 private void button8_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentRow.Cells["Folio"].Value.ToString() != "")
     {
         DAO.FelWebServiceDAO felweb    = new EquimarFac.DAO.FelWebServiceDAO();
         DAO.CatalogosDAO     catalogos = new EquimarFac.DAO.CatalogosDAO();
         catalogos.nombre         = lblcliente.Text;
         dataGridView2.DataSource = catalogos.devuelveclientepornombre();
         foreach (DataGridViewRow row in dataGridView2.Rows)
         {
             felweb.Email = row.Cells[18].Value.ToString();
         }
         felweb.UUID = dataGridView1.CurrentRow.Cells["UUID"].Value.ToString();
         string[]        resultado    = new string[2];
         DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
         facturasdao1.Nombre      = comboBox2.Text;
         dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
         foreach (DataGridViewRow row in dataGridView2.Rows)
         {
             felweb.CuentaFEL   = row.Cells[1].Value.ToString();
             felweb.emisorRFC   = row.Cells[0].Value.ToString();
             felweb.PasswordFEL = row.Cells[2].Value.ToString();
         }
         resultado = felweb.enviacfdicorreo();
         if (resultado[0] == "True")
         {
             MessageBox.Show("Enviado");
         }
         else
         {
             MessageBox.Show(resultado[1]);
         }
     }
     else
     {
         MessageBox.Show("Genere el CFDI primero");
     }
 }
示例#21
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
         facturasdao.IDFactura      = int.Parse(this.Text);
         facturasdao.facturaimpresa = textBox1.Text;
         string resultado = facturasdao.insertanumfacturaimpresa();
         if (resultado != "Correcto")
         {
             MessageBox.Show(resultado);
         }
         else
         {
             this.Close();
             facturasgui.actualizagrid();
         }
     }
     catch
     {
         MessageBox.Show("Algun tipo de error");
     }
 }
示例#22
0
        private void textBox8_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string          campo = comboBox1.Text;
                DataView        dv;
                DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();

                if (campo == "Canceladas")
                {
                    actualizagrid();
                }
                else
                {
                    dv           = new DataView(facturas.devuelvefacturas());
                    dv.RowFilter = campo + " like '%" + textBox8.Text + "%'";

                    dataGridView1.DataSource = dv;
                }
            }
            catch
            {
            }
        }
示例#23
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult result = MessageBox.Show("¿De verdad desea cancelar esta factura?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (result == DialogResult.Yes)
         {
             DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
             facturas.IDFactura = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value);
             string resultado = facturas.cancelafactura();
             if (resultado != "Correcto")
             {
                 MessageBox.Show(resultado);
             }
             else
             {
                 actualizagrid();
             }
         }
     }
     catch
     {
     }
 }
示例#24
0
 public int numerocompras()
 {
     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
     return(facturas.devuelveidcompras());
 }
示例#25
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                calculaprecios();
                if ((richTextBox1.Text != "") && (textBox8.Text != "") && (textBox13.Text != "") && (comboBox3.SelectedIndex != -1) && (comboBox1.SelectedIndex != -1))
                {
                    DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
                    //this.IDFactura, this.NumeroProgresivo, this.Fecha, this.Concepto, this.Subtotal, this.Iva, this.Total, this.ConceptoT);
                    facturasdao.IDFactura = int.Parse(this.Text);
                    //facturasdao.Folio = (textBox8.Text);
                    facturasdao.NumeroProgresivo = 1;
                    facturasdao.Fecha            = DateTime.Now;
                    facturasdao.Concepto         = richTextBox1.Text;
                    facturasdao.Subtotal         = decimal.Parse(textBox13.Text);
                    facturasdao.Iva   = decimal.Parse(textBox14.Text);
                    facturasdao.Total = decimal.Parse(textBox15.Text);
                    //, this.Descuento_decimal, this.MotivoDescuento_string, this.PorcentajeDescuento_decimal, this.Moneda, this.TipoDeCambio_decimal, this.FechaTipoCambio_datetime, this.UUID, this.Folio);
                    if (((checkBox3.Checked) | (checkBox4.Checked)) && textBox2.Text != "")
                    {
                        if (checkBox3.Checked)
                        {
                            //porcentaje
                            facturasdao.Descuento_decimal           = descuentopublic;
                            facturasdao.PorcentajeDescuento_decimal = descuentoporcentajepublic;
                        }

                        if (checkBox4.Checked)
                        {
                            //cantidad
                            facturasdao.Descuento_decimal           = descuentopublic;
                            facturasdao.PorcentajeDescuento_decimal = descuentoporcentajepublic;
                        }
                    }
                    else
                    {
                    }
                    facturasdao.MotivoDescuento_string = textBox3.Text;
                    facturasdao.Moneda = comboBox3.Text;
                    if (textBox4.Text != "")
                    {
                        facturasdao.TipoDeCambio_decimal = decimal.Parse(textBox4.Text);
                    }
                    else
                    {
                    }
                    //facturasdao.TipoDeCambio_decimal = decimal.Parse(textBox4.Text);
                    facturasdao.FechaTipoCambio_datetime = (dateTimePicker5.Value);
                    facturasdao.UUID  = "";
                    facturasdao.Folio = "";
                    Numalet let = new Numalet();
                    if (comboBox3.Text == "USD")
                    {
                        let.MascaraSalidaDecimal   = "00'/100 U.S.D'";
                        let.SeparadorDecimalSalida = "Dolares";
                        //observar que sin esta propiedad queda "veintiuno pesos" en vez de "veintiún pesos":
                        let.ApocoparUnoParteEntera = true;

                        facturasdao.ConceptoT = ("Son: " + let.ToCustomCardinal(textBox15.Text));
                        //Son: un mil ciento veintiún pesos 24/100 M.N.
                    }
                    else
                    {
                        let.MascaraSalidaDecimal   = "00'/100 M.N'";
                        let.SeparadorDecimalSalida = "Pesos";
                        //observar que sin esta propiedad queda "veintiuno pesos" en vez de "veintiún pesos":
                        let.ApocoparUnoParteEntera = true;

                        facturasdao.ConceptoT = ("Son: " + let.ToCustomCardinal(textBox15.Text));
                        //Son: un mil ciento veintiún pesos 24/100 M.N.
                    }
                    string resultado = facturasdao.actualiza_notacredito();
                    if (resultado != "Correcto")
                    {
                        MessageBox.Show(resultado);
                    }
                    else
                    {
                        //facturasgui.actualizagrid();
                        //this.Close();
                        carganotasgrid();
                    }
                }
                else
                {
                    MessageBox.Show("Verifique su informacion por datos faltantes");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#26
0
        private void button5_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿De verdad desea emitir esta factura?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                if (comboBox2.SelectedIndex != -1)
                {
                    if (dataGridView1.CurrentRow.Cells[2].Value.ToString() == "")
                    {
                        DAO.FelWebServiceDAO felweb = new EquimarFac.DAO.FelWebServiceDAO();
                        cargacliente();
                        foreach (DataGridViewRow row in dataGridView2.Rows)
                        {
                            felweb.NombreCliente        = row.Cells[1].Value.ToString();
                            felweb.Contacto             = row.Cells[6].Value.ToString();
                            felweb.Telefono             = row.Cells[4].Value.ToString();
                            felweb.Email                = row.Cells[18].Value.ToString();
                            felweb.rfcReceptor          = row.Cells[5].Value.ToString();
                            felweb.nombreReceptor       = row.Cells[8].Value.ToString();
                            felweb.calleReceptor        = row.Cells[10].Value.ToString();
                            felweb.noExteriorReceptor   = row.Cells[11].Value.ToString();
                            felweb.noInteriorReceptor   = row.Cells[12].Value.ToString();
                            felweb.coloniaReceptor      = row.Cells[13].Value.ToString();
                            felweb.localidadReceptor    = row.Cells[14].Value.ToString();
                            felweb.referenciaReceptor   = row.Cells[15].Value.ToString();
                            felweb.municipioReceptor    = row.Cells[3].Value.ToString();
                            felweb.estadoReceptor       = row.Cells[16].Value.ToString();
                            felweb.paisReceptor         = row.Cells[17].Value.ToString();
                            felweb.codigoPostalReceptor = row.Cells[19].Value.ToString();
                        }
                        DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
                        facturasdao1.Nombre      = comboBox2.Text;
                        dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
                        foreach (DataGridViewRow row in dataGridView2.Rows)
                        {
                            felweb.CuentaFEL   = row.Cells[1].Value.ToString();
                            felweb.emisorRFC   = row.Cells[0].Value.ToString();
                            felweb.PasswordFEL = row.Cells[2].Value.ToString();
                        }


                        felweb.ClaveCFDI = "FAC";


                        felweb.formaDePago       = "Pago en una sola exhibición";
                        felweb.parcialidades     = "";
                        felweb.condicionesDePago = "";
                        felweb.metodoDePago      = dataGridView1.CurrentRow.Cells["metodoDePago"].Value.ToString();
                        string descuentostring;
                        string porcentajedescuentostring;
                        if (dataGridView1.CurrentRow.Cells["descuento"].Value.ToString() == "")
                        {
                            decimal descuento = 0, porcentajedescuento = 0;
                            descuentostring           = descuento.ToString("N6");
                            porcentajedescuentostring = porcentajedescuento.ToString("N6");
                        }
                        else
                        {
                            decimal descuento           = decimal.Parse(dataGridView1.CurrentRow.Cells["descuento"].Value.ToString()),
                                    porcentajedescuento = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["porcentajeDescuento"].Value);
                            descuentostring           = descuento.ToString("N4");
                            porcentajedescuentostring = porcentajedescuento.ToString("N4");
                        }

                        decimal iva = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["Iva"].Value),
                                total = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["Total"].Value), subtotal;
                        if (dataGridView1.CurrentRow.Cells["Descuento"].Value.ToString() != "")
                        {
                            subtotal = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["Subtotal"].Value) + Convert.ToDecimal(dataGridView1.CurrentRow.Cells["Descuento"].Value);
                        }
                        else
                        {
                            subtotal = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["Subtotal"].Value);
                        }
                        decimal tipodecambio;
                        string  tipodecambiostring;
                        if (dataGridView1.CurrentRow.Cells["tipodecambio"].Value.ToString() == "")
                        {
                            tipodecambiostring = "";
                        }
                        else
                        {
                            tipodecambio       = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["tipodecambio"].Value);
                            tipodecambiostring = tipodecambio.ToString();
                        }


                        string ivastring      = iva.ToString("N4");
                        string totalstring    = total.ToString("N4");
                        string subtotalstring = subtotal.ToString("N4");


                        felweb.descuento           = descuentostring;
                        felweb.porcentajeDescuento = porcentajedescuentostring;
                        felweb.motivoDescuento     = dataGridView1.CurrentRow.Cells["motivodescuento"].Value.ToString();
                        felweb.moneda     = dataGridView1.CurrentRow.Cells["Moneda"].Value.ToString();
                        felweb.tipoCambio = tipodecambiostring;
                        if (tipodecambiostring == "")
                        {
                            felweb.fechaTipoCambio = "";
                        }
                        else
                        {
                            felweb.fechaTipoCambio = dataGridView1.CurrentRow.Cells["fechatipodecambio"].Value.ToString();
                        }
                        felweb.totalImpuestosRetenidos   = "0.000000";
                        felweb.totalImpuestosTrasladados = ivastring;
                        felweb.subTotal = subtotalstring;
                        felweb.total    = totalstring;
                        //felweb.importeConLetra = dataGridView1.CurrentRow.Cells["ConceptoT"].Value.ToString();
                        felweb.LugarExpedicion = dataGridView1.CurrentRow.Cells["LugarExpedicion"].Value.ToString();
                        //felweb.NumCuentaPago = "";
                        felweb.FolioFiscalOrig      = "";
                        felweb.SerieFolioFiscalOrig = "";
                        felweb.FechaFolioFiscalOrig = "";
                        felweb.MontoFolioFiscalOrig = "";

                        //Datos Varios
                        felweb.datosEtiquetas1 = "|B/R|" + dataGridView1.CurrentRow.Cells["Remolcadores"].Value.ToString() + "|";
                        cargafacturadetalle();
                        if (dataGridView1.CurrentRow.Cells["Agencia"].Value.ToString() == "")
                        {
                            felweb.datosEtiquetas2 = "|Viaje|" + dataGridView2.Rows[0].Cells["Viaje"].Value.ToString() + "|";
                            if (dataGridView1.CurrentRow.Cells["NumCuenta"].Value.ToString() == "")
                            {
                                felweb.NumCuentaPago = "";
                                cargacliente();
                                foreach (DataGridViewRow row in dataGridView2.Rows)
                                {
                                    if ((row.Cells[16].Value.ToString() == "Estado Extranjero") && (row.Cells[17].Value.ToString() == "País Extranjero"))
                                    {
                                        felweb.datosEtiquetas3 = "|País|" + row.Cells["PaisExtranjero"].Value.ToString() + "|";
                                        felweb.datosEtiquetas4 = "|Estado|" + row.Cells["EstadoExtranjero"].Value.ToString() + "|";
                                    }
                                }
                            }
                            else
                            {
                                felweb.NumCuentaPago = dataGridView1.CurrentRow.Cells["NumCuenta"].Value.ToString();
                                //felweb.datosEtiquetas3 = "|NumCuenta|" + dataGridView1.CurrentRow.Cells["NumCuenta"].Value.ToString() + "|";
                                cargacliente();
                                foreach (DataGridViewRow row in dataGridView2.Rows)
                                {
                                    if ((row.Cells[16].Value.ToString() == "Estado Extranjero") && (row.Cells[17].Value.ToString() == "País Extranjero"))
                                    {
                                        felweb.datosEtiquetas3 = "|País|" + row.Cells["PaisExtranjero"].Value.ToString() + "|";
                                        felweb.datosEtiquetas4 = "|Estado|" + row.Cells["EstadoExtranjero"].Value.ToString() + "|";
                                    }
                                }
                            }
                        }
                        else
                        {
                            felweb.datosEtiquetas2 = "|Agencia|" + dataGridView1.CurrentRow.Cells["Agencia"].Value.ToString() + "|";
                            felweb.datosEtiquetas3 = "|Viaje|" + dataGridView2.Rows[0].Cells["Viaje"].Value.ToString() + "|";

                            if (dataGridView1.CurrentRow.Cells["NumCuenta"].Value.ToString() == "")
                            {
                                felweb.NumCuentaPago = "";
                                cargacliente();
                                foreach (DataGridViewRow row in dataGridView2.Rows)
                                {
                                    if ((row.Cells[16].Value.ToString() == "Estado Extranjero") && (row.Cells[17].Value.ToString() == "País Extranjero"))
                                    {
                                        felweb.datosEtiquetas4 = "|País|" + row.Cells["PaisExtranjero"].Value.ToString() + "|";
                                        felweb.datosEtiquetas5 = "|Estado|" + row.Cells["EstadoExtranjero"].Value.ToString() + "|";
                                    }
                                }
                            }
                            else
                            {
                                felweb.NumCuentaPago = dataGridView1.CurrentRow.Cells["NumCuenta"].Value.ToString();
                                //felweb.datosEtiquetas4 = "|NumCuenta|" + dataGridView1.CurrentRow.Cells["NumCuenta"].Value.ToString() + "|";
                                cargacliente();
                                foreach (DataGridViewRow row in dataGridView2.Rows)
                                {
                                    if ((row.Cells[16].Value.ToString() == "Estado Extranjero") && (row.Cells[17].Value.ToString() == "País Extranjero"))
                                    {
                                        felweb.datosEtiquetas4 = "|País|" + row.Cells["PaisExtranjero"].Value.ToString() + "|";
                                        felweb.datosEtiquetas5 = "|Estado|" + row.Cells["EstadoExtranjero"].Value.ToString() + "|";
                                    }
                                }
                            }
                        }


                        felweb.importeConLetra = dataGridView1.CurrentRow.Cells["TotalLetras"].Value.ToString();
                        List <string> datosConceptos = new List <string>(), datosInfoAduanera = new List <string>();
                        cargaconceptos();
                        foreach (DataGridViewRow row in dataGridView2.Rows)
                        {
                            //El esquema, para incluir los conceptos sera el siguiente: | Cantidad | Unidad | noIdentificacion | Descripcion | valorUnitario | Importe |
                            //Haciendo uso del caracter "|" pipe, para separar cada uno de los valores correspondientes. Ejemplo: |1|mtro.||alambre 1/2 pulgada|1.0|1.0|
                            //|cantidad|unidad|noIdentificacion|descripcion|valorUnitario|importe|
                            datosConceptos.Add("|1|1||" + row.Cells[1].Value.ToString() + " B/M: " + row.Cells[2].Value.ToString() + " TRB: " + row.Cells[3].Value.ToString() + " Muelle: " + row.Cells[4].Value.ToString() + " FECHA DE MOVIMIENTO: " + row.Cells[5].Value.ToString() + " HORARIO: " + row.Cells[6].Value.ToString() + " TIEMPO TRANSCURRIDO: " + row.Cells[7].Value.ToString() + "|" + (decimal.Parse(row.Cells[8].Value.ToString()) + decimal.Parse(row.Cells[9].Value.ToString())).ToString() + "|" + row.Cells[8].Value.ToString() + "|");
                            datosInfoAduanera.Add("");
                        }
                        felweb.conceptos    = datosConceptos;
                        felweb.infoaduanera = datosInfoAduanera;
                        //felweb.datosConceptos = dataGridView1.CurrentRow.Cells["Cliente"].Value.ToString();
                        //felweb.datosInfoAduanera = dataGridView1.CurrentRow.Cells["Cliente"].Value.ToString();
                        felweb.datosRetenidosIVA      = "";
                        felweb.datosRetenidosISR      = "";
                        felweb.datosTraslados1        = "|IVA (IVA 16.00%)|IVA|16.00|" + dataGridView1.CurrentRow.Cells["Iva"].Value.ToString() + "|";
                        felweb.datosRetenidosLocales1 = "";
                        felweb.datosRetenidosLocales2 = "";
                        felweb.datosTrasladosLocales1 = "";
                        string[] respuesta = new string[5];


                        respuesta = felweb.GenerarCDFI();
                        if (respuesta[0] == "True")
                        {
                            XmlDocument xmldoc     = new XmlDocument();
                            string      resultado1 = respuesta[3].ToString();
                            //XmlWriterSettings settings;

                            ////settings = new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8, CheckCharacters = false };

                            //XmlReader reader = XmlReader.Create(resultado1, settings.Encoding.EncodingName = UTF8Encoding);
                            XmlReaderSettings rs = new XmlReaderSettings();
                            rs.CheckCharacters = false;

                            //// XmlXapResolver is the default resolver.
                            //using (XmlReader reader = XmlReader.Create(resultado1, rs))
                            //{
                            //    xmldoc.in
                            //    xmldoc.Load(reader);
                            //}

                            xmldoc.LoadXml(resultado1);

                            //xmldoc.Save("C:\\Facturas CFDI\\FacturasXML\\FacturasMiXML_Timbrado.xml");
                            DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
                            facturasdao.IDFactura = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value);
                            //// Move to an element.
                            //XmlElement root = doc.DocumentElement;

                            //// Get an attribute.
                            //XmlAttribute attr = root.GetAttributeNode("ISBN");

                            //// Display the value of the attribute.
                            //String attrValue = attr.InnerXml;
                            //Console.WriteLine(attrValue);
                            XmlElement elementoxml = xmldoc.DocumentElement;
                            string     lstVideos   = elementoxml.ChildNodes.Count.ToString();
                            //XmlAttribute atributeelement = elementoxml.get
                            string      atributouuid = lstVideos;
                            XmlNodeList nodelist     = elementoxml.ChildNodes;
                            XmlNodeList nodelist2    = nodelist.Item(4).ChildNodes;
                            // XmlNodeList nodelist3 = nodelist2.Item(0).ChildNodes;
                            XmlAttributeCollection elemento2 = nodelist2.Item(0).Attributes;
                            //XmlAttribute atrib = elemento2.GetNamedItem("UUID");
                            string nodotexto = elemento2.GetNamedItem("UUID").InnerText;

                            XmlAttributeCollection elemento3 = elementoxml.Attributes;
                            string nodotexto2 = elemento3.GetNamedItem("folio").InnerText;
                            facturasdao.facturaimpresa = nodotexto2;
                            xmldoc.Save("C:\\Facturas CFDI\\FacturasXML\\" + nodotexto2 + ".xml");
                            Image imagen = Base64ToImage(respuesta[4]);
                            imagen.Save("C:\\Facturas CFDI\\FacturasCBD\\" + nodotexto2 + ".png");
                            facturasdao.ClaveCFDI = nodotexto;

                            string resultado = facturasdao.insertanumfacturaimpresa();
                            MessageBox.Show("Correcto");
                            actualizagrid();
                        }
                        else
                        {
                            MessageBox.Show("Error de generacion del CFDI " + respuesta[1] + " " + respuesta[2]);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Para volver a emitir una factura es necesario volver a crearla");
                    }
                }
                else
                {
                    MessageBox.Show("Es necesario elegir una cuenta");
                }
            }
        }
示例#27
0
 public void cargafacturadetalle()
 {
     DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
     facturasdao.IDFactura    = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
     dataGridView2.DataSource = facturasdao.reportefacturas();
 }
示例#28
0
 public void cargacuentas()
 {
     DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
     dataGridView1.DataSource = facturasdao.devuelvedatospac();
 }
示例#29
0
 public void cargaconceptos()
 {
     DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
     facturasdao.IDFactura    = int.Parse(dataGridView1.CurrentRow.Cells["ID"].Value.ToString());
     dataGridView2.DataSource = facturasdao.devuelveserviciosf();
 }
示例#30
0
 public void actualizagrid()
 {
     DAO.FacturasDAO facturasdao = new EquimarFac.DAO.FacturasDAO();
     facturasdao.IDFactura    = int.Parse(lbl_idfactura.Text);
     dataGridView1.DataSource = facturasdao.devuelveserviciosf();
 }