Ejemplo n.º 1
0
        public void UpdateUser(GlobalClass.userCreateMapper AlteringUser)
        {
            //Open connection
            if (this.openConnection() == true)
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = dbConnect;
                string query = @"UPDATE user_info 
                                    SET Name='" + AlteringUser.Name + @"',
                                        Surname='" + AlteringUser.Surname + @"',
                                        Patronym='" + AlteringUser.Patronim + @"'
                                    WHERE ID=" + AlteringUser.id_info;
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
                query           = @"UPDATE aquser 
                                    SET ID_group=" + AlteringUser.id_group + @",
                                        passwd='" + AlteringUser.MD5HashPass + @"'
                                    WHERE ID=" + AlteringUser.ID;
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();

                //close connection
                this.CloseConnection();
            }
        }
Ejemplo n.º 2
0
 private void AlterUser()
 {
     AlteringUser        = elementBase.SelectUserWhere(this.userId);
     this.SurnameT.Text  = AlteringUser.Surname;
     this.NameT.Text     = AlteringUser.Name;
     this.PatronymT.Text = AlteringUser.Patronim;
     this.groupSelector.SelectedValue = AlteringUser.id_group;
 }
Ejemplo n.º 3
0
        public GlobalClass.userCreateMapper SelectUserWhere(int id)
        {
            string query = @"SELECT a.ID, b.Name, b.Surname, b.Patronym,a.ID_info, a.ID_group, a.passwd FROM aquser as a
                            JOIN user_info as b ON b.ID = a.ID_info
                            where a.ID = " + id.ToString() + " limit 1";

            GlobalClass.userCreateMapper tempUser = new GlobalClass.userCreateMapper();

            if (this.openConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query, dbConnect);
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int    II = (int)((long)dataReader["ID_info"]);
                    int    IG = (int)((long)dataReader["ID_group"]);
                    int    I  = (int)((long)dataReader["ID"]);
                    string N  = (string)dataReader["Name"];
                    string S  = (string)dataReader["Surname"];
                    string P  = (string)dataReader["Patronym"];
                    string Pw = (string)dataReader["passwd"];
                    tempUser = new GlobalClass.userCreateMapper(I, N, S, P, II, IG, Pw);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return list to be displayed
                return(tempUser);
            }
            else
            {
                return(tempUser);
            }
        }
Ejemplo n.º 4
0
        public void InsertUserInfo(GlobalClass.userCreateMapper InsertingUser)
        {
            if (this.openConnection() == true)
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = dbConnect;
                string query = @"INSERT INTO user_info (`Name`,`Surname`,`Patronym`)
                                    VALUES ('" + InsertingUser.Name + "','" + InsertingUser.Surname + "','" + InsertingUser.Patronim + "')";
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
                long inserted_id = -1;
                inserted_id = cmd.LastInsertedId;
                if (inserted_id > -1)
                {
                    query           = @"INSERT INTO aquser (`ID_group`,`ID_info`,`passwd`)
                                     VALUES ('" + InsertingUser.id_group + "','" + inserted_id + "','" + InsertingUser.MD5HashPass + "')";
                    cmd.CommandText = query;
                    cmd.ExecuteNonQuery();
                }

                //close connection
                this.CloseConnection();
            }
        }
Ejemplo n.º 5
0
 public AddUser()
 {
     InitializeComponent();
     newUser      = true;
     AlteringUser = new GlobalClass.userCreateMapper();
 }