Пример #1
0
 public int DataInsert(User user)
 {
     ConnectionOpen();
     string sql = "insert into User(UserID,UserName,UserRole,Assigned,LuckyDog,IsLuckyDog,UserDescribe) Values(" + user.UserID + "," + user.UserName + "," + user.UserRole + "," + user.Assigned + "," + user.LuckyDog + "," + user.IsLuckyDog + "," + user.UserDescribe + ")";
     OleDbCommand cmd = new OleDbCommand(sql, oleConnection);
     int result;
     try
     {
         result = cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw new ADOException() { msg = "数据插入失败失败" };
     }
     finally
     {
         ConnectionClosed();
     }
     return result;
 }
Пример #2
0
        private void stopDraw()
        {
            if (thread.ThreadState != ThreadState.Unstarted)
            {
                this.btnStart.Text = "开始";
                thread.Suspend();
                try
                {
                    foreach (User user in _allUsers)
                    {
                        if (user.Assigned == nowAward.AwardType)
                        {
                            tempUser = user;
                        }
                    }
                    tempUser.IsLuckyDog = 1;
                    tempUser.LuckyDog = nowAward.AwardType;
                    ADO.GetEntity().DataUpdate(tempUser);
                    nowAward.AwardNumber--;
                    ADO.GetEntity().DataUpdateAward(nowAward);
                    if (nowAward.AwardNumber <= 0)
                    {
                        allAward.Remove(nowAward);
                        if (allAward.Count <= 0)
                        {
                            DrawOver();
                        }
                    }
                }
                catch (ADOException ex)
                {
                    MessageBox.Show(ex.msg);
                }
                this.lbLuckyDog.Text = tempUser.UserDescribe + "——" + tempUser.UserName;

                allUsers.Remove(tempUser);
            }
        }
Пример #3
0
 private void ChangeNumberLable()
 {
     allUsers = RandomSort(allUsers);
     int i = allUsers.Count - 1;
     while (true)
     {
         tempUser = allUsers[i];
         lbNumber.Text = tempUser.UserID;
         lbNumber.Refresh();
         Thread.Sleep(30);
         i--;
         if (i < 0)
         {
             i = allUsers.Count - 1;
         }
     }
 }
Пример #4
0
        public List<User> DataMultipleSelect(string sql)
        {
            List<User> users = new List<User>();
            ConnectionOpen();
            OleDbDataAdapter oleDA = new OleDbDataAdapter(sql, oleConnection);
            DataSet ds = new DataSet();
            try
            {
                oleDA.Fill(ds);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    User user = new User();
                    user.ID = Convert.ToInt32(row["ID"]);
                    user.UserID = row["UserID"].ToString();
                    user.UserName = row["UserName"].ToString();
                    user.UserRole = row["UserRole"].ToString();
                    user.Assigned = row["Assigned"].ToString();
                    user.LuckyDog = row["LuckyDog"].ToString();
                    user.IsLuckyDog = Convert.ToInt32(row["IsLuckyDog"]);
                    user.UserDescribe = row["UserDescribe"].ToString();
                    users.Add(user);
                }

            }
            catch (Exception ex)
            {
                new ADOException() { msg = "数据检索失败" };
            }
            finally
            {
                ConnectionClosed();
            }
            return users;
        }
Пример #5
0
        public int DataUpdate(User user)
        {
            ConnectionOpen();

            string sql = "update [User] set ";
            sql = (user.UserID == "") ? sql : sql + " UserID = '" + user.UserID+"'";
            sql = (user.UserName == "") ? sql : sql + ",UserName = '******'";
            sql = (user.UserRole == "") ? sql : sql + ",UserRole = '" + user.UserRole + "'";
            sql = (user.Assigned == "") ? sql : sql + ",Assigned = '" + user.Assigned + "'";
            sql = (user.LuckyDog == "") ? sql : sql + ",LuckyDog = '" + user.LuckyDog + "'";
            sql = (user.IsLuckyDog == 0) ? sql : sql + ",IsLuckyDog = " + user.IsLuckyDog;
            sql = (user.UserDescribe == "") ? sql : sql + ",UserDescribe = '" + user.UserDescribe + "'";
            sql = sql + " where ID = " + user.ID;
            OleDbCommand cmd = new OleDbCommand(sql, oleConnection);
            int result;
            try
            {
                result = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new ADOException() { msg = "数据更新失败" };
            }
            finally
            {
                ConnectionClosed();
            }
            return result;
        }
Пример #6
0
 public User DataSingleSelect(string sql)
 {
     ConnectionOpen();
     OleDbCommand cmd = new OleDbCommand(sql, oleConnection);
     User user = new User();
     try
     {
         OleDbDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             user.ID = Convert.ToInt32(reader["ID"]);
             user.UserID = reader["UserID"].ToString();
             user.UserName = reader["UserName"].ToString();
             user.UserRole = reader["UserRole"].ToString();
             user.Assigned = reader["Assigned"].ToString();
             user.LuckyDog = reader["LuckyDog"].ToString();
             user.IsLuckyDog = Convert.ToInt32(reader["IsLuckyDog"]);
             user.UserDescribe = reader["UserDescribe"].ToString();
         }
     }
     catch (Exception ex)
     {
         new ADOException() { msg = "数据检索失败" };
     }
     finally
     {
         ConnectionClosed();
     }
     return user;
 }