示例#1
0
 //退出团队
 private void button3_Click(object sender, EventArgs e)
 {
     if (teamnumberbox.Text.Trim() == "")
     {
         MessageBox.Show("已退出团队!");
     }
     else if (id == mygroupshow.Rows[0]["memberoneid"].ToString())
     {
         DialogResult dr = MessageBox.Show("确定退出团队?", "退出团队", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             mygroupshow.Rows[0]["memberoneid"]   = null;
             mygroupshow.Rows[0]["memberonename"] = null;
             mygroupshow.Rows[0]["mnumber"]       = (int)mygroupshow.Rows[0]["mnumber"] - 1;
             SqlDbHelper.updatedatatable(mygroupshow, "team");
             SqlDbHelper.ExecuteNonQuery(string.Format("update stupasswordtable set groupID='0' where account='{0}' ", memberoneid.Text));
             clear();
         }
     }
     else if (id == mygroupshow.Rows[0]["membertwoid"].ToString())
     {
         DialogResult dr = MessageBox.Show("确定退出团队?", "退出团队", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             mygroupshow.Rows[0]["membertwoid"]   = null;
             mygroupshow.Rows[0]["membertwoname"] = null;
             mygroupshow.Rows[0]["mnumber"]       = (int)mygroupshow.Rows[0]["mnumber"] - 1;
             SqlDbHelper.updatedatatable(mygroupshow, "team");
             SqlDbHelper.ExecuteNonQuery(string.Format("update stupasswordtable set groupID='0' where account='{0}' ", membertwoid.Text));
             clear();
         }
     }
     else if (id == mygroupshow.Rows[0]["memberthreeid"].ToString())
     {
         DialogResult dr = MessageBox.Show("确定退出团队?", "退出团队", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             mygroupshow.Rows[0]["memberthreeid"]   = null;
             mygroupshow.Rows[0]["memberthreename"] = null;
             mygroupshow.Rows[0]["mnumber"]         = (int)mygroupshow.Rows[0]["mnumber"] - 1;
             SqlDbHelper.updatedatatable(mygroupshow, "team");
             SqlDbHelper.ExecuteNonQuery(string.Format("update stupasswordtable set groupID='0' where account='{0}' ", memberthreeid.Text));
             clear();
         }
     }
 }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dr   = MessageBox.Show("确定解散团队?", "删除团队", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            DataTable    will = SqlDbHelper.ExecuteDataTable(string.Format("select * from will where stuid='{0}'", id));

            if (dr == DialogResult.Yes)
            {
                mygroupshow.Rows[0].Delete();
                SqlDbHelper.updatedatatable(mygroupshow, "team");
                if (will.Rows.Count != 0)
                {
                    will.Rows[0].Delete();
                    SqlDbHelper.updatedatatable(will, "will");
                }
                //will.Rows[0].Delete();
                //SqlDbHelper.updatedatatable(will, "will");
                SqlDbHelper.ExecuteNonQuery(string.Format("update stupasswordtable set groupID='0' where account='{0}' or account='{1}' or account='{2}' or account='{3}'", captainidbox.Text, memberoneid.Text, membertwoid.Text, memberthreeid.Text));
                clear();
            }
            else
            {
            }
        }
示例#3
0
 private void thirdwill_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (thirdwill.Columns[e.ColumnIndex].Name == "退选")
     {
         SqlDataReader readcaptainid = SqlDbHelper.ExecuteReader(string.Format("select captainid from team where teamnumber=(select teamnumber from team where captainid='{0}' or memberoneid='{0}' or membertwoid='{0}' or memberthreeid='{0}')", id));
         if (readcaptainid.HasRows)
         {
             readcaptainid.Read();
             SqlDataReader readnumber = SqlDbHelper.ExecuteReader(string.Format("select mnumber from team where captainid='{0}'", readcaptainid[0].ToString()));
             readnumber.Read();
             if (id == readcaptainid[0].ToString())
             {
                 SqlDbHelper.ExecuteNonQuery(string.Format("update will set thirdwill = NULL,thirdwillname = NULL,isaccess3=NULL where stuid='{0}'", id));
                 label4.Text = "已成功退选第三志愿!";
                 thirdwill.Rows.Clear();
                 thirdwill.Columns.Remove("退选");
             }
             else
             {
                 MessageBox.Show("仅能由队长退选志愿");
             }
         }
     }
 }
示例#4
0
        //保存团队
        private void createteam_Click_1(object sender, EventArgs e)
        {
            string[,] teamlist = new string[3, 2];//记录保存编辑的成员信息
            DataTable team = SqlDbHelper.ExecuteDataTable(string.Format("select * from team where teamnumber='{0}'", teamid.Text));

            //在重新编辑时,把旧队员的groupID重新设置为0
            if (team.Rows.Count != 0)
            {
                //在重新编辑时,把旧队员的groupID重新设置为0
                //删除原有团队信息
                DataTable member1 = SqlDbHelper.ExecuteDataTable(string.Format("select captainid,memberoneid,membertwoid,memberthreeid from team where teamnumber='{0}' ", teamid.Text));
                SqlDbHelper.ExecuteNonQuery(string.Format("update stupasswordtable set groupID='0' where account='{0}' or account='{1}' or account='{2}' or account='{3}'", member1.Rows[0]["captainid"].ToString(), member1.Rows[0]["memberoneid"].ToString(), member1.Rows[0]["membertwoid"].ToString(), member1.Rows[0]["memberthreeid"].ToString()));
                DataTable teamdt = SqlDbHelper.ExecuteDataTable(string.Format("select * from team where teamnumber='{0}'", teamid.Text));
                teamdt.Rows[0].Delete();
                SqlDbHelper.updatedatatable(teamdt, "team");

                //最后把新团队的信息填充到team表,和更新学生账户表groupID
                DataTable dt = new DataTable();
                dt = SqlDbHelper.ExecuteDataTable("select * from team where 1=2");
                DataRow dr = dt.NewRow();


                for (int i = 0; i < 3; i++)
                {
                    if (!ismember(txts1[i].Text, txts[i].Text))
                    {
                        MessageBox.Show(string.Format("成员{0}不是本系统用户", i + 1));
                        return;
                    }
                }

                for (int i = 0; i < 3; i++)
                {
                    teamlist[i, 0] = txts[i].Text;  //学号
                    teamlist[i, 1] = txts1[i].Text; //姓名
                }
                if ((teamlist[1, 0] == teamlist[0, 0] && teamlist[1, 0] != null) || (teamlist[2, 0] == teamlist[1, 0] && teamlist[2, 0] != null) || (teamlist[2, 0] == teamlist[0, 0] && teamlist[2, 0] != null))
                {
                    MessageBox.Show("组员之间存在重复信息");
                    return;
                }

                dr["teamnumber"]     = teamid.Text;
                dr["topicname"]      = topicname.Text.Trim();
                dr["topicintroduce"] = topicintroduce.Text.Trim();
                dr["captainid"]      = captainid.Text;
                dr["captainname"]    = captainname.Text;

                for (int i = 0; i < 3; i++)
                {
                    dr[i * 2 + 5] = teamlist[i, 0];
                    dr[i * 2 + 4] = teamlist[i, 1];
                }

                dt.Rows.Add(dr);
                SqlDbHelper.UpdateDataTable(dt, "team");
                SqlDbHelper.ExecuteNonQuery(string.Format("update stupasswordtable set groupID='{0}' where account='{0}' or account='{1}' or account='{2}' or account='{3}'", teamid.Text, txts[0].Text, txts[1].Text, txts[2].Text));
                label1.Text = "已重新编辑团队!";
            }

            //在没有团队的情况下,创建团队
            else
            {
                DataTable dt = new DataTable();
                dt = SqlDbHelper.ExecuteDataTable("select * from team where 1=2");
                DataRow dr = dt.NewRow();

                for (int i = 0; i < 3; i++)
                {
                    if (!ismember(txts1[i].Text, txts[i].Text))
                    {
                        MessageBox.Show(string.Format("成员{0}不是本系统用户", i + 1));
                        return;
                    }
                }

                for (int i = 0; i < 3; i++)
                {
                    teamlist[i, 0] = txts[i].Text;  //学号
                    teamlist[i, 1] = txts1[i].Text; //姓名
                }


                if ((teamlist[1, 0] == teamlist[0, 0] && teamlist[1, 0] != "") || (teamlist[2, 0] == teamlist[1, 0] && teamlist[2, 0] != "") || (teamlist[2, 0] == teamlist[0, 0] && teamlist[2, 0] != ""))
                {
                    MessageBox.Show("组员之间存在重复信息");
                    return;
                }

                dr["teamnumber"]     = teamid.Text;
                dr["topicname"]      = topicname.Text.Trim();
                dr["topicintroduce"] = topicintroduce.Text.Trim();
                dr["captainid"]      = captainid.Text;
                dr["captainname"]    = captainname.Text;

                for (int i = 0; i < 3; i++)
                {
                    dr[i * 2 + 5] = teamlist[i, 0];
                    dr[i * 2 + 4] = teamlist[i, 1];
                }

                dt.Rows.Add(dr);
                SqlDbHelper.UpdateDataTable(dt, "team");
                label1.Text = "已创建团队!";
                SqlDbHelper.ExecuteNonQuery(string.Format("update stupasswordtable set groupID='{0}' where account='{0}' or account='{1}' or account='{2}' or account='{3}'", teamid.Text, mbs[0].id1, mbs[1].id1, mbs[2].id1));
            }
        }