public void save(EnvioModel envioModel) { try { SQLiteConnection myConn = bd.ConnectSqlite(); // myConn.Open(); string sql = "INSERT INTO envio VALUES(null,'" + envioModel.tipoDte + "'," + envioModel.folio + ",'" + envioModel.fchEmis.ToString("yyyy-MM-dd hh:MM:ss") + "'," + envioModel.mntTotal + ",'" + envioModel.estado + "','" + envioModel.envioXml + "','" + envioModel.recepcionDteXml + "','" + envioModel.trackId + "'," + envioModel.CdgSIISucur + " " + ")"; SQLiteCommand command = new SQLiteCommand(sql, myConn); command.ExecuteNonQuery(); myConn.Close(); } catch (Exception empUpdate) { Console.WriteLine("ERROR: {0}" + empUpdate.ToString()); // MessageBox.Show("ERROR: {0}" + empUpdate.ToString()); } //MessageBox.Show("Guardado con exito"); }
public DataTable listaLibroXFecha(DateTime mesAno, string estado, string fechaInicial, string fechaFinal) { DataTable datatable = new DataTable(); empresaModel = empresaModel.getEmpresa(); try { SQLiteConnection myConn = bd.ConnectSqlite(); string sql = "select TipoDTE,Folio,FchEmis,RUTEmisor,RUTRecep,RznSoc,MntNeto,MntExe,IVA, MntTotal " + "FROM documento " + "where estado='" + estado + "'" // +"and FchEmis between '"+fechaInicial+"' and '"+fechaFinal+"'" + "and RUTEmisor <> '" + empresaModel.RutEmisor + "'" + "order by TipoDTE"; SQLiteCommand command = new SQLiteCommand(sql, myConn); SQLiteDataReader reader = command.ExecuteReader(); datatable.Load(reader); } catch (Exception ex) { datatable = null; throw new Exception("Error" + ex.Message); } return(datatable); }
public void save(DocumentoModel doc) { SQLiteConnection myConn = bd.ConnectSqlite(); // myConn.Open(); try { string sql = "INSERT INTO documento (" + "TipoDTE," + "Folio," + "FchEmis," + "RUTEmisor," + "RUTRecep," + "RznSoc," + "MntNeto," + "MntExe," + "IVA," + "tipoimp," + "tasaimp," + "montoimp," + "MntTotal," + "estado," + "NombreXml" + ") VALUES (" + doc.TipoDTE + "," + doc.Folio + ",'" + Convert.ToDateTime(doc.FchEmis).ToString("yyyy-MM-dd") + "','" + doc.RUTEmisor + "','" + doc.RUTRecep + "','" + doc.RznSoc + "'," + doc.MntNeto + "," + doc.MntExe + "," + doc.IVA + ",'" + doc.tipoimp + "'," + doc.tasaimp + "," + doc.montoimp + "," + doc.MntTotal + ",'" + doc.estado + "','" + doc.NombreXml + "'" + ")"; SQLiteCommand command = new SQLiteCommand(sql, myConn); command.ExecuteNonQuery(); Console.WriteLine(">>>>>>>> " + doc.Folio); } catch (Exception empUpdate) { Console.WriteLine("====================== ERROR: {0}" + empUpdate.ToString() + " =========================="); // MessageBox.Show("ERROR: {0}" + empUpdate.ToString()); } myConn.Close(); }
public List <PrinterModel> printerList() { List <PrinterModel> printers = new List <PrinterModel>(); try { SQLiteConnection myConn = bd.ConnectSqlite(); //myConn.Open(); string sql = "select * from printers"; SQLiteCommand command = new SQLiteCommand(sql, myConn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { PrinterModel printer = new PrinterModel(); printer.printerName = reader["printername"].ToString(); printer.directory = reader["directory"].ToString(); printers.Add(printer); } myConn.Close(); return(printers); } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.ToString()); return(printers); } }
public int getCafActual(int tipoDte) { string idUltimoCaf = string.Empty; SQLiteConnection sqliteConn = new SQLiteConnection(); sqliteConn = bd.ConnectSqlite(); string sql = "SELECT max(id) FROM caf where \"tipoDte\" = '" + tipoDte + "';"; SQLiteCommand command = new SQLiteCommand(sql, sqliteConn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { idUltimoCaf = reader.GetString(reader.GetOrdinal("max")); } return(Convert.ToInt32(idUltimoCaf)); }
public void incrementaSgte(String tDte, String rutEmisor) { try { SQLiteConnection myConn = bd.ConnectSqlite(); myConn.Open(); string sql = "UPDATE folio set folioSgte = folioSgte+1" + "WHERE tipoDte = " + tDte + " and rut ='" + rutEmisor + "';"; SQLiteCommand command = new SQLiteCommand(sql, myConn); command.ExecuteNonQuery(); myConn.Close(); } catch (Exception empUpdate) { Console.WriteLine("ERROR: {0}" + empUpdate.ToString()); // MessageBox.Show("ERROR: {0}" + empUpdate.ToString()); } }
public void addLog(String suceso, String estado) { try { DateTime thisDay = DateTime.Now; String fecha = String.Format("{0:yyyyMMddTHHmmss}", thisDay); SQLiteConnection myConn = bd.ConnectSqlite(); //myConn.Open(); string sql = "insert into log (fch, suceso, estado) values ('" + fecha + "' , '" + suceso + "', '" + estado + "')"; SQLiteCommand command = new SQLiteCommand(sql, myConn); command.ExecuteNonQuery(); myConn.Close(); } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.ToString()); } }
public void addUltmoDte(DocumentoModel doc) { try { DateTime thisDay = DateTime.Now; String fecha = String.Format("{0:yyyyMMddTHHmmss}", thisDay); SQLiteConnection myConn = bd.ConnectSqlite(); //myConn.Open(); string sql = "insert into ultimodte (RutEmisor, RznSoc, CdgSIISucur, RutRecep, RznSocRecep, Folio, TipoDTE, fch) values ('" + doc.RUTEmisor + "','" + doc.RznSoc + "'," + doc.CdgSIISucur + ",'" + doc.RUTRecep + "','" + doc.RznSocRecep + "'," + doc.Folio + "," + doc.TipoDTE + ",'" + fecha + "')"; SQLiteCommand command = new SQLiteCommand(sql, myConn); command.ExecuteNonQuery(); myConn.Close(); } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.ToString()); } }
public void save(DescargasModel descargaModel) { try { SQLiteConnection sqliteConn = new SQLiteConnection(); sqliteConn = bd.ConnectSqlite(); string sql = "INSERT INTO descargas(" + "uid,\"nomArchivo\")" + " VALUES ('" + descargaModel.uid + "','" + descargaModel.nomArchivo + "'" + ");"; SQLiteCommand command = new SQLiteCommand(sql, sqliteConn); command.ExecuteNonQuery(); sqliteConn.Close(); } catch (SQLiteException ex) { throw new Exception("Error" + ex.Message); } }
public String getTipoTrasXCod(int idTras) { String tipotraslado = String.Empty; SQLiteConnection myConn = bd.ConnectSqlite(); myConn.Open(); string sql = "select * from tipotraslado where id = " + idTras; SQLiteCommand command = new SQLiteCommand(sql, myConn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { tipotraslado = reader.GetString(reader.GetOrdinal("nombre")); } return(tipotraslado); }
public EmpresaModel getEmpresa() { EmpresaModel empresa = new EmpresaModel(); SQLiteConnection myConn = bd.ConnectSqlite(); string sql = "select * from empresa"; SQLiteCommand command = new SQLiteCommand(sql, myConn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { empresa.RutEmisor = reader["RutEmisor"].ToString(); empresa.RznSoc = reader["RznSoc"].ToString(); empresa.GiroEmis = reader["GiroEmis"].ToString(); empresa.Telefono = reader["Telefono"].ToString(); empresa.CorreoEmisor = reader["CorreoEmisor"].ToString(); empresa.Acteco = reader["Acteco"].ToString(); empresa.CdgSIISucur = reader["CdgSIISucur"].ToString(); empresa.DirMatriz = reader["DirMatriz"].ToString(); empresa.CiudadOrigen = reader["CiudadOrigen"].ToString(); empresa.CmnaOrigen = reader["CmnaOrigen"].ToString(); empresa.DirOrigen = reader["DirOrigen"].ToString(); empresa.SucurSII = reader["SucurSII"].ToString(); empresa.NomCertificado = reader["NomCertificado"].ToString(); empresa.SucurEmisor = reader["SucurEmisor"].ToString(); empresa.FchResol = reader["FchResol"].ToString(); empresa.RutCertificado = reader["RutCertificado"].ToString(); empresa.NumResol = reader["NumResol"].ToString(); empresa.CondEntrega = reader["CondEntrega"].ToString(); empresa.UrlCore = reader["UrlCore"].ToString(); empresa.PrnTwoCopy = reader["PrnTwoCopy"].ToString(); empresa.PrnMtoNeto = reader["PrnMtoNeto"].ToString(); empresa.PrnThermal = reader["PrnThermal"].ToString(); } myConn.Close(); return(empresa); }
public DocumentoModel lectura(String fileJson, bool moveFile, String dirOrigen) { DocumentoModel doc = new DocumentoModel(); fileAdmin file = new fileAdmin(); String fileName = String.Empty; if (dirOrigen == "") { dirOrigen = @"C:\AdmToSii\file"; } if (fileJson == "") { fileName = file.nextFile(dirOrigen, "*.json"); } else { fileName = dirOrigen + fileJson; } if (fileName != null) { StreamReader objReader = new StreamReader(fileName, System.Text.Encoding.Default, true); objReader.ToString(); String data = objReader.ReadToEnd(); DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(DocumentoModel)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(data)); try { doc = (DocumentoModel)js.ReadObject(ms); } catch (Exception e) { Console.WriteLine(e.Message); // MessageBox.Show("Error de lectura JSON"+ e.Message); } // Datos del Emisor // Cargo datos en laclase Documento desde sqlite string oc = bd.GetOC(); if (oc == "True") { doc.NroOrdenCompra = Convert.ToInt32(getOrdenCompra(data)); doc.NroCita = getNroCita(data); doc.Sello = getSello(data); } if (doc.RUTEmisor == null) { try { SQLiteConnection myConn = bd.ConnectSqlite(); myConn.Open(); string sql = "select * from empresa"; SQLiteCommand command = new SQLiteCommand(sql, myConn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { doc.RUTEmisor = reader["RutEmisor"].ToString(); doc.RznSoc = reader["RznSoc"].ToString(); doc.GiroEmis = reader["GiroEmis"].ToString(); doc.Telefono = reader["Telefono"].ToString(); doc.CorreoEmisor = reader["CorreoEmisor"].ToString(); doc.Acteco = Convert.ToInt32(reader["Acteco"]); doc.CdgSIISucur = Convert.ToInt32(reader["CdgSIISucur"]); doc.DirMatriz = reader["DirMatriz"].ToString(); doc.CmnaOrigen = reader["CmnaOrigen"].ToString(); doc.CiudadOrigen = reader["CiudadOrigen"].ToString(); doc.DirOrigen = reader["DirOrigen"].ToString(); doc.NombreCertificado = reader["NomCertificado"].ToString(); doc.SucurEmisor = reader["SucurEmisor"].ToString(); doc.FchResol = reader["FchResol"].ToString(); doc.RutEnvia = reader["RutCertificado"].ToString(); doc.NumResol = reader["NumResol"].ToString(); doc.CondEntrega = reader["CondEntrega"].ToString(); } myConn.Close(); } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.ToString()); } } else { try { SQLiteConnection myConn = bd.ConnectSqlite(); //myConn.Open(); string sql = "select * from empresa where empresa.RutEmisor = '" + doc.RUTEmisor.ToString() + "'"; SQLiteCommand command = new SQLiteCommand(sql, myConn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { doc.Telefono = reader["Telefono"].ToString(); doc.CorreoEmisor = reader["CorreoEmisor"].ToString(); doc.Acteco = Convert.ToInt32(reader["Acteco"]); doc.DirRegionalSII = reader["sucurSII"].ToString(); doc.DirMatriz = reader["DirMatriz"].ToString(); doc.NombreCertificado = reader["NomCertificado"].ToString(); doc.SucurEmisor = reader["SucurEmisor"].ToString(); doc.FchResol = reader["FchResol"].ToString(); doc.RutEnvia = reader["RutCertificado"].ToString(); doc.NumResol = reader["NumResol"].ToString(); doc.CondEntrega = reader["CondEntrega"].ToString(); doc.PrnMtoNeto = reader["PrnMtoNeto"].ToString(); doc.PrnTwoCopy = reader["PrnTwoCopy"].ToString(); } myConn.Close(); } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.ToString()); } } objReader.Close(); ms.Close(); if (moveFile) { file.mvFile(fileName, dirOrigen, "C:/AdmToSii/fileProcess/"); } CafModel caf = new CafModel(); if (!caf.isValid(doc)) { doc = null; } if (fileJson == "") { doc.fileName = fileName; } else { doc.fileName = fileJson; } return(doc); } else { return(null); } }