public static bool Actualizar_Usuario_Validado(string user, string pass) { DataBase db = new DataBase(); string sConexion = db.GenerarConexionString(DataBase.getDefaultPathConfig()); string ConsultaSQL = QueryVerificarExistenciaUsuario; CCryptorEngine cryp = new CCryptorEngine(); ConsultaSQL = ConsultaSQL.Replace("@name", cryp.Encriptar(user)); ConsultaSQL = ConsultaSQL.Replace("@pass", cryp.EncodeMD5(pass)); DataTable dt = db.ExecQuery(ConsultaSQL, sConexion); //Existe el usuario? if ((int)(dt.Rows[0]["login"]) < 1) { // Agrego al usuario Logueado por Web ConsultaSQL = QueryInsertarUsuario; } else { // Actualizo la pass del usuario ConsultaSQL = QueryActualizarUsuario; } ConsultaSQL = ConsultaSQL.Replace("@name", cryp.Encriptar(user)); ConsultaSQL = ConsultaSQL.Replace("@pass", cryp.EncodeMD5(pass)); return(db.ExecNonQuery(ConsultaSQL, sConexion)); }
private void btnLogin_Click(object sender, EventArgs e) { if (txtUser.Text == user_adm && txtPass.Text == pass_adm) { LoguearUsuario(true); return; } DataBase db = new DataBase(); string sConexion = db.GenerarConexionString(DataBase.getDefaultPathConfig()); string ConsultaSQL = "SELECT COUNT(Id) as login FROM usr WHERE name = '@name' AND pass = '******';"; CCryptorEngine cryp = new CCryptorEngine(); ConsultaSQL = ConsultaSQL.Replace("@name", cryp.Encriptar(txtUser.Text)); ConsultaSQL = ConsultaSQL.Replace("@pass", cryp.EncodeMD5(txtPass.Text)); DataTable dt = db.ExecQuery(ConsultaSQL, sConexion); if ((int)(dt.Rows[0]["login"]) != 1) { MessageBox.Show("El nombre de usuario o la contraseña introducidos no son correctos.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtUser.SelectAll(); txtPass.SelectAll(); return; } LoguearUsuario(false); }
public bool Marcar_Registros_No_Informados() { try { var db = new DataBase(); var cryp = new CCryptorEngine(); var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB()); var query = QueryCrearNuevoLote; query = query.Replace("@lot", cryp.Encriptar(this.id)); query = query.Replace("@int", cryp.Encriptar("1")); // Es el primer intento de informar return(db.ExecNonQuery(query, sConexion)); } catch { return(false); } }
public bool Insert_Base_Local_Masivo(DataBase db) { try { var cryp = new CCryptorEngine(); var query = QueryInsert; query = query.Replace("@Ape", cryp.Encriptar(this.ape)); query = query.Replace("@Nom", cryp.Encriptar(this.nom)); query = query.Replace("@Doc", cryp.Encriptar(this.doc.ToString())); query = query.Replace("@Tar", cryp.Encriptar(this.tar)); query = query.Replace("@Id", cryp.Encriptar(this.id.ToString())); return(db.ExecNonQueryMasivo(query)); } catch { return(false); } }
public static void Eliminar_Usuario_Local() { DataBase db = new DataBase(); string sConexion = db.GenerarConexionString(DataBase.getDefaultPathConfig()); string ConsultaSQL = QueryEliminarUsuario; CCryptorEngine cryp = new CCryptorEngine(); ConsultaSQL = ConsultaSQL.Replace("@name", cryp.Encriptar(user_name_login)); db.ExecNonQuery(ConsultaSQL, sConexion); }
private void button1_Click(object sender, EventArgs e) { if (txtOriginal.Text.CompareTo(string.Empty) == 0) { return; } CCryptorEngine c = new CCryptorEngine(); txtMD5.Text = c.EncodeMD5(txtOriginal.Text); txtEncriptado.Text = c.Encriptar(txtOriginal.Text); txtDesencriptado.Text = c.Desencriptar(txtEncriptado.Text); }
public bool Insert(Persona per, bool es_ingreso, bool reg_x_doc) { try { var db = new DataBase(); var cryp = new CCryptorEngine(); var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB()); var query = QueryInsert .Replace("@Pid", cryp.Encriptar(per.id.ToString())) .Replace("@Fec", cryp.Encriptar(DateTime.Now.ToString("yyyyMMdd HH:mm:ss"))) .Replace("@Ing", es_ingreso.ToString().ToUpper()) .Replace("@Usr", cryp.Encriptar(Seguridad.user_name_login)) .Replace("@Edi", cryp.Encriptar(Seguridad.edificio.id.ToString())) .Replace("@Rdc", cryp.Encriptar(reg_x_doc.ToString())); db.ExecNonQuery(query, sConexion); return(true); } catch { return(false); } }
public bool Grabar_Dotacion_JS() { try { var cryp = new CCryptorEngine(); var path_file = DataBase.getDefaultPathDotacionJsCryp(); var dot_js_cryp = cryp.Encriptar(JsonConvert.SerializeObject(this.personas)); System.IO.File.WriteAllText(path_file, dot_js_cryp); return(true); } catch { return(false); } }
public bool Existe_Base_Local() { try { var db = new DataBase(); var cryp = new CCryptorEngine(); var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB()); var query = QueryExiste; query = query.Replace("@Id", cryp.Encriptar(this.id.ToString())); var dt = db.ExecQuery(query, sConexion); if (dt.Rows.Count > 0 && Convert.ToInt32(dt.Rows[0]["Existe"]) == 1) { return(true); } return(false); } catch { return(false); } }
public bool Cargar_Registros_Del_Lote() { var db = new DataBase(); var cryp = new CCryptorEngine(); var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB()); var query = QueryRegLote; query = query.Replace("@lot", cryp.Encriptar(this.id)); var dt = db.ExecQuery(query, sConexion); this.registros = new List <RegistroControlAcceso>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { var rca = new RegistroControlAcceso(); try { rca.id = Convert.ToInt32(row["Id"]); rca.per_id = Convert.ToInt32(cryp.Desencriptar(row["pid"].ToString())); rca.fecha = DateTime.ParseExact(cryp.Desencriptar(row["fec"].ToString()), "yyyyMMdd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); rca.es_ingreso = (Convert.ToInt32(row["ing"]) != 0? true : false); rca.usu = cryp.Desencriptar(row["usr"].ToString()); rca.edif = Convert.ToInt32(cryp.Desencriptar(row["edi"].ToString())); try { rca.reg_x_doc = (cryp.Desencriptar(row["rdc"].ToString()) == true.ToString() ? true : false); } catch { rca.reg_x_doc = false; } this.registros.Add(rca); } catch { continue; } } return(true); } return(false); }