using iTextSharp.text; using iTextSharp.text.pdf; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SQLite; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView; //using Image = iTextSharp.text.Image; namespace CKUERA { public partial class Clientes : Form { public Clientes() { InitializeComponent(); } static public string Paises; static public string Departamentos; static public string Distritos; static public string Localidades; static public string Id ="0"; static public int ApuntoReg=0; private void Clientes_Load(object sender, EventArgs e) { mensaje_lab.Left = 3000; button5.Left = 3000; DataG1.Width = 586; DataG1.Height = 266; DataG1.Left = 40; DataG1.Top = TextBox1.Top + TextBox1.Height + 1; Button1.BackColor= Global.ColorSistema; Button2.BackColor = Global.ColorSistema; Button3.BackColor = Global.ColorSistema;// button4.BackColor= Global.ColorSistema;// comb_TipoIden.Items.Add("RUC"); comb_TipoIden.Items.Add("CÉDULA IDENTIDAD"); comb_TipoIden.Items.Add("PASAPORTE"); comb_TipoIden.Items.Add("IDEN. EXTRANJERA"); comb_TipoIden.Items.Add("IDEN. DIPLOMÁTICA"); comb_TipoIden.Items.Add("IDEN. TRIBUTARIA"); { string name = "iconos\\registrar.png"; try { Button1.Image = System.Drawing.Image.FromFile(name); } catch (Exception) { } } { string name = "iconos\\modificar.png"; try { button4.Image = System.Drawing.Image.FromFile(name); } catch (Exception) { } } { string name = "iconos\\limpiar.png"; try { Button2.Image = System.Drawing.Image.FromFile(name); } catch (Exception) { } } { string name = "iconos\\eliminar.png"; try { Button3.Image = System.Drawing.Image.FromFile(name); } catch (Exception) { } } } private void Clientes_Resize(object sender, EventArgs e) { panel1.Left = this.Width / 2 - panel1.Width / 2; panel1.Top = this.Height / 2 - panel1.Height / 2; Btn_Cerrar.Top = 0; Btn_Cerrar.Left = panel1.Width - Btn_Cerrar.Width; this.BackColor = Global.ColorSistema; Lb_Titulo.Top = 0; Lb_Titulo.Left = 0; Lb_Titulo.Text = this.Text; } public void REEMPLZAR() { TextBox1.Text = TextBox1.Text.ToUpper().Trim().Replace("'", "´"); TextBox2.Text = TextBox2.Text.ToUpper().Trim().Replace("'", "´"); TextBox3.Text = TextBox3.Text.ToUpper().Trim().Replace("'", "´"); TextBox4.Text = TextBox4.Text.ToUpper().Trim().Replace("'", "´"); TextBox1.SelectionStart = TextBox1.Text.Length + 1; TextBox2.SelectionStart = TextBox2.Text.Length + 1; TextBox3.SelectionStart = TextBox3.Text.Length + 1; TextBox4.SelectionStart = TextBox4.Text.Length + 1; } public static string a; public static string DigitoVer(string ruc) { int multix = 2; int suma = 0; try { ruc.ToCharArray() .Reverse() .ToList() .ForEach(f => { suma += (Convert.ToInt32(f.ToString()) * multix); multix = (multix == 9) ? 2 : multix + 1; }); a= (11 - (suma % 11)) <= 1 ? "0" : (11 - (suma % 11)).ToString(); return a = (11 - (suma % 11)) <= 1 ? "0" : (11 - (suma % 11)).ToString(); } catch { return a = ""; } } public void LIMPIAR() { // LIMPIA TODO TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; Txt_Email.Text = ""; Txt_Nom_Fantasia.Text = ""; Opt_P_Juridica.Checked= false; Opt_P_Fisica.Checked= false; valorD.Text = ""; RadioButton2.Checked = true; No_Buscar.Checked = false; Cobrar_ch.Checked = true; Saldo.Text = ""; comb_TipoIden.Text = ""; Lab_Descrip.Text = ""; //Com_Bar.Text = ""; Com_Dpto.Text = ""; Com_Dtr.Text = ""; Com_Loca.Text = ""; ApuntoReg = 0; } private void TextBox1_TextChanged_1(object sender, EventArgs e) { if (RadioButton1.Checked == false) { if (RadioButton2.Checked == false) { MessageBox.Show("Selecciones una opción de lo que desea hacer; ''Registrar nuevo'' o ''Modificar''", "!Atención!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (Regex.IsMatch(TextBox1.Text, "[^a-zA-Z0-9-/_() .,áéíóúÁÉÍÓÚñÑ`]")) { //MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox1.Select(); return; } if (TextBox1.Text == "") LIMPIAR(); { if (No_Buscar.Checked == true) return; // NO BUSCAR SI YA ENCONTRÓ if (RadioButton2.Checked == true) // SI ES MODIFICAR { if (No_Buscar.Checked == true) { REEMPLZAR(); } { this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_listar.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼", TextBox1.Text));//, TextBox2.Text.Trim())); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains("1) { MessageBox.Show("Ya existe un cliente con este documento.", "¡ATENCIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TextBox2.Text = ""; TextBox2.Select(); //Conex.Close(); return; } if (TextBox3.Text == "")//CELULAR Y TELÉFONO { //TextBox3.Text = "0"; TextBox3.Select(); return; } TextBox3.Text = TextBox3.Text.Replace(" ", ";"); TextBox3.Text = TextBox3.Text.Replace(",", ";"); TextBox3.Text = TextBox3.Text.Replace("-", ""); TextBox3.Text = TextBox3.Text.Replace("_", ""); TextBox3.Text = TextBox3.Text.Replace("&", "y"); TextBox3.Text = TextBox3.Text.Replace("'", "`"); TextBox3.Text = TextBox3.Text.Replace("\\", ";"); TextBox3.Text = TextBox3.Text.Replace("|", ";"); if (Regex.IsMatch(TextBox3.Text, "[^a-zA-Z0-9-/_() .,;áéíóúÁÉÍÓÚñÑ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox3.Select(); return; } if (TextBox4.Text == "")//DIRECCIÓN COMPLETA { //TextBox4.Text = ";"; TextBox4.Select(); return; } TextBox4.Text = TextBox4.Text.ToUpper().Trim(); TextBox4.Text = TextBox4.Text.Replace(",", ";"); TextBox4.Text = TextBox4.Text.Replace("|", "/"); TextBox4.Text = TextBox4.Text.Replace("&", "y"); TextBox4.Text = TextBox4.Text.Replace("'", "`"); TextBox4.Text = TextBox4.Text.Replace("\\", ";"); if (Regex.IsMatch(TextBox4.Text, "[^a-zA-Z0-9-/_() .,;:áéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox4.Select(); return; } try { string[] v; v = TextBox4.Text.Split(';'); string a = v[1]; } catch { MessageBox.Show("Debe escribir un número de casa desdepues de la calle, separado por PUNTO Y COMA \";\".\n\nEjemplo: \"Juan E. Oleary;1200\""); TextBox4.Select(); return; } if (Com_Pais.Text == "")//PAIS { Com_Pais.Select(); return; } Com_Pais.Text = Com_Pais.Text.ToUpper().Trim(); Com_Pais.Text = Com_Pais.Text.Replace(",", ";"); Com_Pais.Text = Com_Pais.Text.Replace("|", "/"); Com_Pais.Text = Com_Pais.Text.Replace("&", "y"); Com_Pais.Text = Com_Pais.Text.Replace("'", "`"); Com_Pais.Text = Com_Pais.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Pais.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Pais.Select(); return; } if (Com_Dpto.Text == "")//DEPARTAMENTO { //Com_Dpto.Text = ";"; Com_Dpto.Select(); return; } Com_Dpto.Text = Com_Dpto.Text.ToUpper().Trim(); Com_Dpto.Text = Com_Dpto.Text.Replace(",", ";"); Com_Dpto.Text = Com_Dpto.Text.Replace("|", "/"); Com_Dpto.Text = Com_Dpto.Text.Replace("&", "y"); Com_Dpto.Text = Com_Dpto.Text.Replace("'", "`"); Com_Dpto.Text = Com_Dpto.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Dpto.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Dpto.Select(); return; } if (Com_Dtr.Text == "")//DISTRITO { //Com_Dtr.Text = ";"; Com_Dtr.Select(); return; } Com_Dtr.Text = Com_Dtr.Text.ToUpper().Trim(); Com_Dtr.Text = Com_Dtr.Text.Replace(",", ";"); Com_Dtr.Text = Com_Dtr.Text.Replace("|", "/"); Com_Dtr.Text = Com_Dtr.Text.Replace("&", "y"); Com_Dtr.Text = Com_Dtr.Text.Replace("'", "`"); Com_Dtr.Text = Com_Dtr.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Dtr.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Dtr.Select(); return; } if (Com_Loca.Text == "")//LOCALIDAD { //Com_Loca.Text = ";"; Com_Loca.Select(); return; } Com_Loca.Text = Com_Loca.Text.ToUpper().Trim(); Com_Loca.Text = Com_Loca.Text.Replace(",", ";"); Com_Loca.Text = Com_Loca.Text.Replace("|", "/"); Com_Loca.Text = Com_Loca.Text.Replace("&", "y"); Com_Loca.Text = Com_Loca.Text.Replace("'", "`"); Com_Loca.Text = Com_Loca.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Loca.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Loca.Select(); return; } if (Txt_Email.Text == "")//EMAIL { Txt_Email.Text = " "; Txt_Email.Select(); return; } Txt_Email.Text = Txt_Email.Text.ToLower().Trim(); Txt_Email.Text = Txt_Email.Text.Replace(",", ";"); Txt_Email.Text = Txt_Email.Text.Replace(" ", ""); Txt_Email.Text = Txt_Email.Text.Replace("'", ""); ////valida correo //IsValidEmail(Txt_Email.Text); //if (!IsValidEmail(Txt_Email.Text)) //{ // MessageBox.Show("El correo electrónico no es válido."); // Txt_Email.Select(); // return; //} if (TextBox2.TextLength < 5) { TextBox2.Text = "X"; } if (RadioButton1.Checked == true) { string TP; if(Opt_P_Juridica.Checked == true) { TP = "2"; } else { TP = "1"; } ApuntoReg = 1; TextBox4.Text = Com_Pais.Text + "; " + Com_Dpto.Text + "; " + Com_Dtr.Text + "; " + Com_Loca.Text + "; " + TextBox4.Text; Txt_Nom_Fantasia.Text = Txt_Nom_Fantasia.Text.ToUpper().Trim(); this.Cursor = Cursors.WaitCursor; HttpWebRequest rq2 = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_insertar.php"); rq2.Method = "POST"; //nombre,n_fantasia,tipo_persona,ci,tel,dir,email byte[] byteArray2 = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}▼{2}▼{3}▼{4}▼{5}▼{6}", TextBox1.Text.Trim(), Txt_Nom_Fantasia.Text, TP, TextBox2.Text, TextBox3.Text.Trim(), TextBox4.Text.Trim(), Txt_Email.Text.Trim())); rq2.ContentType = "application/x-www-form-urlencoded"; rq2.ContentLength = byteArray2.Length; Stream stream2 = rq2.GetRequestStream(); stream2.Write(byteArray2, 0, byteArray2.Length); stream2.Close(); // WebResponse response2 = rq2.GetResponse(); stream2 = response2.GetResponseStream(); StreamReader reader2 = new StreamReader(stream2); string devuelve2 = reader2.ReadToEnd(); reader2.Close(); stream2.Close(); response2.Close(); string[] c2 = devuelve2.Split('▲'); this.Cursor = Cursors.Default; string resultado2 = devuelve2.ToUpper(); bool re2; re2 = resultado2.Contains("ERROR"); if (re2 == true) { MessageBox.Show(devuelve2); return; } MessageBox.Show(devuelve2); LIMPIAR(); } } TextBox1.Select(); } private void DataG1_CellContentClick(object sender, DataGridViewCellEventArgs e) { } private void DataG1_Click(object sender, EventArgs e) { ID_LABEL.Text = DataG1.CurrentRow.Cells[0].Value.ToString(); { double deuda = 0; string fecha = ""; string hora = ""; //MOSTRAR CLIENTES this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_muestra.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼", ID_LABEL.Text)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string[] c = devuelve.Trim().Split('▲'); this.Cursor = Cursors.Default; string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains(" 0) { Saldo.Text = "Saldo Total " + Global.SIMB_ + " " + string.Format("{0:#,##0.##}", deuda); } if (saldox < 0) { Saldo.ForeColor = Color.FromArgb(0, 0, 192); } else { Saldo.ForeColor = Color.FromArgb(192, 0, 0); } } UL_FECHA.Text = fecha;//CREO QUE NO SE USA UL_HORA.Text = hora;//CREO QUE NO SE USA Fdesde.Text = fecha; //DTPIKER DESDE PARA REPORTE //MessageBox.Show(fecha); } } private void Button3_Click_1(object sender, EventArgs e) { if (Global.SALDO_CLI>0 | Global.SALDO_CLI < 0) { MessageBox.Show("Este cliente tiene operación pendiente. No podrá eliminarse.","¡ATENCIÓN!",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; } DialogResult result = MessageBox.Show("¿Confirma que realmente desea eliminar?", "¿ESTÁ SEGURO/A?", MessageBoxButtons.YesNo); if (result == DialogResult.No) return; this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_delete.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼", ID_LABEL.Text)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); //string[] c = devuelve.Split('▲'); this.Cursor = Cursors.Default; string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains("ERROR"); if (re == true) { MessageBox.Show(devuelve); return; } MessageBox.Show(devuelve); //MessageBox.Show(TextBox1.Text + " se eliminó.", "Hecho", MessageBoxButtons.OK, MessageBoxIcon.Information); LIMPIAR(); TextBox1.Select(); } private void Button2_Click_1(object sender, EventArgs e) { LIMPIAR(); TextBox1.Select(); } private void RadioButton1_CheckedChanged_1(object sender, EventArgs e) { if (RadioButton1.Checked == true) { this.AcceptButton = Button1; panel2.Visible = false; DataG1.Visible = false; TextBox1.Select(); } } private void PaisesCargar() { this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/paises.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼", "")); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); //string[] c = devuelve.Split('▲'); string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains("
"); if (re == true) { MessageBox.Show(devuelve); return; } if (devuelve.Trim() != "") { foreach (var line in devuelve.Trim().Split('↔')) { var v = line.Trim().Split('▲'); if (v[0].Trim() != "") { Com_Pais.Items.Add(v[1] + ";" + v[0].ToUpper()); Paises = Paises + v[1] + ";" + v[0].ToUpper() + "\n"; } } } Com_Pais.Text = "PRY;PARAGUAY"; this.Cursor = Cursors.Default; } private void CargarCombos(string columna, string codigo) { this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/localidades.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}▼", columna, codigo)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains("
"); if (re == true) { MessageBox.Show(devuelve); return; } if (devuelve.Trim() != "") { foreach (var line in devuelve.Trim().Split('↔')) { var v = line.Trim().Split('▲'); if (v[0].Trim() != "") { if (columna == "departamentos") { Departamentos= Departamentos + v[1].ToUpper() + ";" + v[0].ToUpper()+"\n"; Com_Dpto.Items.Add(v[1] + ";" + v[0].ToUpper()); } if (columna == "distritos") { Distritos = Distritos + v[1].ToUpper() + ";" + v[0].ToUpper() + "\n"; Com_Dtr.Items.Add(v[1] + ";" + v[0].ToUpper()); } if (columna == "localidades") { Localidades = Localidades + v[1].ToUpper() + ";" + v[0].ToUpper() + ";" + v[2].Trim() + "\n"; Com_Loca.Items.Add(v[1] + ";" + v[0].ToUpper() + ";" + v[2].Trim()); } } } } Departamentos = Departamentos + ";\n"; Distritos = Distritos + ";\n"; Localidades = Localidades + ";\n"; if (!Com_Dpto.Items.Contains(";")) Com_Dpto.Items.Add(";"); if (!Com_Dtr.Items.Contains(";")) Com_Dtr.Items.Add(";"); if (!Com_Loca.Items.Contains(";")) Com_Loca.Items.Add(";"); //if (!Com_Bar.Items.Contains(";")) Com_Bar.Items.Add(";"); this.Cursor = Cursors.Default; } private void RadioButton2_CheckedChanged_1(object sender, EventArgs e) { if (RadioButton2.Checked == true) { panel2.Visible = true; this.AcceptButton = button4; TextBox1.Select(); } } public void button5_Click(object sender, EventArgs e) { Close(); } private void button4_Click(object sender, EventArgs e) { this.AcceptButton = button4; Com_Loca_Leave(null, null); if (RadioButton1.Checked == false & RadioButton2.Checked == false) { MessageBox.Show("Marque una opción de lo que desea hacer; Registrar Nuevo o Modificar Registro", "¡ATENCIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox1.Select(); return; } if (TextBox1.Text == "")//RAZÓN SOCIAL { TextBox1.Select(); return; } TextBox1.Text = TextBox1.Text.ToUpper().Trim(); TextBox1.Text = TextBox1.Text.Replace("&", "y"); TextBox1.Text = TextBox1.Text.Replace("'", "`"); TextBox1.Text = TextBox1.Text.Replace(";", ","); TextBox1.Text = TextBox1.Text.Replace("\\", ","); if (Regex.IsMatch(TextBox1.Text, "[^a-zA-Z0-9-/_() .,°áéíóúÁÉÍÓÚñÑ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox1.Select(); return; } if (Txt_Nom_Fantasia.Text == "") { Txt_Nom_Fantasia.Text = " "; Txt_Nom_Fantasia.Select(); return; } Txt_Nom_Fantasia.Text = Txt_Nom_Fantasia.Text.Replace("&", "y"); Txt_Nom_Fantasia.Text = Txt_Nom_Fantasia.Text.Replace("'", "`"); Txt_Nom_Fantasia.Text = Txt_Nom_Fantasia.Text.Replace(";", ","); Txt_Nom_Fantasia.Text = Txt_Nom_Fantasia.Text.Replace("\\", ","); if (Regex.IsMatch(Txt_Nom_Fantasia.Text, "[^a-zA-Z0-9-/_() .,áéíóúÁÉÍÓÚñÑ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Txt_Nom_Fantasia.Select(); return; } if (Opt_P_Fisica.Checked == false && Opt_P_Juridica.Checked == false) { MessageBox.Show("Seleccione el tipo de pesona para este cliente; Jurídica o Física."); return; } if (TextBox2.Text.Trim() == "")//NUMERO DE DOCUMENTO { TextBox2.Select(); return; } if (comb_TipoIden.SelectedIndex == 2) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//PASAPORTE if (comb_TipoIden.SelectedIndex == 3) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//CÉDULA EXTRANJERA if (comb_TipoIden.SelectedIndex == 5) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//CÉDULA DIPLOMÁTICA if (comb_TipoIden.SelectedIndex == 6) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//CÉDULA TRIBUTARIA TextBox2.Text = TextBox2.Text.Replace("&", "y"); TextBox2.Text = TextBox2.Text.Replace("'", "`"); TextBox2.Text = TextBox2.Text.Replace(";", ","); TextBox2.Text = TextBox2.Text.Replace("\\", ","); TextBox2.Text = TextBox2.Text.Replace("|", ","); if (Regex.IsMatch(TextBox2.Text, "[^a-zA-Z0-9-/_() .,áéíóúÁÉÍÓÚñÑ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox2.Select(); return; } if (TextBox2.Text.Trim() == "") { TextBox2.Select(); return; } if (comb_TipoIden.SelectedIndex == 2) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//PASAPORTE if (comb_TipoIden.SelectedIndex == 3) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//CÉDULA EXTRANJERA if (comb_TipoIden.SelectedIndex == 4) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//CÉDULA DIPLOMÁTICA if (comb_TipoIden.SelectedIndex == 5) { TextBox2.Text = TextBox2.Text.Trim() + " "; }//CÉDULA TRIBUTARIA TextBox2.Text = TextBox2.Text.Replace("&", "y"); TextBox2.Text = TextBox2.Text.Replace("'", "`"); TextBox2.Text = TextBox2.Text.Replace(";", ","); TextBox2.Text = TextBox2.Text.Replace("\\", ","); if (Regex.IsMatch(TextBox2.Text, "[^a-zA-Z0-9-/_() .,áéíóúÁÉÍÓÚñÑ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox2.Select(); return; } if (TextBox3.Text == "")//CELULAR Y TELÉFONO { //TextBox3.Text = "0"; TextBox3.Select(); return; } TextBox3.Text = TextBox3.Text.Replace(" ", ";"); TextBox3.Text = TextBox3.Text.Replace(",", ";"); TextBox3.Text = TextBox3.Text.Replace("-", ""); TextBox3.Text = TextBox3.Text.Replace("_", ""); TextBox3.Text = TextBox3.Text.Replace("&", "y"); TextBox3.Text = TextBox3.Text.Replace("'", "`"); TextBox3.Text = TextBox3.Text.Replace("\\", ";"); TextBox3.Text = TextBox3.Text.Replace("|", ";"); if (Regex.IsMatch(TextBox3.Text, "[^a-zA-Z0-9-/_() .,;áéíóúÁÉÍÓÚñÑ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox3.Select(); return; } if (TextBox4.Text == "")//CALLE Y NÚM DE CASA { //TextBox4.Text = ";"; TextBox4.Select(); return; } TextBox4.Text = TextBox4.Text.ToUpper().Trim(); TextBox4.Text = TextBox4.Text.Replace(",", ";"); TextBox4.Text = TextBox4.Text.Replace(":", ";"); TextBox4.Text = TextBox4.Text.Replace("|", "/"); TextBox4.Text = TextBox4.Text.Replace("&", "y"); TextBox4.Text = TextBox4.Text.Replace("'", "`"); TextBox4.Text = TextBox4.Text.Replace("\\", "/"); if (Regex.IsMatch(TextBox4.Text, "[^a-zA-Z0-9-/_() .,;ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); TextBox4.Select(); return; } try { string[] v; v = TextBox4.Text.Split(';'); string a = v[1]; } catch { MessageBox.Show("Debe escribir un número de casa desdepues de la calle, separado por PUNTO Y COMA \";\".\n\nEjemplo: \"Juan E. Oleary;1200\""); TextBox4.Select(); return; } if (Com_Pais.Text == "")//PAIS { Com_Pais.Select(); return; } Com_Pais.Text = Com_Pais.Text.ToUpper().Trim(); Com_Pais.Text = Com_Pais.Text.Replace(",", ";"); Com_Pais.Text = Com_Pais.Text.Replace("|", "/"); Com_Pais.Text = Com_Pais.Text.Replace("&", "y"); Com_Pais.Text = Com_Pais.Text.Replace("'", "`"); Com_Pais.Text = Com_Pais.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Pais.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Pais.Select(); return; } if (Com_Dpto.Text == "")//DEPARTAMENTO { //Com_Dpto.Text = ";"; Com_Dpto.Select(); return; } Com_Dpto.Text = Com_Dpto.Text.ToUpper().Trim(); Com_Dpto.Text = Com_Dpto.Text.Replace(",", ";"); Com_Dpto.Text = Com_Dpto.Text.Replace("|", "/"); Com_Dpto.Text = Com_Dpto.Text.Replace("&", "y"); Com_Dpto.Text = Com_Dpto.Text.Replace("'", "`"); Com_Dpto.Text = Com_Dpto.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Dpto.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Dpto.Select(); return; } if (Com_Dtr.Text == "")//DISTRITO { //Com_Dtr.Text = ";"; Com_Dtr.Select(); return; } Com_Dtr.Text = Com_Dtr.Text.ToUpper().Trim(); Com_Dtr.Text = Com_Dtr.Text.Replace(",", ";"); Com_Dtr.Text = Com_Dtr.Text.Replace("|", "/"); Com_Dtr.Text = Com_Dtr.Text.Replace("&", "y"); Com_Dtr.Text = Com_Dtr.Text.Replace("'", "`"); Com_Dtr.Text = Com_Dtr.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Dtr.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Dtr.Select(); return; } if (Com_Loca.Text == "")//LOCALIDAD { //Com_Loca.Text = ";"; Com_Loca.Select(); return; } Com_Loca.Text = Com_Loca.Text.ToUpper().Trim(); Com_Loca.Text = Com_Loca.Text.Replace(",", ";"); Com_Loca.Text = Com_Loca.Text.Replace("|", "/"); Com_Loca.Text = Com_Loca.Text.Replace("&", "y"); Com_Loca.Text = Com_Loca.Text.Replace("'", "`"); Com_Loca.Text = Com_Loca.Text.Replace("\\", ";"); if (Regex.IsMatch(Com_Loca.Text, "[^a-zA-Z0-9-/_() .,;:ÅáéíóúÁÉÍÓÚñѰ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Com_Loca.Select(); return; } if (Txt_Email.Text == "")//EMAIL { Txt_Email.Text = " "; Txt_Email.Select(); return; } Txt_Email.Text = Txt_Email.Text.ToLower().Trim(); Txt_Email.Text = Txt_Email.Text.Replace(",", ";"); Txt_Email.Text = Txt_Email.Text.Replace(" ", ""); Txt_Email.Text = Txt_Email.Text.Replace("'", ""); ////valida correo //IsValidEmail(Txt_Email.Text); //if (!IsValidEmail(Txt_Email.Text)) //{ // MessageBox.Show("El correo electrónico no es válido."); // Txt_Email.Select(); // return; //} if (TextBox2.TextLength < 3) { TextBox2.Text = "X"; } Txt_Nom_Fantasia.Text = Txt_Nom_Fantasia.Text.ToUpper().Trim(); string TP; if (Opt_P_Juridica.Checked == true) { TP = "2"; } else { TP = "1"; } ApuntoReg = 1; TextBox4.Text = Com_Pais.Text + "; " + Com_Dpto.Text + "; " + Com_Dtr.Text + "; " + Com_Loca.Text + "; " + TextBox4.Text; this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_update.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}▼{2}▼{3}▼{4}▼{5}▼{6}▼{7}", TextBox1.Text, Txt_Nom_Fantasia.Text, TP, TextBox2.Text, TextBox3.Text, TextBox4.Text, Txt_Email.Text, ID_LABEL.Text)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string[] c = devuelve.Split('▲'); this.Cursor = Cursors.Default; string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains("ERROR"); if (re == true) { MessageBox.Show(devuelve); return; } MessageBox.Show(devuelve); //MessageBox.Show(TextBox1.Text + " se modificó con éxito.", "Está hecho", MessageBoxButtons.OK, MessageBoxIcon.Information); LIMPIAR(); TextBox1.Select(); } private void Cobrar_ch_CheckedChanged_1(object sender, EventArgs e) { if (Cobrar_ch.Checked == true) { TituloP.Text = Pagar_ch.Text; this.AcceptButton = TituloP; valorD.Select(); } } private void Pagar_ch_CheckedChanged_1(object sender, EventArgs e) { if (Pagar_ch.Checked == true) { TituloP.Text = Pagar_ch.Text; this.AcceptButton = TituloP; valorD.Select(); } } private void Saldo_Click(object sender, EventArgs e) { } private void Saldo_TabIndexChanged(object sender, EventArgs e) { } private void TituloP_Click(object sender, EventArgs e) { this.AcceptButton = TituloP; if (valorD.Text == "") { valorD.Select(); return; } if (Concepto_box.Text == "") { Concepto_box.Select(); return; } Concepto_box.Text = Concepto_box.Text.Replace("&", "y"); Concepto_box.Text = Concepto_box.Text.Replace("'", "`"); Concepto_box.Text = Concepto_box.Text.Replace(";", ","); Concepto_box.Text = Concepto_box.Text.Replace("\\", ","); if (Regex.IsMatch(Concepto_box.Text, "[^a-zA-Z0-9-/_() .,áéíóúÁÉÍÓÚñÑ`]")) { MessageBox.Show("En el campo escrito existe caracter especial no admitido. Reemplace y vuelva a presionar ENTER.", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); Concepto_box.Select(); return; } Principal fp = new Principal(); Global.ID_cliente = int.Parse(ID_LABEL.Text); Global.valorPago = double.Parse(valorD.Text); Global.monto = string.Format("{0:#,##0.##}", double.Parse(valorD.Text)); Global.RazonS = TextBox1.Text; Global.RUC = TextBox2.Text; Global.DIRECCION_F = TextBox4.Text; Global.Cobrar = Cobrar_ch.Checked; Global.concepto = Concepto_box.Text.ToUpper(); //FECHA DateTime fecha = DateTime.Now; string fechax = fecha.ToString("yyyy-MM-dd"); //HORA DateTime hora = DateTime.Now; string horax = hora.ToString("HH:mm:ss"); // string NUM_FACTx = DateTime.Now.ToString("ddMMyy") + DateTime.Now.ToString("HHmmss"); Global.NUM_FACT = DateTime.Now.ToString("ddMMyy") + DateTime.Now.ToString("HHmmss"); //Clientes fc = new Clientes(); if (Global.Cobrar == true)//SI ES COBRAR { Global.in_o_egr = 0; this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_cobrar.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}▼{2}▼{3}▼{4}▼{5}▼{6}▼{7}▼{8}▼{9}▼{10}", Global.ID_cliente, Global.NUM_caja, fechax, horax, Global.concepto + " - " + fecha, ((Global.valorPago) - Global.valorPago * 2), Global.USUARIO_SIST, Global.RazonS, Global.RUC, Global.DIRECCION_F, Global.NUM_FACT)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string[] c = devuelve.Split('▲'); this.Cursor = Cursors.Default; if (c[0].Length > 100) { MessageBox.Show(devuelve); return; } } else//SI ES PAGAR { Global.in_o_egr = 1; this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_pagar.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}▼{2}▼{3}▼{4}▼{5}▼{6}▼{7}▼{8}▼{9}▼{10}", Global.ID_cliente, Global.NUM_caja, fechax, horax, Global.concepto.ToUpper(), Global.valorPago, Global.USUARIO_SIST, Global.RazonS, Global.RUC, Global.DIRECCION_F, Global.NUM_FACT)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string[] c = devuelve.Split('▲'); this.Cursor = Cursors.Default; if (c[0].Length > 100) { MessageBox.Show(devuelve); return; } MessageBox.Show(devuelve); } string Telefono = ""; if (TextBox3.TextLength > 8) { if (TextBox3.TextLength < 12)//SI NO ES FORMATO INTERNACONAL { Telefono = Global.Tel_WhatsApp.Substring(0, 3) + TextBox3.Text; } else//SI ES FORMATO INTERNACONAL { Telefono = TextBox3.Text; } } // CUANDO SE LE COBRA AL CLIENTE if (Cobrar_ch.Checked == true) { //WHATSAPP AL CLIENTE fp.EnviarWhatsApp(Global.ID_WhatsApp, "Estimad@\n*" + TextBox1.Text.Trim() + "*\n\nAgradecemos su pago de \n*" + Global.SIMB_ + " " + double.Parse(valorD.Text).ToString("#,##0.##") + ".-* En concepto de " + Concepto_box.Text + ".\n\nAtentemente,\n*_" + Global.Nom_EMPRESA + "_*\nCaja " + Global.NUM_caja + ": " + Global.USUARIO_SIST + "\n" + Global.Tel_EMPRESA + "\n\n_*NO RESPONDER.* Este es un mensaje automático. Si desea puede ponerse en contacto a través del teléfono de la empresa._", Telefono); fp.Espera(1);//segundos //WATSAPP AL ADMINISTRADOR fp.EnviarWhatsApp(Global.ID_WhatsApp, "El/la Cliente\n*" + TextBox1.Text.Trim() + "*\n\nRealizó un pago de \n*" + Global.SIMB_ + " " + double.Parse(valorD.Text).ToString("#,##0.##") + ".-* En concepto de " + Concepto_box.Text + ".\n\nRecibido en\n*_" + Global.Nom_EMPRESA + "_*\nCaja " + Global.NUM_caja + ": " + Global.USUARIO_SIST + "\n" + Global.Tel_EMPRESA, Global.Tel_WhatsApp); fp.Espera(1);//segundos } // CUANDO SE SUMA A LA CUENTA DEL CLIENTE if (Pagar_ch.Checked == true) { //WHATSAPP AL CLIENTE fp.EnviarWhatsApp(Global.ID_WhatsApp, "Estimad@\n*" + TextBox1.Text.Trim() + "*\n\nSumamos a su cuenta el monto de \n*" + Global.SIMB_ + " " + double.Parse(valorD.Text).ToString("#,##0.##") + ".-* En concepto de " + Concepto_box.Text + ".\n\nAtentemente,\n*_" + Global.Nom_EMPRESA + "_*\nCaja " + Global.NUM_caja + ": " + Global.USUARIO_SIST + "\n" + Global.Tel_EMPRESA + "\n\n_*NO RESPONDER.* Este es un mensaje automático. Si desea puede ponerse en contacto a través del teléfono de la empresa._", Telefono); fp.Espera(1);//segundos //WATSAPP AL ADMINISTRADOR fp.EnviarWhatsApp(Global.ID_WhatsApp, "El/la Cliente\n*" + TextBox1.Text.Trim() + "*\n\nSumó a su cuenta el monto de \n*" + Global.SIMB_ + " " + double.Parse(valorD.Text).ToString("#,##0.##") + ".-* En concepto de " + Concepto_box.Text + ".\n\nOperación Realizada en\n*_" + Global.Nom_EMPRESA + "_*\nCaja " + Global.NUM_caja + ": " + Global.USUARIO_SIST + "\n" + Global.Tel_EMPRESA, Global.Tel_WhatsApp); fp.Espera(1);//segundos } this.Close(); pdf_mostrar_reciboP mR = new pdf_mostrar_reciboP(); mR.Mostrar_reciboP_pdf(); } private void button6_Click_1(object sender, EventArgs e) { //mensaje_lab.Top= Label6.Top +12; //mensaje_lab.Left= Label6.Left+12; mensaje_lab.Visible=true; mensaje_lab.Refresh(); this.Cursor= Cursors.WaitCursor; button6.Enabled=false; Global.fecha_desdex = string.Format("{0:yyyy-MM-dd}", Fdesde.Value); Global.fecha_hastax = string.Format("{0:yyyy-MM-dd}", Fhasta.Value); Global.ID_cliente = int.Parse(ID_LABEL.Text); Global.RazonS = TextBox1.Text; Global.RUC = TextBox2.Text; Global.TotalRp = 0; Saldo.Text = ""; pdf_ReportCLI pdf_repCLI = new pdf_ReportCLI(); pdf_repCLI.Mostrar_ReportCLI_pdf(); mensaje_lab.Visible=false; mensaje_lab.Refresh(); button6.Enabled=true; this.Cursor= Cursors.Default; } private void valorD_TextChanged_1(object sender, EventArgs e) { valorD.Text = valorD.Text.Replace(",", "."); this.AcceptButton = TituloP; } private void button7_Click_1(object sender, EventArgs e) { if (Global.SALDO_CLI < 1) { MessageBox.Show("Cliente sin deuda."); return; } Principal principal = new Principal(); string Telefono = ""; if (TextBox3.TextLength > 8) { if (TextBox3.TextLength < 12)//SI NO ES FORMATO INTERNACONAL { Telefono = Global.Tel_WhatsApp.Substring(0, 3) + TextBox3.Text; } else//SI ES FORMATO INTERNACIONAL { Telefono = TextBox3.Text; } } if (Saldo.Visible) { if (TextBox3.TextLength < 9) { return; } string saldox = Saldo.Text.Replace("Saldo Total ", ""); principal.EnviarWhatsApp(Global.ID_WhatsApp,"Estimad@\n*" + TextBox1.Text.Trim() + "*\n\nSu deuda actual es de *" + saldox + ".-*\nRogamos que abone lo antes posible.\n\nAtentemente,\n*_" + Global.Nom_EMPRESA + "_*\n" + Global.Tel_EMPRESA + "\n\n_*NO RESPONDER.* Este es un mensaje automático. Si desea puede ponerse en contacto a través del teléfono de la empresa._", Telefono); principal.Espera(1);//segundos } } private void TextBox3_TextChanged_1(object sender, EventArgs e) { //try //{ // double d = double.Parse(TextBox3.Text); //} //catch { MessageBox.Show("En número y sin espacio, por favor."); TextBox3.Text = ""; } TextBox3.Text = TextBox3.Text.Replace(" ", ""); TextBox3.SelectionStart= TextBox3.TextLength+1; } private void button8_Click_1(object sender, EventArgs e) { string[] v; v = TextBox3.Text.Split(';'); CampaWhats campaWhats = new CampaWhats(); campaWhats.NumSolo.Text = v[0].Trim(); campaWhats.Tel = v[0].Trim(); campaWhats.Nombre = TextBox1.Text.Trim(); if (v[0].Trim().Length > 9) { campaWhats.Solo_Este.Text = "Se enviará sólo al " + v[0].Trim(); } else { campaWhats.Solo_Este.Text = "Se enviará a todos los contactos"; } //campaWhats.Solo_Este.Text = "Enviar sólo al " + v[0].Trim(); campaWhats.ShowDialog(); } private void TextBox2_TextChanged_1(object sender, EventArgs e) { Lb_DV.Text = ""; Lb_RUC_Cancel.ForeColor = Color.Green; Lb_RUC_Cancel.Text = ""; var v = TextBox2.Text.Split('-'); try { if (v[1].Length > 1) { TextBox2.Text = ""; } if (TextBox2.Text.Substring(TextBox2.Text.Length - 2, 2) == "--") { TextBox2.Text = ""; } } catch { } if (Regex.IsMatch(TextBox2.Text, "[^A-Za-z0-9- ]"))// if (Regex.IsMatch(RUC_TBox.Text, "[^A-Za-z0-9- ]")) { TextBox2.Text = ""; TextBox2.Select(); return; } if (TextBox2.Text.Length < 3) { comb_TipoIden.Text = ""; Lb_DV.Text = ""; return; } else { ConsultarRUC(); } if (TextBox2.Text.Length < 5) return; if (TextBox2.Text.Substring(TextBox2.Text.Length - 2, 1) == "-") { if (comb_TipoIden.Items.Count > 0) { comb_TipoIden.SelectedIndex = 0;//RUC } } else { comb_TipoIden.SelectedIndex = 1;} if (TextBox2.Text.Substring(TextBox2.Text.Length - 4, 4).ToString().Trim().Length == 0) { comb_TipoIden.SelectedIndex = 2;//PASAPORTE } if (TextBox2.Text.Substring(TextBox2.Text.Length - 4, 4).ToString().Trim().Length == 1) { comb_TipoIden.SelectedIndex = 3;//IDEN. EXTRANJERA } if (TextBox2.Text.Substring(TextBox2.Text.Length - 4, 4).ToString().Trim().Length == 2) { comb_TipoIden.SelectedIndex = 4;//IDEN. DIPLOMÁTICA } if (TextBox2.Text.Substring(TextBox2.Text.Length - 4, 4).ToString().Trim().Length == 3) { comb_TipoIden.SelectedIndex = 5;//IDEN. TRIBUTARIA } } public void ConsultarRUC() { try { int i = int.Parse(TextBox2.Text); } catch { return; } if (TextBox2.Text.Trim() == "") { return; } string archivo = "ruc" + TextBox2.Text.Trim().Substring(TextBox2.Text.Trim().Length - 1, 1) + ".txt"; try { HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(Global._host_serv + "/api/c_sharp.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}", archivo, TextBox2.Text)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string[] c = devuelve.Split('▲'); this.Cursor = Cursors.Default; //MessageBox.Show(devuelve); if (devuelve != "") { //foreach (var line in devuelve.Trim().Split('↔')) { var v = devuelve.Trim().Split('|'); if (v[0] != "") { if (v[4] == "CANCELADO") { Lb_RUC_Cancel.ForeColor= Color.Red; Lb_RUC_Cancel.Text = "Estado: " + v[4]; } else { if(RadioButton1.Checked==true) TextBox1.Text = v[1]; Lb_DV.Text = v[2]; Lb_RUC_Cancel.ForeColor = Color.Green; Lb_RUC_Cancel.Text = "Estado: " + v[4]; } } } } } catch { } } private void Lb_DV_Click(object sender, EventArgs e) { } private void Btn_Cerrar_Click(object sender, EventArgs e) { Close(); } private void comb_TipoIden_SelectedIndexChanged(object sender, EventArgs e) { } private void TextBox4_TextChanged(object sender, EventArgs e) { try { if(ApuntoReg == 0) { if (Com_Pais.Text.Trim() == "PRY;PARAGUAY") { //if (TextBox4.Text != "PRY;PARAGUAY; ;; ;; ;; ;") { string[] v; v = TextBox4.Text.Split(';'); string a = v[2]; string s = TextBox4.Text; if (v[2] == "") { //MessageBox.Show("No corresponde. Sólo se pueden registrar dos campos, separados por PUNTO Y COMA \":\".\n\nEjemplo: \"Umaita casi Lomas bonitas;1450\""); TextBox4.Text = TextBox4.Text.Substring(0, TextBox4.Text.Length - 1); } if (v[2] != "") { TextBox4.Text = TextBox4.Text.Substring(0, TextBox4.Text.Length - 1); Com_Dpto.Text = ";"; Com_Dtr.Text = ";"; Com_Loca.Text = ";"; } } } } } catch { } } private void Fdesde_ValueChanged(object sender, EventArgs e) { } private void No_Buscar_CheckedChanged(object sender, EventArgs e) { } private void Txt_Nom_Fantasia_TextChanged(object sender, EventArgs e) { } private void label10_Click(object sender, EventArgs e) { } private void Lb_DV_Click_1(object sender, EventArgs e) { } private void Lb_DV_DoubleClick_1(object sender, EventArgs e) { if (TextBox2.Text.Substring(TextBox2.Text.Length - 2, 1) != "-") { TextBox2.Text = TextBox2.Text + "-" + Lb_DV.Text; } } private void Com_Dpto_SelectedIndexChanged(object sender, EventArgs e) { string[] v; v= Com_Dpto.Text.Split(';'); string Cod=v[1]; Com_Dtr.Items.Clear(); Com_Dtr.Text = ""; CargarCombos("distritos",Cod); Lab_Descrip.Text = "Departamento: " + Com_Dpto.Text; } private void Com_Dpto_Click(object sender, EventArgs e) { } private void Com_Dtr_SelectedIndexChanged(object sender, EventArgs e) { string[] v; v = Com_Dtr.Text.Split(';'); string Cod = v[1]; Com_Loca.Items.Clear(); Com_Loca.Text = ""; CargarCombos("localidades", Cod); Lab_Descrip.Text = "Distrito: " + Com_Dtr.Text; } private void Com_Loca_SelectedIndexChanged(object sender, EventArgs e) { //string[] v; //v = Com_Loca.Text.Split(';'); //string Cod = v[1]; //Com_Bar.Items.Clear(); //Com_Bar.Text = ""; //CargarCombos("barrios", Cod); Lab_Descrip.Text = "Localidad: " + Com_Loca.Text; } private void Com_Bar_SelectedIndexChanged(object sender, EventArgs e) { //Lab_Descrip.Text = "Barrio: " + Com_Bar.Text; } private void Com_Dpto_TextChanged(object sender, EventArgs e) { //Com_Dpto.Text = ""; } private void Com_Dtr_TextChanged(object sender, EventArgs e) { //Com_Dtr.Text = ""; } private void Com_Loca_TextChanged(object sender, EventArgs e) { //Com_Loca.Text = ""; } private void Com_Bar_TextChanged(object sender, EventArgs e) { //Com_Bar.Text = ""; } private void Com_Dpto_Leave(object sender, EventArgs e) { if (!Departamentos.Contains(Com_Dpto.Text.Trim() + "\n")) { Com_Dpto.Text = ""; Lab_Descrip.Text = "<>"; Com_Dpto.Select(); } } private void label11_Click(object sender, EventArgs e) { } private void Com_Dtr_Leave(object sender, EventArgs e) { if (!Distritos.Contains(Com_Dtr.Text.Trim() + "\n")) { Com_Dtr.Text = ""; Lab_Descrip.Text = "<>"; Com_Dtr.Select(); } } private void Com_Loca_Leave(object sender, EventArgs e) { if (!Localidades.Contains(Com_Loca.Text.Trim() + "\n")) { Com_Loca.Text = ""; Lab_Descrip.Text = "<>"; Com_Loca.Select(); return; } Lab_Descrip.Text = ""; } private void Com_Bar_Leave(object sender, EventArgs e) { //if (!Barrios.Contains(Com_Bar.Text.Trim() + "\n")) //{ // Com_Bar.Text = ""; // Lab_Descrip.Text = "<>"; // Com_Bar.Select(); // return; //} //Lab_Descrip.Text = ""; } private void Clientes_Shown(object sender, EventArgs e) { Com_Dpto.Items.Clear(); Com_Pais.Items.Clear(); CargarCombos("departamentos", ""); PaisesCargar(); } private void Com_Pais_SelectedIndexChanged(object sender, EventArgs e) { Lab_Descrip.Text = "País: " + Com_Pais.Text; if (Com_Pais.Text != "PRY;PARAGUAY") { Com_Dpto.Text = ";"; Com_Dtr.Text = ";"; Com_Loca.Text = ";"; //Com_Bar.Text = ";"; Com_Dpto.Enabled = false; Com_Dpto.Enabled = false; Com_Dtr.Enabled = false; Com_Loca.Enabled = false; //Com_Bar.Enabled = false; } else { Com_Dpto.Enabled = true; Com_Dpto.Enabled = true; Com_Dtr.Enabled = true; Com_Loca.Enabled = true; //Com_Bar.Enabled = true; } } private void Com_Pais_Leave(object sender, EventArgs e) { if (!Paises.Contains(Com_Pais.Text.Trim() + "\n")) { Com_Pais.Text = ""; Lab_Descrip.Text = "<>"; Com_Pais.Select(); } } private void panel1_Paint(object sender, PaintEventArgs e) { } private void TextBox2_Leave(object sender, EventArgs e) { TextBox2_TextChanged_1(null,null); if(Lb_RUC_Cancel.Text!="Estado: CANCELADO") { if (Lb_DV.Text != "") { var v = TextBox2.Text.Split('-'); try { string a = v[1]; } catch { TextBox2.Text = TextBox2.Text + "-" + Lb_DV.Text; } } } } public bool IsValidEmail(string email) { const string pattern = @"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*" + "@" + @"((([\-\w]+\.)+[a-zA-Z]{2,})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$"; return Regex.IsMatch(email, pattern); } private void Txt_Email_TextChanged(object sender, EventArgs e) { } } public class pdf_mostrar_reciboP { public object Mostrar_reciboP_pdf() { //CREAR PDF string pdfgenerate = "\\DOC_PDF\\RECIBOS_PDF\\CLIENTES\\" + Global.NUM_FACT + "_RECIBO.pdf"; Document oDoc; PdfWriter pdfw; PdfContentByte cb; float top1; //PREPARA EL PDF oDoc = new Document(PageSize.A4, 30, 20, 20, 20); pdfw = PdfWriter.GetInstance(oDoc, new FileStream(pdfgenerate, FileMode.Create, FileAccess.Write, FileShare.None)); pdfw.CompressionLevel = PdfStream.BEST_COMPRESSION; pdfw.SetFullCompression(); oDoc.Open(); oDoc.NewPage(); top1 = oDoc.PageSize.Top; cb = pdfw.DirectContent;//DEBE IR ANTES DE LAS LÍNEAS DE TEXTO // Creamos un titulo personalizado con tamaño de fuente 18 y color Azul Paragraph title = new Paragraph(); title.Font = FontFactory.GetFont(FontFactory.TIMES, 18f, BaseColor.BLACK); title.Add("* RECIBO DE DINERO * "); oDoc.Add(title); // Agregamos un parrafo vacio como separacion. oDoc.Add(new Paragraph(" ")); //COLOR Y TIPO DE FUENTE cb.SetColorFill(BaseColor.BLACK); cb.SetFontAndSize(BaseFont.CreateFont(@"arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED), 12); NumLet NumLet = new NumLet(); string enletras = NumLet.enletras(Global.monto); PdfPTable table = new PdfPTable(1); table.WidthPercentage = 100; table.DefaultCell.BorderColor = new BaseColor(128, 128, 128); table.AddCell("Número " + Global.NUM_FACT); table.AddCell("Fecha " + DateTime.Now.ToString()); table.AddCell("Son " + Global.SIMB_ + " " + string.Format("{0:#,##0.##}", double.Parse(Global.monto)) + ".--------------------"); if (Global.in_o_egr == 0) //SI ES UN INGRESO (EL CLIENTE PAGA) { table.AddCell("Recibí de " + Global.RazonS.ToUpper()); } if (Global.in_o_egr == 1) //SI ES UN EGRESO (EL CLIENTE COBRA) { table.AddCell("Recibí de " + Global._nom_empresa + " (" + Global.USUARIO_SIST.ToUpper() + ")"); } table.AddCell("La cantidad de " + Global.SIMB_ + " " + enletras + ".--------------------"); table.AddCell("En concepto de " + Global.concepto.ToUpper() + "."); table.AddCell(" "); if (Global.in_o_egr == 0)//SI ES UN INGRESO (PAGO) { table.AddCell("Firma del/la responsable de " + Global._nom_empresa + " (" + Global.USUARIO_SIST.ToUpper() + ")"); } if (Global.in_o_egr == 1)//SI ES UN INGRESO (PAGO) { table.AddCell("Firma: " + Global.RazonS.ToUpper()); } oDoc.Add(table); pdfw.Flush(); oDoc.Close(); System.Diagnostics.Process.Start(@pdfgenerate);//MUESTRA EL RECIBO EN PDF return (null); } } public class pdf_ReportCLI { public object Mostrar_ReportCLI_pdf() { //Rep_ventas cf = new Rep_ventas(); //using (MySqlConnection Conex = new MySqlConnection(string.Format("Server={0};Database={1};Uid={2};Pwd={3};Port={4};", Global._host, Global._base, Global._usuario, Global._pass, Global._port))) { //Conex.Open(); //CREAR PDF string pdfgenerate = "\\DOC_PDF\\REPORTE.pdf"; Document oDoc; PdfWriter pdfw; PdfContentByte cb; float top1; //PREPARA EL PDF oDoc = new Document(PageSize.A4, 30, 20, 20, 20); pdfw = PdfWriter.GetInstance(oDoc, new FileStream(pdfgenerate, FileMode.Create, FileAccess.Write, FileShare.None)); pdfw.CompressionLevel = PdfStream.BEST_COMPRESSION; pdfw.SetFullCompression(); oDoc.Open(); oDoc.NewPage(); top1 = oDoc.PageSize.Top; try { //ENCABEZADO LOGO (usado en reportes) iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance("logo.png", true); logo.CompressionLevel = PdfStream.NO_COMPRESSION; //logo.SetAbsolutePosition(60, top1 - 130); oDoc.Add(logo); } catch (Exception) { } cb = pdfw.DirectContent;//DEBE IR ANTES DE LAS LÍNEAS DE TEXTO //EL TÍTULO Paragraph title = new Paragraph(); title.Font = FontFactory.GetFont(FontFactory.TIMES, 10f, BaseColor.BLACK); title.Add("REPORTE Ventas a Crédito, Cliente: " + Global.RazonS + ", RUC: " + Global.RUC + ". \nDesde el " + string.Format("{0:dd-MM-yyyy}", DateTime.Parse(Global.fecha_desdex)) + ", hasta el " + string.Format("{0:dd-MM-yyyy}", DateTime.Parse(Global.fecha_hastax)) + "\nGenerador por " + Global.USUARIO_SIST + " - Caja " + Global.NUM_caja + " - Fecha: " + DateTime.Now.ToString()); ; ; ; title.Alignment = Element.ALIGN_LEFT; oDoc.Add(title); PdfPTable table = new PdfPTable(6);//TABLA CON 6 CELDAS //TEXTO QUE IRÁ DENTRO DE LA TABLA DEL ENCABEZADO Paragraph TEXTO_T0 = new Paragraph(); TEXTO_T0.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); TEXTO_T0.Add("COMPROBANTE"); Paragraph TEXTO_T1 = new Paragraph(); TEXTO_T1.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); TEXTO_T1.Add("FECHA"); Paragraph TEXTO_T2 = new Paragraph(); TEXTO_T2.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); TEXTO_T2.Add("HORA"); Paragraph TEXTO_T3 = new Paragraph(); TEXTO_T3.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); TEXTO_T3.Add("DESCRIPCION"); Phrase Titulo4 = new Phrase("MONTO", FontFactory.GetFont(FontFactory.TIMES, 9, BaseColor.BLACK)); PdfPCell TEXTO_T4 = new PdfPCell(Titulo4); TEXTO_T4.HorizontalAlignment = Element.ALIGN_RIGHT; TEXTO_T4.BackgroundColor = new BaseColor(224, 255, 255); Phrase Titulo5 = new Phrase("USUARIO", FontFactory.GetFont(FontFactory.TIMES, 9, BaseColor.BLACK)); PdfPCell TEXTO_T5 = new PdfPCell(Titulo5); TEXTO_T5.HorizontalAlignment = Element.ALIGN_RIGHT; TEXTO_T5.BackgroundColor = new BaseColor(224, 255, 255); table.HorizontalAlignment = 0; table.TotalWidth = 545f;//MEDIDA TOTAL DE LA TABLA table.LockedWidth = true; float[] widths = new float[] { 75f, 50f, 30f, 240f, 55f, 95f };//MEDIDAS DE COLUMNAS table.SetWidths(widths); //table.WidthPercentage = 100; table.DefaultCell.BackgroundColor = new BaseColor(224, 255, 255); table.DefaultCell.BorderColor = new BaseColor(0, 0, 0);//125,125,255 table.AddCell(TEXTO_T0); table.AddCell(TEXTO_T1); table.AddCell(TEXTO_T2); table.AddCell(TEXTO_T3); table.AddCell(TEXTO_T4); table.AddCell(TEXTO_T5); table.DefaultCell.BackgroundColor = new BaseColor(255, 255, 255); //SQLiteDataReader RS = null; //string POR_OPER = "SELECT NUM_FACT,FECHA,HORA,DESCRIPCION,SUM(VENTA*CANT) MONTO,USUARIO FROM CREDITO WHERE FECHA>= '" + Global.fecha_desdex + "' AND FECHA<= '" + Global.fecha_hastax + "' AND ID_CLIENTE= " + Global.ID_cliente + " GROUP BY NUM_FACT,FECHA,HORA,DESCRIPCION,USUARIO;"; //SQLiteCommand CMD_POR_OPER = new SQLiteCommand(POR_OPER, arreglar); //RS = CMD_POR_OPER.ExecuteReader(); HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_reporte.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}▼{2}", Global.fecha_desdex, Global.fecha_hastax, Global.ID_cliente)); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string[] c = devuelve.Split('▲'); string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains("ERROR"); if (re == true) { MessageBox.Show(devuelve); } if (devuelve != "") { foreach (var line in devuelve.Split('↔')) { var v = line.Split('▲'); if (v[0] != "") { Paragraph factura = new Paragraph(); factura.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); factura.Add(v[0]); Paragraph fecha = new Paragraph(); fecha.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); fecha.Add(string.Format("{0:dd-MM-yyyy}", DateTime.Parse(v[1]))); Paragraph hora = new Paragraph(); hora.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); hora.Add(string.Format("{0:HH:mm}", DateTime.Parse(v[2]))); Paragraph descrip = new Paragraph(); descrip.Font = FontFactory.GetFont(FontFactory.TIMES, 9f, BaseColor.BLACK); descrip.Add(v[3]); Phrase Conte4 = new Phrase(string.Format("{0:#,##0.##}", double.Parse(v[4])), FontFactory.GetFont(FontFactory.TIMES, 9, BaseColor.BLACK)); PdfPCell montoG = new PdfPCell(Conte4); montoG.HorizontalAlignment = Element.ALIGN_RIGHT; montoG.BackgroundColor = new BaseColor(255, 255, 255); montoG.BorderColor = new BaseColor(211, 211, 211);//125,125,255 Phrase Conte6 = new Phrase(v[5], FontFactory.GetFont(FontFactory.TIMES, 9, BaseColor.BLACK)); PdfPCell oper = new PdfPCell(Conte6); oper.HorizontalAlignment = Element.ALIGN_RIGHT; oper.BackgroundColor = new BaseColor(255, 255, 255); oper.BorderColor = new BaseColor(211, 211, 211);//125,125,255 //table.WidthPercentage = 100; table.DefaultCell.BorderColor = new BaseColor(211, 211, 211);//125,125,255 table.AddCell(factura); table.AddCell(fecha); table.AddCell(hora); table.AddCell(descrip); table.AddCell(montoG); table.AddCell(oper); Global.TotalRp = Global.TotalRp + double.Parse(v[4]); } } } //TOTAL DE VENTA QUE SALE EN LA CABECERA Paragraph title2 = new Paragraph(); title2.Font = FontFactory.GetFont(FontFactory.COURIER_BOLD, 14f, BaseColor.BLUE); title2.Add("Total " + Global.SIMB_ + " " + string.Format("{0:#,##0.##}", Global.TotalRp)); title2.Alignment = Element.ALIGN_RIGHT; oDoc.Add(title2); //PARRAFO VACÍO COMO SEPARADOR Paragraph title3 = new Paragraph(); title3.Font = FontFactory.GetFont(FontFactory.TIMES, 2, BaseColor.BLACK); title3.Add("."); title3.Alignment = Element.ALIGN_LEFT; oDoc.Add(title3); oDoc.Add(table); //RS.Close(); pdfw.Flush(); oDoc.Close(); System.Diagnostics.Process.Start(@pdfgenerate);//MUESTRA EL REPORTE EN PDF //Conex.Close(); } return (null); } } }