Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Type == "Add")
     {
         M_CUser NewUser = new M_CUser();
         NewUser.name     = textBox1.Text;
         NewUser.password = textBox2.Text;
         NewUser.job      = comboBox1.SelectedItem.ToString();
         bool Check = NewUser.Valid();
         if (Check)
         {
             string [] att = { "Name", "Password", "Job_Description" };
             string[]  val = { NewUser.name, NewUser.password, NewUser.job };
             //NewUser.addUser(NewUser.name, NewUser.password, NewUser.job);
             NewUser.adduser2("Users", att, val);
         }
     }
     else
     {
         M_CUser NewUser = new M_CUser();
         NewUser.name     = textBox1.Text;
         NewUser.password = textBox2.Text;
         NewUser.job      = comboBox1.SelectedItem.ToString();
         // NewUser.updateUser(NewUser.name, NewUser.password, NewUser.job, id);
         string[] atts   = { "Name", "Password", "Job_Description" };
         string[] values = { NewUser.name, NewUser.password, NewUser.job };
         NewUser.updateuser2("Users", id, atts, values, "UserID");
     }
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            M_CUser UU = new M_CUser();

            UU.name     = textBox1.Text;
            UU.password = textBox2.Text;

            if (UU.Login(UU))
            {
                ///
                type = UU.Login2(UU);

                if (type == 1)
                {
                    VC_Manager MN = new VC_Manager();
                    MN.Show();
                }
                if (type == 2)
                {
                    VC_Teachers TC = new VC_Teachers();
                    TC.Show();
                }
                if (type == 3)
                {
                    VC_Receptionist RC = new VC_Receptionist();
                    RC.Show();
                }
            }
            else
            {
                MessageBox.Show("No");
            }
        }
Exemplo n.º 3
0
 public bool Login(M_CUser UL)
 {
     foreach (var i in M_CUser.allUsers())
     {
         if (i.name == UL.name && i.password == UL.password)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        public static int SingleUser(int UserId)
        {
            string query = "select * from Users where UserId=@UserID";

            Connect.Open();
            SqlCommand command = new SqlCommand(query, Connect);

            command.Parameters.AddWithValue("@UserID", UserId);
            SqlDataReader reader = command.ExecuteReader();

            reader.Read();
            M_CUser MM = new M_CUser();

            MM.name = reader["Name"].ToString();
            MM.job  = reader["Job_Description"].ToString();
            Connect.Close();
            return(UserId);
        }
Exemplo n.º 5
0
        public static List <M_CUser> allUsers()
        {
            string         query = "select * from Users;";
            List <M_CUser> Users = new List <M_CUser>();

            Connect.Open();
            SqlCommand    command = new SqlCommand(query, Connect);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                M_CUser User = new M_CUser();
                User.name     = reader["Name"].ToString();
                User.password = reader["Password"].ToString();
                User.job      = reader["Job_Description"].ToString();
                Users.Add(User);
            }
            Connect.Close();

            return(Users);
        }
Exemplo n.º 6
0
        public int Login2(M_CUser UL2)
        {
            int type = 0;

            foreach (var i in M_CUser.allUsers())
            {
                if (i.name == UL2.name && i.password == UL2.password)
                {
                    if (i.job == "Manager")
                    {
                        type = 1;
                    }
                    if (i.job == "Teacher")
                    {
                        type = 2;
                    }
                    if (i.job == "Receptionist")
                    {
                        type = 3;
                    }
                }
            }
            return(type);
        }