Esempio n. 1
0
 // when form is loaded.
 private void frmShowUser_Load(object sender, EventArgs e)
 {
     if (ID != null)
     {
         try
         {
             // load the user object from the database.
             usuarios u = usuarios.getUser(ID);
             // load the image for the object.
             try {
                 // try and cacth the exception if there's no filepath on the database.
                 pbImage.Image = Image.FromFile(u.image);
             }
             catch (Exception)
             {
                 // if there's no path on the database replace the image for the default image.
                 MessageBox.Show("No se ha registrado una imagen", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 pbImage.Image = Image.FromFile(@"C:\FactoriadeProyectos\Sistema-oficina-abogados\Images\n.png");
             }
             // **** //
             // then load the labels with the object info.
             lblID.Text   = "ID: " + u.id;
             lblName.Text = "Nombre: " + u.nombre;
             lblType.Text = "Tipo: " + u.nivel;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         // load the default image.
         try
         {
             pbImage.Image = Image.FromFile(@"C:\FactoriadeProyectos\Sistema-oficina-abogados\Images\n.png");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 2
0
        // getting user object from database
        public static usuarios getUser(string id)
        {
            usuarios u = new usuarios();

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand    comand = new SqlCommand(string.Format("SELECT users.ID, users.name, users.passwrd, users.picture, UserLevel.levels FROM users INNER JOIN UserLevel ON users.userLevelID = UserLevel.id WHERE users.ID = '{0}'", id), con);
                SqlDataReader re     = comand.ExecuteReader();
                while (re.Read())
                {
                    u.id     = re["ID"].ToString();
                    u.nombre = re["name"].ToString();
                    u.nivel  = re["levels"].ToString();
                    u.image  = re["picture"].ToString();
                }
                con.Close();
            }
            return(u);
        }
Esempio n. 3
0
        // method which loads all users.
        public static List<usuarios> listAllUsers()
        {
            List<usuarios> list = new List<usuarios>();
            using(SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand("SELECT users.ID, users.name, users.passwrd, users.picture, UserLevel.levels FROM users INNER JOIN UserLevel ON users.userLevelID = UserLevel.id", con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    usuarios u = new usuarios();
                    u.id = re["ID"].ToString();
                    u.nombre = re["name"].ToString();
                    u.nivel = re["levels"].ToString();
                    u.image = re["picture"].ToString();

                    list.Add(u);
                }
                con.Close();
            }
            return list;
        }
Esempio n. 4
0
        // method which loads all users.
        public static List <usuarios> listAllUsers()
        {
            List <usuarios> list = new List <usuarios>();

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand    comand = new SqlCommand("SELECT users.ID, users.name, users.passwrd, users.picture, UserLevel.levels FROM users INNER JOIN UserLevel ON users.userLevelID = UserLevel.id", con);
                SqlDataReader re     = comand.ExecuteReader();
                while (re.Read())
                {
                    usuarios u = new usuarios();
                    u.id     = re["ID"].ToString();
                    u.nombre = re["name"].ToString();
                    u.nivel  = re["levels"].ToString();
                    u.image  = re["picture"].ToString();

                    list.Add(u);
                }
                con.Close();
            }
            return(list);
        }
Esempio n. 5
0
        // search engine for all users.
        public static List <usuarios> SearchEngineUsers(string id, string name, string level, string passwrd)
        {
            List <usuarios> list = new List <usuarios>();

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand(string.Format("SELECT users.ID, users.name, users.passwrd, users.picture, UserLevel.levels FROM users INNER JOIN UserLevel ON users.userLevelID = UserLevel.id where users.ID like '{0}%' and name like '{1}%' and passwrd like '{2}%' and levels like '{3}%'",
                                                                 id, name, passwrd, level), con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    usuarios u = new usuarios();
                    u.id     = re["ID"].ToString();
                    u.nombre = re["name"].ToString();
                    u.nivel  = re["levels"].ToString();
                    u.image  = re["picture"].ToString();

                    list.Add(u);
                }
                con.Close();
            }
            return(list);
        }
Esempio n. 6
0
        // search engine for all users.
        public static List<usuarios> SearchEngineUsers(string id, string name, string level, string passwrd)
        {
            List<usuarios> list = new List<usuarios>();
            using(SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand(string.Format("SELECT users.ID, users.name, users.passwrd, users.picture, UserLevel.levels FROM users INNER JOIN UserLevel ON users.userLevelID = UserLevel.id where users.ID like '{0}%' and name like '{1}%' and passwrd like '{2}%' and levels like '{3}%'",
                    id, name, passwrd, level), con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    usuarios u = new usuarios();
                    u.id = re["ID"].ToString();
                    u.nombre = re["name"].ToString();
                    u.nivel = re["levels"].ToString();
                    u.image = re["picture"].ToString();

                    list.Add(u);
                }
                con.Close();
            }
            return list;
        }
Esempio n. 7
0
 // getting user object from database
 public static usuarios getUser(string id)
 {
     usuarios u = new usuarios();
     using(SqlConnection con = DBcomun.getConnection())
     {
         SqlCommand comand = new SqlCommand(string.Format("SELECT users.ID, users.name, users.passwrd, users.picture, UserLevel.levels FROM users INNER JOIN UserLevel ON users.userLevelID = UserLevel.id WHERE users.ID = '{0}'", id), con);
         SqlDataReader re = comand.ExecuteReader();
         while (re.Read())
         {
             u.id = re["ID"].ToString();
             u.nombre = re["name"].ToString();
             u.nivel = re["levels"].ToString();
             u.image = re["picture"].ToString();
         }
         con.Close();
     }
     return u;
 }