using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SQLite; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; namespace CKUERA { public partial class FacturaNum : Form { public FacturaNum() { InitializeComponent(); } private void FacturaNum_Load(object sender, EventArgs e) { Ventas ventas = new Ventas(); ventas.GeneraNumFactura(); textBox1.Text= int.Parse(Global.num_esta).ToString("000"); textBox2.Text = int.Parse(Global.NUM_caja).ToString("000"); textBox3.Text = Global.NUM_FACT.Substring(8,7); textBox3.SelectAll(); } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { textBox1.Select(); return; } if (textBox1.TextLength>3) { MessageBox.Show("El campo no debe tener más que 3 dígitos."); textBox1.SelectAll(); return; } if (Regex.IsMatch(textBox1.Text, "[^0-9`]")) { textBox1.Text = ""; textBox1.Select(); return; } if (textBox2.Text == "") { textBox2.Select(); return; } if (textBox2.TextLength > 3) { MessageBox.Show("El campo no debe tener más que 3 dígitos."); textBox2.SelectAll(); return; } if (Regex.IsMatch(textBox2.Text, "[^0-9`]")) { textBox2.Text = ""; textBox2.Select(); return; } if (textBox3.Text == "") { textBox3.Select(); return; } if (textBox3.TextLength > 7) { MessageBox.Show("El campo no debe tener más que 7 dígitos."); textBox3.SelectAll(); return; } if (Regex.IsMatch(textBox3.Text, "[^0-9`]")) { textBox3.Text = ""; textBox3.Select(); return; } Global.RegistrarLV=1; Global.NUM_FACT= textBox1.Text.Trim() + "-" + textBox2.Text.Trim() + "-" + textBox3.Text.Trim(); int NewNum = int.Parse(textBox3.Text); string SQLFACT = "UPDATE CONFIG" + Global.NUM_caja + " SET NUM_FACT='"+ NewNum.ToString() + "';"; SQLiteCommand CMD_NF = new SQLiteCommand(SQLFACT, Global.conexion); CMD_NF.ExecuteNonQuery(); this.Close(); } private void textBox1_TextChanged(object sender, EventArgs e) { } } }