예제 #1
0
 public Staffs(Staffs staff)
 {
     // TODO: Complete member initialization
     this.Sid  = staff.Sid;
     this.Pass = staff.Pass;
     this.Name = staff.Name;
     this.Pos  = staff.Pos;
 }
예제 #2
0
 private bool SignSql()
 {
     sqlhelper = new MySqlHelper(poweruser, powerpwd, sysdatabase);
     if (sqlhelper.Connect())
     {
         string sqlword;
         if (ID_LEVEL.SelectedIndex == 0) //user
         {
             sqlword  = "select * from " + ID_LEVEL.Text;
             sqlword += " where uid = " + addstring(UserBox.Text);
         }
         else
         {
             sqlword  = "select * from " + ID_LEVEL.Text;
             sqlword += " where sid = " + addstring(UserBox.Text);
         }
         MySqlDataReader sqlR = sqlhelper.ExecuteReader(sqlword);
         if (sqlR == null)
         {
             MessageBox.Show("服务器抛出异常");
             return(false);
         }
         if (sqlR.Read())
         {
             if (sqlR.FieldCount == 4)//staff
             {
                 staff      = new Staffs();
                 staff.Sid  = sqlR[0].ToString();
                 staff.Pass = sqlR[1].ToString();
                 staff.Name = sqlR[2].ToString();
                 staff.Pos  = sqlR[3].ToString();
                 if (staff.Pass == PassBox.Text)
                 {
                     power = true;
                     return(true);
                 }
                 else
                 {
                     MessageBox.Show("口令错误");
                     return(false);
                 }
             }
             else if (sqlR.FieldCount == 7)//user
             {
                 user            = new Users();
                 user.Uid        = sqlR[0].ToString();
                 user.Pass       = sqlR[1].ToString();
                 user.Name       = sqlR[2].ToString();
                 user.Mail       = sqlR[3].ToString();
                 user.Phone      = sqlR[4].ToString();
                 user.Address    = sqlR[5].ToString();
                 user.Blacklabel = (bool)sqlR[6];
                 if (user.Pass == PassBox.Text)
                 {
                     power = false;
                     return(true);
                 }
                 else
                 {
                     MessageBox.Show("口令错误");
                     return(false);
                 }
             }
             else
             {
                 MessageBox.Show("没有该 " + ID_LEVEL.Text);
             }
             sqlR.Close();
             sqlR.Dispose();
             sqlhelper.Close();
             sqlhelper.Dispose();
             return(false);
         }
     }
     else
     {
         MessageBox.Show("failed to connect");
         return(false);
     }
     MessageBox.Show("没有该 " + ID_LEVEL.Text);
     return(false);
 }