Пример #1
0
 //mehtod to make a user
 public static void addUser(Info.UserInfo Uinfo)
 {
     //connection
     using (IDbConnection cnn = new SqlConnection(connection()))
     {
         cnn.Open();
         //inserts into user table
         cnn.Execute("insert into Login (UserName,PassWord) values (@UserName,@PassWord)", Uinfo);
     }
 }
        protected void TbCreate_Click(object sender, EventArgs e)
        {
            //making variables that i will need
            bool hasit = false;

            //adding data to list
            user = SqlMethods.fillUser();
            Info.UserInfo U = new Info.UserInfo();

            U.PassWord = TbPassword.Text;
            //looping through the list
            foreach (Info.UserInfo i in user)
            {
                //checking if the password that is entered is already assigned to another account
                if (U.PassWord == i.PassWord)
                {
                    hasit = true;
                }
            }
            //checking which type of person is getting an account
            if (hasit == false)
            {
                //checking if the Student is ticked to make sure to add it as there username
                if (RbStudent.Checked == true)
                {
                    U.UserName = "******";
                }
                else
                //checking if the Teahcer is ticked to make sure to add it as there username
                if (RbTeacher.Checked == true)
                {
                    U.UserName = "******";
                }
                //printing out what account they jsut made with there info
                SqlMethods.addUser(U);
            }
            else
            {
                //printing form dll that the password that they entered is allready in use for another account
            }
        }