Example #1
0
 private bool alterMatchInfo(SeasonMatch match)
 {
     if (textBox_switchNum.Text == "" || textBox_serialNum.Text == "")
     {
         MessageBox.Show("转换数量或轮次数量不能为空", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
         return false;
     }
     else
     {
         //检查数量是否正确
         if (!checkSwitchResult.checkStringSwitchInteger(textBox_switchNum.Text))
         {
             MessageBox.Show("转换次数必须是数字", "非数字", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
             return false;
         }
         if (!checkSwitchResult.checkStringSwitchInteger(textBox_serialNum.Text))
         {
             MessageBox.Show("赛事轮次必须是数字", "非数字", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
             return false;
         }
         int switchNum = Convert.ToInt32(textBox_switchNum.Text);
         int serialNum = Convert.ToInt32(textBox_serialNum.Text);
         match.setName(textBox_name.Text);
         match.setDescription(richTextBox_description.Text);
         match.setSwitchNum(switchNum);
         match.setSerialNum(serialNum);
         //更新数据库操作
         MatchInfoDAO.updateMatchInfo(match);
         //关闭本页面
         return true;
     }
 }
Example #2
0
 //往数据库中添加赛事,并且返回新被添加的赛事
 public static SeasonMatch addNewMatch(string name,string description,int switchNum,int serialNum)
 {
     SeasonMatch match = new SeasonMatch();
     DBUtility dbutility = new DBUtility();
     int matchID;
     string SQL = "insert into matchinfo(seasonName,description,switchNum,serialNum) values('";
     SQL=SQL+name + "','" + description + "'," + switchNum + "," + serialNum + ")";
     try
     {
         dbutility.openConnection();
         matchID = dbutility.ExecuteQuery_Last_Insert_ID(SQL);
        // dbutility.ExecuteUpdate(SQL);
         match.setID(matchID);
         match.setName(name);
         match.setDescription(description);
         match.setSwitchNum(switchNum);
         match.setSerialNum(serialNum);
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return match;
 }
Example #3
0
        //依据赛事名称,返回赛事信息
        public static SeasonMatch getMatchInfo(string matchName)
        {
            SeasonMatch match = new SeasonMatch();
            //执行查询数据库操作
            DBUtility dbutility = new DBUtility();
            string SQL = "select ID,seasonName,description,switchNum,serialNum from matchinfo where seasonName='" + matchName + "'";
            try
            {
                dbutility.openConnection();
                MySqlDataReader rd = dbutility.ExecuteQuery(SQL);
                while (rd.Read())
                {
                    match.setID(Convert.ToInt32(rd[0]));
                    match.setName(Convert.ToString(rd[1]));
                    match.setDescription(Convert.ToString(rd[2]));
                    match.setSwitchNum(Convert.ToInt32(rd[3]));
                    match.setSerialNum(Convert.ToInt32(rd[4]));

                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                dbutility.Close();
            }
            return match;
        }