using CKUERA; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SQLite; using System.Drawing; using System.Linq; using System.Reflection.Emit; using System.Security.Policy; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ECV { public partial class FactElectr_Conf : Form { public FactElectr_Conf() { InitializeComponent(); } private void Btn_Guardar_Click(object sender, EventArgs e) { if (Txt_ID.Text == "") { Txt_ID.Focus(); return; } //if (Txt_ID.Text.Substring(Txt_ID.Text.Length - 1, 1) != "/") //{ // Txt_ID.Text = Txt_ID.Text + "/"; //} if (Txt_ApiKey.Text == "") { Txt_ApiKey.Focus(); return; } if (Txt_Punto.Text == "") { Txt_Punto.Focus(); return; } if (Txt_URL.Text == "") { Txt_URL.Focus(); return; } try { if (Txt_URL.Text.Substring(0, 5) != "https") { Txt_URL.Text = "https://" + Txt_URL.Text.Trim(); } } catch { } if (com_TipoTransaccion.Text == "") { com_TipoTransaccion.Focus(); return; } if (com_tipoImpuesto.Text == "") { com_tipoImpuesto.Focus(); return; } string SQL = "UPDATE fact_elec_conf SET id_fe = '"+ Txt_ID.Text +"', apikey = '"+ Txt_ApiKey.Text +"', punto = '"+ Txt_Punto.Text +"', url = '"+ Txt_URL.Text +"', tipo_transac = '"+ com_TipoTransaccion.Text +"', tipo_imp = '"+ com_tipoImpuesto.Text +"', mensaje = '" + Txt_Mensaje.Text + "'"; SQLiteCommand CMD = new SQLiteCommand(SQL, Global.conexion); CMD.ExecuteNonQuery(); //Global.conexion.Close(); MessageBox.Show("La Configuración se actuliazó exitosamente. \n Ahora haga clic en ''Guardar'', el sistema se cerrará, abra de nuevo para que la nueva configuración tome efecto."); this.Close(); } public void FactElectr_Conf_Load(object sender, EventArgs e) { //Crear la Tabla "fact_elec_conf" string SQL ="CREATE TABLE IF NOT EXISTS fact_elec_conf (id INTEGER PRIMARY KEY, id_fe, apikey, punto, url, tipo_transac, tipo_imp, mensaje)"; SQLiteCommand CMD = new SQLiteCommand(SQL, Global.conexion); CMD.ExecuteNonQuery(); //Insertar datos string SQL1 = "INSERT INTO fact_elec_conf (id_fe, apikey, punto, url, tipo_transac, tipo_imp, mensaje) SELECT 'marcialestechevera', 'B5A2C991-B0E3-4533-ADFB-1B1D56F7107A', '001-001', 'https://oietema.com/','3=Mixto (Venta de mercadería y servicios)','1=IVA','Nos complace informarle que tendremos una promoción excepcional.' WHERE NOT EXISTS (SELECT 1 FROM fact_elec_conf LIMIT 1)"; SQLiteCommand CMD1 = new SQLiteCommand(SQL1, Global.conexion); CMD1.ExecuteNonQuery(); //Muestra la config SQLiteDataReader RS2 = null; string SQL2 = "SELECT * FROM fact_elec_conf LIMIT 1;"; SQLiteCommand CMD2 = new SQLiteCommand(SQL2, Global.conexion); RS2 = CMD2.ExecuteReader(); if (RS2.HasRows == true) { RS2.Read(); Txt_ID.Text = RS2.GetString(1); Global.FE_TenantId = RS2.GetString(1); Txt_ApiKey.Text = RS2.GetString(2); Global.FE_ApiKey = RS2.GetString(2); Txt_Punto.Text = RS2.GetString(3); Global.FE_Punto = RS2.GetString(3); Txt_URL.Text = RS2.GetString(4); Global.FE_URL = RS2.GetString(4); com_TipoTransaccion.Text = RS2.GetString(5); string[] Tt; Tt = RS2.GetString(5).Split('='); Global.FE_TipoTransac = Tt[0]; com_tipoImpuesto.Text = RS2.GetString(6); string[] Ti; Ti = RS2.GetString(6).Split('='); Global.FE_TipoImpuesto = Ti[0]; Txt_Mensaje.Text = RS2.GetString(7); Global.FE_Mensaje = RS2.GetString(7); } } private void Txt_Mensaje_TextChanged(object sender, EventArgs e) { label8.Text = "Son " + Txt_Mensaje.Text.Length.ToString() + " caracteres."; } } }