Exemple #1
0
       //when check name and password, get the user's information
       public PropertyClass CheckNameAndPasswd(string name,string password)
       {
           PropertyClass accountClass=null;


       string strSql="select * from account where accountName='"+name.Trim()+"' and accountPassword='******'";
        try{
           sdr=db.GetDataReader(strSql);
            sdr.Read();
            if(sdr.HasRows)
            {
            accountClass=new PropertyClass();
            accountClass.UserId=sdr.GetInt32("id");
            accountClass.AccountName=name.Trim();
            accountClass.AccountPassword=password.Trim();
            accountClass.Email=sdr["email"].ToString();
            accountClass.Job=sdr.GetInt32("job");;
            accountClass.Superviser=sdr.GetInt32("superviser");
            }
        }
           catch(Exception ex)
        {
           
          }
        finally
        {
            sdr.Close();
        }
          return accountClass; 
      
       }
Exemple #2
0
        //when check name and password, get the user's information
        public static PropertyClass CheckNameAndPasswd(string name, string password)
        {
            PropertyClass accountClass = null;


            string strSql = "select * from account where accountName='" + name.Trim() + "' and accountPassword='******'";

            try{
                sdr = db.GetDataReader(strSql);
                sdr.Read();
                if (sdr.HasRows)
                {
                    accountClass                 = new PropertyClass();
                    accountClass.UserId          = sdr.GetInt32("id");
                    accountClass.AccountName     = name.Trim();
                    accountClass.AccountPassword = password.Trim();
                    accountClass.Email           = sdr["email"].ToString();
                    accountClass.Job             = sdr.GetInt32("job");;
                    accountClass.Superviser      = sdr.GetInt32("superviser");
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);
            }
            finally
            {
                sdr.Close();
            }
            return(accountClass);
        }
Exemple #3
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                accountProperty =accountMgr.CheckNameAndPasswd(textBox1.Text.Trim(), maskedTextBox1.Text.Trim());
                Logger.Info(accountProperty.UserId + "," + accountProperty.Job + " logged in");

            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not connect to the server.Please contact the admin");
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);
                return;

            }

            if (accountProperty== null)
            {
                MessageBox.Show("Invalid Name or Password");

            }
            else
            {
                UserInfo.UserId = accountProperty.UserId;
                UserInfo.UserName = accountProperty.AccountName;
                UserInfo.Job = (JobDescription)accountProperty.Job;

                MainFrame mainFrame = new MainFrame();
                this.Hide();
                mainFrame.WindowState = FormWindowState.Maximized;
                mainFrame.Show();

            }
        }