Beispiel #1
0
 public bool Recuperar_Dotacion_DB()
 {
     try {
         var db        = new DataBase();
         var cryp      = new CCryptorEngine();
         var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB());
         var dt        = db.ExecQuery(QueryListAll, sConexion);
         if (dt.Rows.Count > 0)
         {
             this.personas = new List <Persona>();
             foreach (DataRow row in dt.Rows)
             {
                 var per = new Persona();
                 try {
                     per.id  = Convert.ToInt32(cryp.Desencriptar(row["Id"].ToString()));
                     per.ape = cryp.Desencriptar(row["Ape"].ToString());
                     per.nom = cryp.Desencriptar(row["Nom"].ToString());
                     per.tar = cryp.Desencriptar(row["Tar"].ToString());
                     per.doc = Convert.ToInt32(cryp.Desencriptar(row["Doc"].ToString()));
                     this.personas.Add(per);
                 }
                 catch {
                     continue;
                 }
             }
             return(true);
         }
         throw new Exception();
     }
     catch
     {
         return(false);
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 public DataTable Get_Edificios()
 {
     try
     {
         var db        = new DataBase();
         var cryp      = new CCryptorEngine();
         var sConexion = db.GenerarConexionString(DataBase.getDefaultPathConfig());
         var query     = QueryTodos;
         return(db.ExecQuery(query, sConexion));
     }
     catch
     {
         return(null);
     }
 }
Beispiel #7
0
 public DataTable Get_Lotes_Informados()
 {
     try
     {
         var db        = new DataBase();
         var cryp      = new CCryptorEngine();
         var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB());
         var query     = QueryLotesInf;
         return(db.ExecQuery(query, sConexion));
     }
     catch
     {
         return(null);
     }
 }
Beispiel #8
0
 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);
     }
 }
Beispiel #9
0
 public static int Cantidad_De_Reg_Para_Informar()
 {
     try
     {
         var db        = new DataBase();
         var cryp      = new CCryptorEngine();
         var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB());
         var query     = QueryExistenRegistrosParaInformar;
         var dt        = db.ExecQuery(query, sConexion);
         return(Convert.ToInt32(dt.Rows[0]["REG_PARA_INF"]));
     }
     catch
     {
         return(-1);
     }
 }
Beispiel #10
0
 public Boolean Actualizar_Edificio_Sel()
 {
     try
     {
         var db        = new DataBase();
         var cryp      = new CCryptorEngine();
         var sConexion = db.GenerarConexionString(DataBase.getDefaultPathConfig());
         db.ExecNonQuery(QueryDeselEdif, sConexion);
         var query = QueryActualizarEdiSel.Replace("@Id", this.id.ToString());
         return(db.ExecNonQuery(query, sConexion));
     }
     catch
     {
         return(false);
     }
 }
Beispiel #11
0
 public bool Recuperar_Dotacion_JS()
 {
     try
     {
         var cryp      = new CCryptorEngine();
         var path_file = DataBase.getDefaultPathDotacionJsCryp();
         var dot_js    = cryp.Desencriptar(System.IO.File.ReadAllText(path_file));
         this.personas = JsonConvert.DeserializeObject <List <Persona> >(dot_js);
         return(true);
     }
     catch (Exception ex)
     {
         this._error_desc = ex.Message;
         return(false);
     }
 }
Beispiel #12
0
 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);
     }
 }
Beispiel #13
0
 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);
     }
 }
        // private static string QuerySelect = "SELECT TOP 1 * FROM Dot WHERE Doc = @Doc OR Tar = '@Tar';";
        // private static string QueryListAll = "SELECT * FROM Dot;";


        public bool Fecha_Actual_Es_Mayor_Ult_Fecha_Grabacion(ref DateTime ult_fecha_grabada)
        {
            try
            {
                var db        = new DataBase();
                var cryp      = new CCryptorEngine();
                var sConexion = db.GenerarConexionString(DataBase.getDefaultPathDB());
                var dt        = db.ExecQuery(QueryUltFecha, sConexion);
                if (dt.Rows.Count < 1)
                {
                    return(true);                   // No hay registros ingresados
                }
                ult_fecha_grabada = DateTime.ParseExact(cryp.Desencriptar((string)dt.Rows[0]["fec"]), "yyyyMMdd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                return(ult_fecha_grabada.CompareTo(DateTime.Now) < 0);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #15
0
 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 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);
     }
 }
Beispiel #17
0
        private void Cargar_Grilla_Lotes_Informados()
        {
            var cryp = new CCryptorEngine();
            var lca  = new LoteControlAcceso();
            var dt   = lca.Get_Lotes_Informados();

            foreach (DataRow row in dt.Rows)
            {
                if (row["LOTE"].ToString() == string.Empty)
                {
                    row["LOTE"] = "< Registros sin Lote >";
                }
                else
                {
                    row["LOTE"] = cryp.Desencriptar(row["LOTE"].ToString());
                }
            }
            dgvLotes.DataSource = dt;
            foreach (DataGridViewColumn col in dgvLotes.Columns)
            {
                col.Width = ((dgvLotes.Width - 45) / dgvLotes.Columns.Count);
            }
        }
Beispiel #18
0
        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);
        }