Example #1
0
 private void menuItem5_Click(object sender, EventArgs e)
 {
     Plantilla plantilla = new Plantilla(eFact_I_Bj.RN.Plantilla.Modo.Modificacion);
     plantilla.ShowDialog();
     plantilla = null;
 }
Example #2
0
        private void GenerarArchivoButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (ConsultaComprobantesDataGridView.SelectedRows.Count != 0)
                {
                    int renglon = ConsultaComprobantesDataGridView.SelectedRows[0].Index;
                    try
                    {
                        eFact_I_Bj.Entidades.Plantilla plantillaExpuesta = new eFact_I_Bj.Entidades.Plantilla();
                        Plantilla plantilla = new Plantilla(eFact_I_Bj.RN.Plantilla.Modo.Consulta, plantillaExpuesta);
                        plantilla.ShowDialog();
                        plantillaExpuesta = plantilla.plantillaExpuesta;
                        plantilla = null;
                        string observaciones = string.Empty;
                        if (plantillaExpuesta != null)
                        {
                            //foreach (eFact_I_Bj.Entidades.ComprobanteBj comprobante in Comprobantes)
                            //{
                                //if (Comprobantes[renglon].Leyendas[0].ToString() != string.Empty)
                                //{
                                //    string leyenda = Comprobantes[renglon].Leyendas[0].ToString();
                                //    observaciones = observaciones + plantillaExpuesta.Leyenda1 + " " + leyenda + " ";
                                //}
                                if (Comprobantes[renglon].Leyendas[1].ToString() != string.Empty)
                                {
                                    string leyenda = Comprobantes[renglon].Leyendas[1].ToString();
                                    observaciones = observaciones + plantillaExpuesta.Leyenda2 + " " + leyenda + " ";
                                }
                                if (Comprobantes[renglon].Leyendas[2].ToString() != string.Empty)
                                {
                                    string leyenda = Comprobantes[renglon].Leyendas[2].ToString();
                                    observaciones = observaciones + plantillaExpuesta.Leyenda3 + " " + leyenda + " ";
                                }
                                if (Comprobantes[renglon].Leyendas[3].ToString() != string.Empty)
                                {
                                    string leyenda = Comprobantes[renglon].Leyendas[3].ToString();
                                    observaciones = observaciones + plantillaExpuesta.Leyenda4 + " " + leyenda + " ";
                                }
                                if (Comprobantes[renglon].Leyendas[4].ToString() != string.Empty)
                                {
                                    string leyenda = Comprobantes[renglon].Leyendas[4].ToString();
                                    observaciones = observaciones + plantillaExpuesta.Leyenda5 + " " + leyenda + " ";
                                }
                                observaciones = observaciones + plantillaExpuesta.LeyendaMoneda + " " + " ";
                                Lc.comprobante[renglon].extensiones = new FeaEntidades.InterFacturas.extensiones();
                                Lc.comprobante[renglon].extensiones.extensiones_datos_comerciales = observaciones;
                                Lc.comprobante[renglon].extensionesSpecified = true;
                                Lc.comprobante[renglon].resumen.observaciones = plantillaExpuesta.LeyendaBanco;
                            //}
                        }
						if (FactServiciosCheckBox.Checked)
						{
							Lc.comprobante[renglon].cabecera.informacion_comprobante.fecha_serv_desde = FechaDsdServ.Value.ToString("yyyyMMdd");
							Lc.comprobante[renglon].cabecera.informacion_comprobante.fecha_serv_hasta = FechaHstServ.Value.ToString("yyyyMMdd");
							Lc.comprobante[renglon].cabecera.informacion_comprobante.codigo_conceptoSpecified = true;
							Lc.comprobante[renglon].cabecera.informacion_comprobante.codigo_concepto = 2;
						}
						if (FactDolarCheckBox.Checked)
						{
							string comentario = "Este documento se emite por el importe equivalente a USD "+ ImporteDolaresTextBox.Text +" al TC "+ TipoCambioTextBox.Text +" ARS/USD. De existir diferencia entre este tipo de cambio y el que corresponda al día anterior al pago efectivo, el pago se considerara hecho a cuenta y la diferencia generada deberá ser compensada mediante una ND/NC según corresponda a ser emitida por Gas Patagonia S.A.";
							Lc.comprobante[renglon].detalle.comentarios = comentario;
						}
                        
                        //Crear "lote_comprobantes"
                        string LoteXML;
                        //Metodo estático para el armado del Lote en formato XML, no necesita usar el constructor con la URL, proxy y certificados.
                        //Para Contingencias: El string LoteXML deberá guardarse en un archivo para se subido al Sitio Web de Interfacturas.
                        FeaEntidades.InterFacturas.lote_comprobantes lcComprobanteSelec = new FeaEntidades.InterFacturas.lote_comprobantes();
						lcComprobanteSelec.cabecera_lote = Lc.cabecera_lote;
						lcComprobanteSelec.cabecera_lote.cantidad_reg = 1;
                        lcComprobanteSelec.comprobante[0] = Lc.comprobante[renglon];
						if (plantillaExpuesta.DescrPlantilla.Equals("Diferencia de Cambio"))
						{
							for (int i = 1; i < lcComprobanteSelec.comprobante[0].detalle.linea.Length; i++)
							{
								if (lcComprobanteSelec.comprobante[0].detalle.linea[i] != null)
								{
									lcComprobanteSelec.comprobante[0].detalle.linea[i] = null;
								}
							}
							lcComprobanteSelec.comprobante[0].detalle.linea[0].cantidadSpecified = false;
							lcComprobanteSelec.comprobante[0].detalle.linea[0].precio_unitarioSpecified = false;
							lcComprobanteSelec.comprobante[0].detalle.linea[0].importe_ivaSpecified = false;
							lcComprobanteSelec.comprobante[0].detalle.linea[0].alicuota_ivaSpecified = false;
							lcComprobanteSelec.comprobante[0].detalle.linea[0].descripcion = string.Empty;
							if (lcComprobanteSelec.comprobante[0].resumen.codigo_moneda == "DOL")
							{
								lcComprobanteSelec.comprobante[0].detalle.linea[0].importe_total_articulo = lcComprobanteSelec.comprobante[0].resumen.importes_moneda_origen.importe_total_neto_gravado;
							}
							else
							{
								lcComprobanteSelec.comprobante[0].detalle.linea[0].importe_total_articulo = lcComprobanteSelec.comprobante[0].resumen.importe_total_neto_gravado;
							}

						}
						if (lcComprobanteSelec.comprobante[0].resumen.codigo_moneda == "DOL")
						{
							lcComprobanteSelec.comprobante[0].resumen.cant_alicuotas_ivaSpecified = false;
							lcComprobanteSelec.comprobante[0].resumen.importe_total_factura = 0;
							lcComprobanteSelec.comprobante[0].resumen.impuesto_liq = 0;
							lcComprobanteSelec.comprobante[0].resumen.importe_total_neto_gravado = 0;
							lcComprobanteSelec.comprobante[0].resumen.importe_total_concepto_no_gravado = 0;
							lcComprobanteSelec.comprobante[0].resumen.impuesto_liq_rni = 0;
							lcComprobanteSelec.comprobante[0].resumen.importe_operaciones_exentas = 0;

						}
						lcComprobanteSelec.cabecera_lote.id_lote = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmss"));
						lcComprobanteSelec.cabecera_lote.fecha_envio_lote = DateTime.Now.ToString("yyyyMMdd") + " " + DateTime.Now.ToString("HHmmss");
                        LoteXML = ArmarLoteXML(lcComprobanteSelec);
                        //Definir ruta y nombre del archivo.
						string archPath = System.Configuration.ConfigurationManager.AppSettings["ArchPath"];
                        FileStream fs = File.Create(@archPath + "\\efact-c-contingencia.xml");
                        System.Text.Encoding codificador;
                        codificador = System.Text.Encoding.GetEncoding("iso-8859-1");
                        fs.Write(codificador.GetBytes(LoteXML), 0, LoteXML.Length);
                        fs.Close();
                        MessageBox.Show("Lote XML generado satisfactoriamente", "NOTIFICACION", MessageBoxButtons.OK);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "NOTIFICACION", MessageBoxButtons.OK);
                        //Guardar el ex.InnerException si tiene contenido para tener mas detalle del problema.
                    }
                    //Actualizar lote
                    //ms = new MemoryStream();
                    //XmlizedString = null;
                    //writer = new XmlTextWriter(ms, System.Text.Encoding.GetEncoding("ISO-8859-1"));
                    //x = new System.Xml.Serialization.XmlSerializer(Lc.GetType());
                    //x.Serialize(writer, Lc);
                    //ms = (MemoryStream)writer.BaseStream;
                    //XmlizedString = RN.Tablero.ByteArrayToString(ms.ToArray());
                    //ms.Close();
                    //Lote.LoteXmlIF = XmlizedString;
                }
            }
            catch (Exception ex)
            {
                Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
            }
        }