public IEnumerator ShowErrorMessage(Text _message) { StartCoroutine(TextFunctions.FadeTextToFullAlpha(1, _message)); yield return(new WaitForSecondsRealtime(3.0f)); StartCoroutine(TextFunctions.FadeTextToZeroAlpha(1, _message)); yield return(0); }
//------- protected string getWrappedMessage(object obj) { string inText = obj.ToString(); string outText = TextFunctions.FormatFreeText(inText, 25); outText = TextFunctions.FormatLineBreaks(outText); return(outText); }
private void BtnImprimirComprobante_Click(object sender, EventArgs e) { try { if (TdgProductosFormulados.RowCount > 0) { Int32 TipoComprobanteID = Convert.ToInt32(this.TdgProductosFormulados.Columns["TipoComprobanteID"].Value); string NumComprobante = this.TdgProductosFormulados.Columns["NumComprobante"].Value.ToString(); string EstadoEnvio = this.TdgProductosFormulados.Columns["EstadoEnvio"].Value.ToString(); string Comprobante = this.TdgProductosFormulados.Columns["Comprobante"].Value.ToString(); string TipoComprobante = this.TdgProductosFormulados.Columns["TipoComprobante"].Value.ToString(); if (MessageBox.Show("¿Seguro que desea generar el pdf del comprobante " + TipoComprobante + " N° " + Comprobante + "?", "Aviso", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { string filepath = fbd.SelectedPath + "\\" + Comprobante; DataSet DS = objCL_Comprobante.GetComprobanteFE(TipoComprobanteID, NumComprobante, c1cboCia.SelectedValue.ToString(), null, ""); CrFE rpt = new CrFE(); DS.Tables[0].TableName = "Cabecera"; DS.Tables[1].TableName = "Detalle"; rpt.SetDataSource(DS); TextFunctions ObjTextFunctions = new TextFunctions(); string TotalPagarLetras = ObjTextFunctions.enletras((DS.Tables[0].Rows[0]["ImporteTotal"]).ToString()); TextObject TxtMontoLetras; TxtMontoLetras = (TextObject)rpt.ReportDefinition.ReportObjects["TxtMontoLetras"]; TxtMontoLetras.Text = TotalPagarLetras + " Soles."; TextObject TxtRespuestaSunat; TxtRespuestaSunat = (TextObject)rpt.ReportDefinition.ReportObjects["TxtRespuestaSunat"]; TxtRespuestaSunat.Text = EstadoEnvio; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, filepath + ".pdf"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected string formatNote(object obj) { string result = "..."; if (obj != null) { result = obj.ToString(); result = TextFunctions.FormatFreeText(result, 50); result = TextFunctions.FormatLineBreaks(result); } return(result); }
public static int MinuteGap(string tCreatedAt, DateTime datetimeUTC) { try { DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); DateTime createdAtDate = unixEpoch.AddMilliseconds(Convert.ToDouble(TextFunctions.Strip(tCreatedAt))); return((int)(datetimeUTC - createdAtDate).TotalMinutes); } catch (Exception e) { return(int.MinValue); } }
//checks inputs and replaces items that exist in the list public string[] CheckInput(string unixTime, string userId, string messageContent) { var checkedMessageContent = messageContent; foreach (var blackItem in blacklistedValues) { if (checkedMessageContent.Contains(blackItem)) { checkedMessageContent = TextFunctions.ReplaceWords(checkedMessageContent, blackItem, replacementMessage); } } return(new string[] { unixTime, userId, checkedMessageContent }); }
public static string generateProfile(string id, string name, string alias, string url, string thumbnail, bool isVerified) { jProfile obj = new jProfile() { Id = id, Name = name, Alias = alias, Url = TextFunctions.StripChar(url), Thumbnail = new jProfile_Thumbnail() { Url = TextFunctions.StripChar(thumbnail) }, IsVerified = isVerified }; return(JsonConvert.SerializeObject(obj)); }
public static string getPrintableDate(string text) { String ddate; DateTime dateObject; String currentdate = ""; String currenthour = ""; String currentminute = ""; try { ddate = TextFunctions.DateFormatUtc(TextFunctions.Strip(text), "0", 0.0); dateObject = DateTime.Parse(ddate); currentdate = dateObject.Date.ToString("yyyy-MM-dd"); currenthour = dateObject.ToString("HH"); currentminute = dateObject.ToString("mm"); } catch (Exception e) { // continue; } return(currentdate + " " + currenthour + ":" + currentminute); }
private void TxtEntrega12_KeyPress(object sender, KeyPressEventArgs e) { TextFunctions ObjTextFunctions = new TextFunctions(); ObjTextFunctions.ValidaNumero(sender, e, TxtEntrega12); }
private void TxtRUC_KeyPress(object sender, KeyPressEventArgs e) { TextFunctions ObjTextFunctions = new TextFunctions(); ObjTextFunctions.SoloNumero(sender, e, TxtRUC); }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //formato para alinear los nuimeros a la derecha StringFormat formato = new StringFormat(); formato.Alignment = StringAlignment.Far; //formato.LineAlignment = StringAlignment.Far; //obtener la cadena del total a pagar string TotalPagarLetras = new TextFunctions().enletras(Total.ToString()); //validar boleta o factura #region Boleta if (Convert.ToInt16(CboTipoComprobante.SelectedValue) == 1)//es boleta { int sum = 0; sum += 12; e.Graphics.DrawString(lblCliente.Text, txtNumPedido.Font, Brushes.Black, 70 + AppSettings.BoletaEjeX, 156 + AppSettings.BoletaEjeY); //cliente if (lblDireccion.Text.Length >= 30) { e.Graphics.DrawString(lblDireccion.Text.Substring(0, 29), txtNumPedido.Font, Brushes.Black, 80 + AppSettings.BoletaEjeX, 186 + AppSettings.BoletaEjeY); //direccion larga } else { e.Graphics.DrawString(lblDireccion.Text, txtNumPedido.Font, Brushes.Black, 80 + AppSettings.BoletaEjeX, 186 + AppSettings.BoletaEjeY); //direccion corta } //e.Graphics.DrawString(null, txtNumPedido.Font, Brushes.Black, 40 + AppSettings.BoletaEjeX, 166 + AppSettings.BoletaEjeY); //canasta e.Graphics.DrawString(lblDocumento.Text, txtNumPedido.Font, Brushes.Black, 326 + AppSettings.BoletaEjeX, 186 + AppSettings.BoletaEjeY); //ruc o DNI e.Graphics.DrawString(DateTime.Now.Date.ToString().Substring(0, 10), txtNumPedido.Font, Brushes.Black, 240 + AppSettings.BoletaEjeX, 136 + AppSettings.BoletaEjeY); //dia e.Graphics.DrawString(NumComprobante.Substring(2), txtNumPedido.Font, Brushes.Black, 260 + AppSettings.BoletaEjeX, 117 + AppSettings.BoletaEjeY); //numero de comprobante int Suma = 238; foreach (DataRow Dr in dsPedido.Tables["detallePedido"].Rows) { e.Graphics.DrawString(Convert.ToDecimal(Dr["Cantidad"]).ToString("#,##0.00") + " " + "KG", txtNumPedido.Font, Brushes.Black, 65 + AppSettings.BoletaEjeX, Suma + AppSettings.BoletaEjeY, formato); //cantidad + UM e.Graphics.DrawString(Dr["NomProducto"].ToString(), txtNumPedido.Font, Brushes.Black, 75 + AppSettings.BoletaEjeX, Suma + AppSettings.BoletaEjeY); //descripcion o producto e.Graphics.DrawString(Convert.ToDecimal(Dr["PrecioUnitario"]).ToString("#,##0.00"), txtNumPedido.Font, Brushes.Black, 320 + AppSettings.BoletaEjeX, Suma + AppSettings.BoletaEjeY, formato); //precio unitario e.Graphics.DrawString(Convert.ToDecimal(Dr["Importe"]).ToString("#,##0.00"), txtNumPedido.Font, Brushes.Black, 380 + AppSettings.BoletaEjeX, Suma + AppSettings.BoletaEjeY, formato); //valor de venta Suma += 14; } e.Graphics.DrawString(lblTotPagar.Text, txtNumPedido.Font, Brushes.Black, 370 + AppSettings.BoletaEjeX, 450 + AppSettings.BoletaEjeY, formato); //total e.Graphics.DrawString(TotalPagarLetras, txtNumPedido.Font, Brushes.Black, 45 + AppSettings.BoletaEjeX, 424 + AppSettings.BoletaEjeY); //tatal pagar en letras } #endregion #region Factura else if (Convert.ToInt16(CboTipoComprobante.SelectedValue) == 2)//es factura { int sum = 0; sum += 12; e.Graphics.DrawString(lblCliente.Text, txtNumPedido.Font, Brushes.Black, 90 + AppSettings.FacturaEjeX, 117 + AppSettings.FacturaEjeY); //cliente //e.Graphics.DrawString(useCliente2.txtDireccion.Text, TxtPrecio.Font, Brushes.Black, 90 + AppSettings.FacturaEjeX, 157 + AppSettings.FacturaEjeY); //direccion if (lblDireccion.Text.Length >= 95) { e.Graphics.DrawString(lblDireccion.Text.Substring(0, 94), txtNumPedido.Font, Brushes.Black, 90 + AppSettings.FacturaEjeX, 157 + AppSettings.FacturaEjeY); //direccion } else { e.Graphics.DrawString(lblDireccion.Text, txtNumPedido.Font, Brushes.Black, 90 + AppSettings.FacturaEjeX, 157 + AppSettings.FacturaEjeY); //direccion } e.Graphics.DrawString(lblDocumento.Text, txtNumPedido.Font, Brushes.Black, 90 + AppSettings.FacturaEjeX, 182 + AppSettings.FacturaEjeY); //ruc o DNI e.Graphics.DrawString(DateTime.Now.Day.ToString(), txtNumPedido.Font, Brushes.Black, 570 + AppSettings.FacturaEjeX, 182 + AppSettings.FacturaEjeY); //dia e.Graphics.DrawString(DateTime.Now.ToString("MMMM"), txtNumPedido.Font, Brushes.Black, 650 + AppSettings.FacturaEjeX, 182 + AppSettings.FacturaEjeY); //mes e.Graphics.DrawString(DateTime.Now.Year.ToString().Substring(2), txtNumPedido.Font, Brushes.Black, 805 + AppSettings.FacturaEjeX, 182 + AppSettings.FacturaEjeY); //año e.Graphics.DrawString(NumComprobante.Substring(2), txtNumPedido.Font, Brushes.Black, 690 + AppSettings.FacturaEjeX, 147 + AppSettings.FacturaEjeY); //numero de comprobante int Suma = 230; foreach (DataRow Dr in dsPedido.Tables["detallePedido"].Rows) { e.Graphics.DrawString(Convert.ToDecimal(Dr["Cantidad"]).ToString("#,##0.00") + " " + "KG", txtNumPedido.Font, Brushes.Black, 80 + AppSettings.FacturaEjeX, Suma + AppSettings.FacturaEjeY, formato); //cantidad + UM e.Graphics.DrawString(Dr["NomProducto"].ToString(), txtNumPedido.Font, Brushes.Black, 110 + AppSettings.FacturaEjeX, Suma + AppSettings.FacturaEjeY); //descripcion o producto e.Graphics.DrawString(Convert.ToDecimal(Dr["PrecioUnitario"]).ToString("#,##0.00"), txtNumPedido.Font, Brushes.Black, 665 + AppSettings.FacturaEjeX, Suma + AppSettings.FacturaEjeY, formato); //precio unitario e.Graphics.DrawString(Convert.ToDecimal(Dr["Importe"]).ToString("#,##0.00"), txtNumPedido.Font, Brushes.Black, 790 + AppSettings.FacturaEjeX, Suma + AppSettings.FacturaEjeY, formato); //valor de venta Suma += 14; } e.Graphics.DrawString(lblSubTotal.Text, txtNumPedido.Font, Brushes.Black, 790 + AppSettings.FacturaEjeX, 427 + AppSettings.FacturaEjeY, formato); //subtotal e.Graphics.DrawString(lblIGV.Text, txtNumPedido.Font, Brushes.Black, 790 + AppSettings.FacturaEjeX, 447 + AppSettings.FacturaEjeY, formato); //igv e.Graphics.DrawString(lblTotPagar.Text, txtNumPedido.Font, Brushes.Black, 790 + AppSettings.FacturaEjeX, 477 + AppSettings.FacturaEjeY, formato); //total e.Graphics.DrawString(DateTime.Now.Day.ToString(), txtNumPedido.Font, Brushes.Black, 405 + AppSettings.FacturaEjeX, 457 + AppSettings.FacturaEjeY); //dia pie e.Graphics.DrawString(DateTime.Now.ToString("MMMM"), txtNumPedido.Font, Brushes.Black, 465 + AppSettings.FacturaEjeX, 457 + AppSettings.FacturaEjeY); //mes pie e.Graphics.DrawString(DateTime.Now.Year.ToString().Substring(2), txtNumPedido.Font, Brushes.Black, 545 + AppSettings.FacturaEjeX, 457 + AppSettings.FacturaEjeY); //año pie e.Graphics.DrawString(TotalPagarLetras, txtNumPedido.Font, Brushes.Black, 90 + AppSettings.FacturaEjeX, 407 + AppSettings.FacturaEjeY); //total pagar en letras } #endregion #region ticketera if (Convert.ToInt16(CboTipoComprobante.SelectedValue) == 3)//es ticket { //obtener datos de la empresa DataView DV = new DataView(Dtempresas); //string EmpresaID = "IH"; DV.RowFilter = "EmpresaID = '" + "GH" + "'"; string NomEmpresa = DV[0]["NomEmpresa"].ToString(); string RUC = DV[0]["RUC"].ToString(); string SerieEticketera; string NroAutorizacion; //SerieEticketera = CboSerieGuia.Columns["SerieEticketera"].Value.ToString(); //NroAutorizacion = CboSerieGuia.Columns["NroAutorizacion"].Value.ToString(); DataView dv1 = new DataView(DtserieGuias, "EmpresaID = '" + "GH" + "' and TipoDocumento = " + CboTipoComprobante.SelectedValue.ToString() + " and Serie = '" + cbSerie.SelectedValue.ToString() + "'", "", DataViewRowState.CurrentRows); SerieEticketera = dv1[0]["SerieEticketera"].ToString(); NroAutorizacion = dv1[0]["NroAutorizacion"].ToString(); //cambiar el nombre de las columnas dsPedido.Tables["detallePedido"].Columns["NomProducto"].ColumnName = "Alias"; string Formatoticket = ObjCL_Venta.FormatoTicketBoleta(NomEmpresa, AppSettings.NomSede, NumComprobante.Substring(2), "Ticket Nro: ", dsPedido.Tables["detallePedido"], RUC, AppSettings.Usuario, Total, NomCaja, SerieEticketera, NroAutorizacion, TotalPagarLetras, lblCliente.Text, lblDocumento.Text, lblDireccion.Text, "", true, FECHA_IMPRESION, Total, 0, null, Total); e.Graphics.DrawString(Formatoticket, txtNumPedido.Font, Brushes.Black, 0, 0); //total pagar en letras } #endregion }
public string GenerarSunat(Int32 TipoComprobanteID, string NumComprobante, string EmpresaID, string Tipo, string TipoNotaCredito, string DescripcionAnulacion) { /* * TipoDocumento = 07 nota de credito * NumComprobante2 para notacredito */ try { DataSet ds = GetComprobanteFE(TipoComprobanteID, NumComprobante, EmpresaID, null, Tipo); DataTable dtc = ds.Tables[0]; DataTable dtd = ds.Tables[1]; if (dtc.Rows[0]["EmiteFE"].ToString() == "S" & (Tipo == "01" | Tipo == "03" | Tipo == "07")) { string RUTA_WS_SUNAT = ConfigurationManager.AppSettings["RUTA_WS_SUNAT"]; ServicioEnviarComprobanteFE.FEServiceClient ServicioFE = new ServicioEnviarComprobanteFE.FEServiceClient(); ServicioEnviarComprobanteFE.Contribuyente emisor = new ServicioEnviarComprobanteFE.Contribuyente(); ServicioEnviarComprobanteFE.Contribuyente receptor = new ServicioEnviarComprobanteFE.Contribuyente(); ServicioEnviarComprobanteFE.DetalleDocumento[] detalle = new ServicioEnviarComprobanteFE.DetalleDocumento[dtd.Rows.Count]; ServicioEnviarComprobanteFE.DatoAdicional[] datosadicionales = new ServicioEnviarComprobanteFE.DatoAdicional[0]; //ServicioEnviarComprobanteFE.DocumentoRelacionado[] relacionados = new ServicioEnviarComprobanteFE.DocumentoRelacionado[0]; receptor.TipoDocumento = dtc.Rows[0]["TipoDocumentoIdentidadCliente"].ToString(); receptor.NroDocumento = dtc.Rows[0]["NumeroDocumentoIdentidadCliente"].ToString(); receptor.NombreLegal = dtc.Rows[0]["RazonSocialCliente"].ToString(); emisor.TipoDocumento = dtc.Rows[0]["TipoDocumentoEmisor"].ToString(); emisor.NroDocumento = dtc.Rows[0]["RUC"].ToString(); emisor.NombreLegal = dtc.Rows[0]["RazonSocial"].ToString(); TextFunctions ObjTextFunctions = new TextFunctions(); string TotalPagarLetras = ObjTextFunctions.enletras(dtc.Rows[0]["ImporteTotal"].ToString()); //ServicioEnviarComprobanteFE.DocumentoRelacionado sss = new ServicioEnviarComprobanteFE.DocumentoRelacionado(); //sss.NroDocumento = ""; //sss.TipoDocumento = ""; //ServicioEnviarComprobanteFE.DatoAdicional dar = new ServicioEnviarComprobanteFE.DatoAdicional(); //dar.Codigo = ""; //dar.Contenido = ""; int id = 0; foreach (DataRow DR in dtd.Rows) { //ServicioEnviarComprobanteFE.DetalleDocumento dd = new ServicioEnviarComprobanteFE.DetalleDocumento(); ServicioEnviarComprobanteFE.DetalleDocumento dd = new ServicioEnviarComprobanteFE.DetalleDocumento(); dd.Cantidad = Convert.ToDecimal(DR["Cantidad"]); dd.CodigoItem = DR["CodigoProducto"].ToString(); dd.Descripcion = DR["DescripcionProducto"].ToString(); dd.Descuento = Convert.ToDecimal(DR["DescuentoItem"]); dd.Id = id + 1; dd.Impuesto = Convert.ToDecimal(DR["MontoIgvItem"]); dd.ImpuestoSelectivo = Convert.ToDecimal(DR["MontoISCItem"]); dd.OtroImpuesto = 0; dd.PrecioReferencial = Convert.ToDecimal(DR["ValorVentaItem"]); dd.PrecioUnitario = Convert.ToDecimal(DR["PrecioVentaItem"]); dd.Suma = Convert.ToDecimal(DR["Suma"]); dd.TipoImpuesto = DR["AfectacionIGVItem"].ToString(); dd.TipoPrecio = "01"; dd.TotalVenta = Convert.ToDecimal(DR["TotalVenta"]); dd.UnidadMedida = DR["CodigoUM"].ToString(); detalle[id] = dd; id = id + 1; } //ServicioEnviarComprobanteFE.DocumentoElectronico _documento = new ServicioEnviarComprobanteFE.DocumentoElectronico() ServicioEnviarComprobanteFE.DocumentoElectronico _documento = new ServicioEnviarComprobanteFE.DocumentoElectronico() { FechaEmision = DateTime.Today.ToShortDateString(), IdDocumento = dtc.Rows[0]["NumComprobante2"].ToString(), TotalIgv = Convert.ToDecimal(dtc.Rows[0]["SumatoriaIGV"]), TotalIsc = Convert.ToDecimal(dtc.Rows[0]["SumatoriaISC"]), TotalOtrosTributos = Convert.ToDecimal(dtc.Rows[0]["SumatoriaOtrosTributos"]), Gravadas = Convert.ToDecimal(dtc.Rows[0]["OperacionesGravadas"]), Exoneradas = Convert.ToDecimal(dtc.Rows[0]["ValorVentaOperacionesExoneradas"]), Inafectas = Convert.ToDecimal(dtc.Rows[0]["OperacionesInafectas"]), Gratuitas = Convert.ToDecimal(dtc.Rows[0]["Gratuitas"]), TotalVenta = Convert.ToDecimal(dtc.Rows[0]["ImporteTotal"]), DescuentoGlobal = Convert.ToDecimal(dtc.Rows[0]["DescuentosGlobales"]), Moneda = dtc.Rows[0]["TipoMoneda"].ToString(), CalculoIgv = Convert.ToDecimal(dtc.Rows[0]["DescuentosGlobales"]), CalculoDetraccion = Convert.ToDecimal(dtc.Rows[0]["DescuentosGlobales"]), CalculoIsc = Convert.ToDecimal(dtc.Rows[0]["DescuentosGlobales"]), MonedaAnticipo = "", TipoDocumento = dtc.Rows[0]["TipoDocumento"].ToString(), TipoOperacion = dtc.Rows[0]["TipoOperacion"].ToString(), TipoDocAnticipo = "", MontoAnticipo = 0, MontoDetraccion = 0, MontoEnLetras = TotalPagarLetras, MontoPercepcion = 0, Emisor = emisor, Receptor = receptor, Items = detalle, //Relacionados = relacionados, DatoAdicionales = datosadicionales, RutaXML = dtc.Rows[0]["RutaXMLFE"].ToString() }; int NotaID = 0; if (Tipo == "07") { ServicioEnviarComprobanteFE.Discrepancia[] discrepancias = new ServicioEnviarComprobanteFE.Discrepancia[1]; ServicioEnviarComprobanteFE.Discrepancia Discre = new ServicioEnviarComprobanteFE.Discrepancia(); Discre.NroReferencia = dtc.Rows[0]["NumComprobante2"].ToString(); Discre.Descripcion = DescripcionAnulacion; Discre.Tipo = TipoNotaCredito; discrepancias[0] = Discre; //obtener nota credito DataTable dtnota = InsertarNotaCreditoFE("07", EmpresaID, dtc.Rows[0]["NumComprobante2"].ToString().Substring(0, 4), Convert.ToInt32(dtc.Rows[0]["NumComprobante2"].ToString().Substring(5, 8)), TipoComprobanteID, Convert.ToDecimal(dtc.Rows[0]["ImporteTotal"]), DescripcionAnulacion, 0, Convert.ToInt32(dtc.Rows[0]["ClienteID"].ToString()), 51, ""); _documento.IdDocumento = dtnota.Rows[0]["NumeroComprobante"].ToString(); _documento.TipoDocumento = Tipo; _documento.Discrepancias = discrepancias; NotaID = Convert.ToInt32(dtnota.Rows[0]["NotaID"]); ServicioEnviarComprobanteFE.DocumentoRelacionado[] Relacionados = new ServicioEnviarComprobanteFE.DocumentoRelacionado[1]; ServicioEnviarComprobanteFE.DocumentoRelacionado relacion = new ServicioEnviarComprobanteFE.DocumentoRelacionado(); relacion.NroDocumento = dtc.Rows[0]["NumComprobante2"].ToString(); relacion.TipoDocumento = dtc.Rows[0]["TipoDocumento"].ToString(); Relacionados[0] = relacion; _documento.Relacionados = Relacionados; } else { ServicioEnviarComprobanteFE.DocumentoRelacionado[] Relacionados = new ServicioEnviarComprobanteFE.DocumentoRelacionado[0]; _documento.Relacionados = Relacionados; } ServicioEnviarComprobanteFE.DocumentoResponse respu = ServicioFE.GenerarXMLFactura(_documento); if (respu.Exito == true) { //solo se envia factura, nota credito a sunat, boleta solo se guarda if (Tipo == "01" | Tipo == "07") { ServicioEnviarComprobanteFE.RespuestaComunConArchivo2 RespuestaSunat = ServicioFE.EnviarSunat(Tipo, dtc.Rows[0]["RutaXMLFE"].ToString(), dtc.Rows[0]["RutaCDRFE"].ToString(), dtc.Rows[0]["RutaCertificado"].ToString(), dtc.Rows[0]["ClaveCertificado"].ToString(), dtc.Rows[0]["RUC"].ToString(), dtc.Rows[0]["UsuarioSOL"].ToString(), dtc.Rows[0]["ClaveSol"].ToString(), _documento.IdDocumento, RUTA_WS_SUNAT, false); if (Tipo == "07") { ActualizarNotaCredito(NotaID, Convert.ToInt64(RespuestaSunat.NroTicket), RespuestaSunat.MensajeError, (RespuestaSunat.Exito == true) ? "S" : "N", Convert.ToInt32(dtc.Rows[0]["ComprobanteId"])); } DataTable dtres; if (Tipo == "01") { dtres = ActualizarComprobanteSunat(Convert.ToInt32(dtc.Rows[0]["ComprobanteId"]), (RespuestaSunat.Exito == true) ? "S" : "N", RespuestaSunat.MensajeRespuesta); } if (RespuestaSunat.Exito == false) { throw new Exception(RespuestaSunat.MensajeError); } else { if (Tipo == "01") { //GENERAR EMISIÓN FISICA if (dtc.Rows[0]["GenerarFisico"].ToString() == "S") { //string mensajeresp = ServicioFE.GenerarPdf(ds, dtc.Rows[0]["RutaXMLFE"].ToString(), dtc.Rows[0]["NumComprobante2"].ToString(), RespuestaSunat.MensajeRespuesta); //if (mensajeresp != "OK") //{ // return respu.MensajeError; //} } } } return("OK"); } } else { return(respu.MensajeError); } } return("OK"); } catch (Exception ex) { return(ex.Message); } }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //formato para alinear los nuimeros a la derecha StringFormat formato = new StringFormat(); formato.Alignment = StringAlignment.Far; //formato.LineAlignment = StringAlignment.Far; TextFunctions ObjTextFunctions = new TextFunctions(); //obtener la cadena del total a pagar string TotalPagarLetras = ObjTextFunctions.enletras(dtcabecera.Rows[0]["Monto"].ToString()); string NomEmpresa = dtcabecera.Rows[0]["NomEmpresa"].ToString(); string RUC = dtcabecera.Rows[0]["RUC"].ToString(); string SerieEticketera = ""; string NroAutorizacion = ""; string CodigoTipoComprobante = "03", TipoLetra = "B", TipoDocumentoCliente = "DNI"; int Canticabecera = 31; string[] Formatoticket = new string[2]; if (dtcabecera.Rows[0]["NroDocumentoCliente"].ToString() == "0") { ConCliente = false; } else { ConCliente = true; } if (hojaimpresa == 1) { if (Convert.ToInt16(dtcabecera.Rows[0]["TipoComprobanteID"]) == 4)//es boleta { Formatoticket = objVenta.FormatoTicketFE(NomEmpresa, AppSettings.NomSede, dtcabecera.Rows[0]["NumComprobante"].ToString().Substring(2), "BOLETA ELECTRONICA: ", dtdetalle, RUC, AppSettings.Usuario, Convert.ToDecimal(dtcabecera.Rows[0]["MontoPagado"]), dtcabecera.Rows[0]["NomCaja"].ToString(), SerieEticketera, NroAutorizacion, TotalPagarLetras, dtcabecera.Rows[0]["RazonSocialCliente"].ToString(), dtcabecera.Rows[0]["NroDocumentoCliente"].ToString(), dtcabecera.Rows[0]["DireccionCliente"].ToString(), "", ConCliente, Convert.ToDateTime(dtcabecera.Rows[0]["AudCrea"]), Convert.ToDecimal(dtcabecera.Rows[0]["MontoPagado"]), Convert.ToDecimal(dtcabecera.Rows[0]["TotalIGV"]), "B", DtDatosSede.Rows[0]["TelefonoCelular"].ToString(), DtDatosSede.Rows[0]["TelefonoFijo"].ToString(), Convert.ToDecimal(dtcabecera.Rows[0]["Monto"]), Convert.ToDecimal(dtcabecera.Rows[0]["TotalICBPER"])); e.Graphics.DrawString(Formatoticket[0], TxtFormato.Font, Brushes.Black, 0, 0); //total pagar en letras } else if (Convert.ToInt16(dtcabecera.Rows[0]["TipoComprobanteID"]) == 5) //es factura { CodigoTipoComprobante = "01"; TipoLetra = "F"; TipoDocumentoCliente = "RUC"; Canticabecera = 35; Formatoticket = objVenta.FormatoTicketFE(NomEmpresa, AppSettings.NomSede, dtcabecera.Rows[0]["NumComprobante"].ToString().Substring(2), "FACTURA ELECTRONICA: ", dtdetalle, RUC, AppSettings.Usuario, Convert.ToDecimal(dtcabecera.Rows[0]["MontoPagado"]), dtcabecera.Rows[0]["NomCaja"].ToString(), SerieEticketera, NroAutorizacion, TotalPagarLetras, dtcabecera.Rows[0]["RazonSocialCliente"].ToString(), dtcabecera.Rows[0]["NroDocumentoCliente"].ToString(), dtcabecera.Rows[0]["DireccionCliente"].ToString(), "", ConCliente, Convert.ToDateTime(dtcabecera.Rows[0]["AudCrea"]), Convert.ToDecimal(dtcabecera.Rows[0]["MontoPagado"]), Convert.ToDecimal(dtcabecera.Rows[0]["TotalIGV"]), "F", DtDatosSede.Rows[0]["TelefonoCelular"].ToString(), DtDatosSede.Rows[0]["TelefonoFijo"].ToString(), Convert.ToDecimal(dtcabecera.Rows[0]["Monto"]), Convert.ToDecimal(dtcabecera.Rows[0]["TotalICBPER"])); e.Graphics.DrawString(Formatoticket[0], TxtFormato.Font, Brushes.Black, 0, 0); //total pagar en letras //e.Graphics.DrawString(Convert.ToChar(27) + "i", TxtPrecio.Font, Brushes.Black, 0, 0); //total pagar en letras } /*imprimir el codigo de barras*/ QRCodeEncoder objqrcode = new QRCodeEncoder(); Image imgimage; Bitmap objbitmap; PictureBox Pimage = new PictureBox(); string s; s = RUC + " | " + CodigoTipoComprobante + " | " + TipoLetra + dtcabecera.Rows[0]["NumComprobante"].ToString().Substring(2, 3) + " | " + "0" + dtcabecera.Rows[0]["NumComprobante"].ToString().Substring(6) + " | " + Convert.ToDecimal(dtcabecera.Rows[0]["TotalIGV"]).ToString("N2") + " | " + Convert.ToDecimal(dtcabecera.Rows[0]["Monto"]).ToString("N2") + " | " + Convert.ToDateTime(dtcabecera.Rows[0]["AudCrea"]).ToShortDateString() + " | " + TipoDocumentoCliente + " | " + dtcabecera.Rows[0]["NroDocumentoCliente"].ToString(); objqrcode.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; objqrcode.QRCodeScale = 3; objqrcode.QRCodeVersion = 6; objqrcode.QRCodeErrorCorrect = ThoughtWorks.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.L; imgimage = objqrcode.Encode(s); objbitmap = new Bitmap(imgimage); //objbitmap.Save("QRCode.jpg"); //Pimage.ImageLocation = "QRCode.jpg"; //CALCULAMOS AL CANTIDAD DE LINEAS int CantidadLineas = (Canticabecera * 14) + (Convert.ToInt32(Formatoticket[1]) * 14); e.Graphics.DrawImage(imgimage, new Point(70, CantidadLineas)); if (Convert.ToDecimal(dtcabecera.Rows[0]["TotalIGV"]) == 0) { string textofinal = "Bienes transferidos en la Amazonía\nRegión Selva para ser cosumidos en la\nmisma."; e.Graphics.DrawString(textofinal, TxtFormato.Font, Brushes.Black, 0, CantidadLineas + (14 * 11)); } hojaimpresa = 2; e.HasMorePages = true; } else if (hojaimpresa == 2) { decimal total = Convert.ToDecimal(dtcabecera.Rows[0]["Monto"]) + Convert.ToDecimal(dtcabecera.Rows[0]["TotalICBPER"]) + Convert.ToDecimal(dtcabecera.Rows[0]["TotalIGV"]); if (Convert.ToInt16(dtcabecera.Rows[0]["TipoComprobanteID"]) == 4)//es boleta { string[] Formatoticket2 = new string[2]; Formatoticket2 = objVenta.FormatoTicketFEResumido(NomEmpresa, AppSettings.NomSede, dtcabecera.Rows[0]["NumComprobante"].ToString().Substring(2), "BOLETA ELECTRONICA: ", dtdetalle, RUC, AppSettings.Usuario, Convert.ToDecimal(dtcabecera.Rows[0]["MontoPagado"]), dtcabecera.Rows[0]["NomCaja"].ToString(), SerieEticketera, NroAutorizacion, TotalPagarLetras, dtcabecera.Rows[0]["RazonSocialCliente"].ToString(), dtcabecera.Rows[0]["NroDocumentoCliente"].ToString(), dtcabecera.Rows[0]["DireccionCliente"].ToString(), "", ConCliente, Convert.ToDateTime(dtcabecera.Rows[0]["AudCrea"]), Convert.ToDecimal(dtcabecera.Rows[0]["MontoPagado"]), Convert.ToDecimal(dtcabecera.Rows[0]["TotalIGV"]), "B", total, Convert.ToDecimal(dtcabecera.Rows[0]["TotalICBPER"])); e.Graphics.DrawString(Formatoticket2[0], TxtFormato.Font, Brushes.Black, 0, 0); //total pagar en letras } else if (Convert.ToInt16(dtcabecera.Rows[0]["TipoComprobanteID"]) == 5) //es factura { CodigoTipoComprobante = "01"; TipoLetra = "F"; TipoDocumentoCliente = "RUC"; Canticabecera = 35; string[] Formatoticket2 = new string[2]; Formatoticket2 = objVenta.FormatoTicketFEResumido(NomEmpresa, AppSettings.NomSede, dtcabecera.Rows[0]["NumComprobante"].ToString().Substring(2), "FACTURA ELECTRONICA: ", dtdetalle, RUC, AppSettings.Usuario, Convert.ToDecimal(dtcabecera.Rows[0]["Monto"]), dtcabecera.Rows[0]["NomCaja"].ToString(), SerieEticketera, NroAutorizacion, TotalPagarLetras, dtcabecera.Rows[0]["RazonSocialCliente"].ToString(), dtcabecera.Rows[0]["NroDocumentoCliente"].ToString(), dtcabecera.Rows[0]["DireccionCliente"].ToString(), "", ConCliente, Convert.ToDateTime(dtcabecera.Rows[0]["AudCrea"]), Convert.ToDecimal(dtcabecera.Rows[0]["Monto"]), Convert.ToDecimal(dtcabecera.Rows[0]["TotalIGV"]), "F", total, Convert.ToDecimal(dtcabecera.Rows[0]["TotalICBPER"])); e.Graphics.DrawString(Formatoticket2[0], TxtFormato.Font, Brushes.Black, 0, 0); //total pagar en letras //e.Graphics.DrawString(Convert.ToChar(27) + "i", TxtPrecio.Font, Brushes.Black, 0, 0); //total pagar en letras } e.HasMorePages = false; } }
public override IEnumerable <Row> Process(RowSet input, Row outputRow, string[] args) { foreach (Row row in input.Rows) { String ddate; DateTime dateObject; String currentdate = ""; String currenthour = ""; String currentminute = ""; string entityPrintable = ""; CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; string entityOriginal = ""; int userAgeInDays = 0; //Parse Tweet's createdTime try { ddate = TextFunctions.DateFormatUtc(TextFunctions.Strip(row["tCreatedAt"].ToString()), "0", 0.0); dateObject = DateTime.Parse(ddate); currentdate = dateObject.Date.ToString("yyyy-MM-dd"); currenthour = dateObject.ToString("HH"); currentminute = dateObject.ToString("mm"); } catch (Exception e) { continue; } //Parse User's createdTime try { userAgeInDays = Convert.ToInt32((dateObject - DateTime.Parse(TextFunctions.DateFormatUtc(TextFunctions.Strip(row["uCreatedAt"].ToString()), "0", 0.0))).TotalDays); if (userAgeInDays < 30) { continue; } } catch (Exception e) { continue; } string targeturl = TextFunctions.StripChar(row["tUrl"].String).Trim(); string printableUrl = targeturl; if (targeturl != "") { if (targeturl.Contains("http://www.")) { targeturl = targeturl.Replace("http://www.", ""); } else if (targeturl.Contains("https://www.")) { targeturl = targeturl.Replace("https://www.", ""); } else if (targeturl.Contains("http://")) { targeturl = targeturl.Replace("http://", ""); } else if (targeturl.Contains("https://")) { targeturl = targeturl.Replace("https://", ""); } targeturl = TextFunctions.removeURLAfterHash(targeturl); } if (targeturl.Contains("itunes.apple.com")) { continue; } if (targeturl.Contains("store.apple.com")) { continue; } int isNews = 0; if (row["tLinkAnnotations"].String.Contains("newsclassifier.is_news_domain\",\"Value\":\"1\"") && !targeturl.Contains("mtv.com") && !targeturl.Contains("popsugar.com")) { isNews = 1; } HashSet <string> alreadyPrinted = new HashSet <string>(); string title = TextFunctions.cleanString(TextFunctions.StripChar(row["tTitle"].String)).Trim(); String[] entities = new String[] { row["tNamedEntityFirst"].String.Trim(), row["tNamedEntitySecond"].String.Trim(), row["tNamedEntityThird"].String.Trim() }; String[] entityTypes = new String[] { row["tNamedEntityCategoryFirst"].String.Trim(), row["tNamedEntityCategorySecond"].String.Trim(), row["tNamedEntityCategoryThird"].String.Trim() }; int ctr = -1; //Process explicit entities List <Entity> entityList = new List <Entity>(); foreach (string entity in entities) { ctr++; if (entity == "") { continue; } if (entity.Length < 3) { continue; } if (entityTypes[ctr] == "DATE" || entityTypes[ctr] == "TIME-POINT" || entityTypes[ctr] == "ZIP") { continue; } entityOriginal = entity.Replace(" _ ", " ").Trim(); entityPrintable = entityOriginal; if ((entityOriginal.ToLower() == entityOriginal)) { entityPrintable = textInfo.ToTitleCase(entityOriginal.ToLower()); } if (alreadyPrinted.Contains(entityOriginal.ToLower())) { continue; } alreadyPrinted.Add(entityOriginal.ToLower()); if (IsEntityExtractedFromDomain(targeturl, entityOriginal)) { continue; } Entity explictEntity = new Entity() { entity = entityOriginal.ToLower(), entityPrintable = entityPrintable, entitytype = "entity", entitysubtypetype = entityTypes[ctr], entitySource = "Original" }; entityList.Add(explictEntity); } //Process ngrams string textNgrams = TextFunctions.generateNgrams(row["tText"].String, 1, 4); string[] tokens = textNgrams.Trim().Split(';'); string typeOfNgramType = ""; string previousEntity = ""; foreach (string token in tokens) { if (token.Length < 3) { continue; } if (token[0] == '#') { typeOfNgramType = "hashtag"; } else if (token[0] == '@') { typeOfNgramType = "username"; } else if (("@" + token) == previousEntity) { typeOfNgramType = "username"; } else { typeOfNgramType = "ngram"; } if (alreadyPrinted.Contains(token.ToLower())) { continue; } if (IsEntityExtractedFromDomain(targeturl, token)) { continue; } previousEntity = token; alreadyPrinted.Add(token.ToLower()); Entity tweetTextNGram = new Entity() { entity = token.ToLower(), entityPrintable = token, entitytype = typeOfNgramType, entitysubtypetype = string.Empty, entitySource = "Text" }; entityList.Add(tweetTextNGram); } /////////////////////////////HEADLINE/////////////////////// (should be news document's title) string textNgrams1 = ""; if (isNews == 1) { textNgrams1 = TextFunctions.generateNgrams(title, 1, 4); } string[] tokens1 = textNgrams1.Trim().Split(';'); foreach (string token in tokens1) { if (token.Length < 3) { continue; } if (token[0] == '#') { typeOfNgramType = "hashtag"; } else if (token[0] == '@') { typeOfNgramType = "username"; } else if (("@" + token) == previousEntity) { typeOfNgramType = "username"; } else { typeOfNgramType = "ngram"; } if (alreadyPrinted.Contains(token.ToLower())) { continue; } if (IsEntityExtractedFromDomain(targeturl, token)) { continue; } previousEntity = token; alreadyPrinted.Add(token.ToLower()); Entity titleTextNGram = new Entity() { entity = token.ToLower(), entityPrintable = token, entitytype = typeOfNgramType, entitysubtypetype = string.Empty, entitySource = "Title" }; entityList.Add(titleTextNGram); } outputRow["dateCreation"].Set(currentdate); outputRow["hourCreation"].Set(currenthour); outputRow["minuteCreation"].Set(currentminute); outputRow["targeturl"].Set(targeturl); outputRow["domain"].Set(row["tDomain"].String.Trim()); outputRow["thumbnail"].Set(TextFunctions.ExtractThumbnail(row["tLinkAnnotations"].String)); outputRow["url"].Set(printableUrl); outputRow["isnewsurl"].Set(isNews); outputRow["tID"].Set(row["tID"].String); outputRow["uID"].Set(row["uID"].String); outputRow["uScreenName"].Set(row["uScreenName"].String); outputRow["uName"].Set(row["uName"].String); outputRow["userAgeInDays"].Set(userAgeInDays); outputRow["sentiment"].Set(0.0); if (isNews == 1) { outputRow["tweettext"].Set(TextFunctions.cleanString(title)); } else if (row["tDomain"].String == "youtube.com") { outputRow["tweettext"].Set(TextFunctions.cleanString(title)); } else { outputRow["tweettext"].Set(""); } outputRow["tIsRetweet"].Set(row["tIsRetweet"].String); /////////////////////////new columns///////////////////////// string text = TextFunctions.normalizedText(TextFunctions.cleanText(row["tText"].String)); outputRow["tText"].Set(text); row["tText"].CopyTo(outputRow["tRawText"]); outputRow["tTextFragments"].Set(row["tTextFragments"].String); outputRow["tPublishTime"].Set(TextFunctions.DateFormatFileUtc(TextFunctions.Strip(row["tCreatedAt"].ToString()), "0", 0.0)); outputRow["tRetweetCount"].Set(row["tRetweetCount"].String); outputRow["tSpamScore"].Set(row["tSpamScore"].String); outputRow["uAuthScore"].Set(row["uAuthScore"].String); outputRow["uFavoritesCount"].Set(row["uFavoritesCount"].String); outputRow["uFollowersCount"].Set(row["uFollowersCount"].String); outputRow["uFriendsCount"].Set(row["uFriendsCount"].String); outputRow["uProfile"].Set(TextFunctions.generateProfile(row["uID"].String, row["uName"].String, row["uScreenName"].String, row["uProfilePage"].String, row["uProfileImageUrl"].String, row["uVerified"].Boolean)); outputRow["uVerified"].Set(row["uVerified"].String); /////////////////////////new columns end///////////////////////// foreach (Entity entity in entityList) { outputRow["entity"].Set(entity.entity); outputRow["entityPrintable"].Set(entity.entityPrintable); outputRow["entitytype"].Set(entity.entitytype); outputRow["entitysubtypetype"].Set(entity.entitysubtypetype); outputRow["entitySource"].Set(entity.entitySource);//new column yield return(outputRow); } } }
public static string generateTextFragments(string text, string linksJsonString) { //clean text text = cleanText(text); string result = ""; //delete "RT @alias: " string pattern = @"^RT @(\w+): "; if (Regex.Match(text, pattern).Success) { text = Regex.Replace(text, pattern, ""); } //replace all link with display url //return all link List <jTextFragment> fragments = new List <jTextFragment>(); string pattern2 = @"https*:\\/\\/(\S+)"; Regex reg = new Regex(pattern2); Match m = reg.Match(text); int count = reg.Matches(text).Count; if (string.IsNullOrEmpty(linksJsonString)) { if (count != 0) { return(String.Empty); } fragments.Add(new jTextFragment() { Text = TextFunctions.StripChar(text), Url = "", Domain = "" }); return(JsonConvert.SerializeObject(fragments)); } var linksObj = JArray.Parse(linksJsonString); if (count != linksObj.Count) { return(String.Empty); } int i = 0; int last = 0; while (m.Success) { result = m.Groups[0].ToString(); int start = m.Groups[0].Captures[0].Index; int end = start + result.Length; if (last < start) { fragments.Add(new jTextFragment() { Text = TextFunctions.StripChar(text.Substring(last, start - last)), Url = "", Domain = "" }); } fragments.Add(new jTextFragment() { Text = TextFunctions.StripChar(linksObj[i]["DisplayUrl"].ToObject <string>()), Url = TextFunctions.StripChar(result), Domain = linksObj[i]["Domain"].ToObject <string>() }); m = m.NextMatch(); i++; last = end; } if (last < text.Length) { fragments.Add(new jTextFragment() { Text = TextFunctions.StripChar(text.Substring(last, text.Length - last)), Url = "", Domain = "" }); } return(JsonConvert.SerializeObject(fragments)); }