Beispiel #1
0
        private void summit_Click(object sender, EventArgs e)
        {
            SqlDataReader reader = SqlDbHelper.ExecuteReader(string.Format("select name from stupasswordtable where account='{0}'", id));

            reader.Read();

            int       count       = 0;
            string    willteaid   = null;
            string    willteaname = null;
            DataTable table       = SqlDbHelper.ExecuteDataTable(string.Format("select * from team where captainid='{0}' or memberoneid='{0}' or membertwoid='{0}' or memberthreeid='{0}'", id)); //获取团队信息  以表形式呈现
            DataTable a           = SqlDbHelper.ExecuteDataTable(string.Format("select * from will where stuid='{0}'", table.Rows[0]["teamnumber"].ToString()));                                  //获取当前团队的志愿表 有行则已经填报过

            string[] mywill = new string[3] {
                null, null, null
            };

            if (a.Rows.Count != 0)
            {
                mywill[0] = a.Rows[0]["firstwill"].ToString();
                mywill[1] = a.Rows[0]["secondwill"].ToString();
                mywill[2] = a.Rows[0]["thirdwill"].ToString();
            }


            foreach (tea_show b in teashow)
            {
                if (b != null)
                {
                    if (b.ischoose)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            if (b.teaid == mywill[i])
                            {
                                MessageBox.Show("已经选择过该导师啦");
                                return;
                            }
                        }
                        willteaid   = b.teaid;
                        willteaname = b.teaname;
                        count++;
                    }
                }
            }

            if (count == 0)
            {
                MessageBox.Show("还没有选择导师哟");
                return;
            }
            else if (count == 1)
            {
                try
                {
                    if (table.Rows.Count != 0)                           //当前有这个团队
                    {
                        if (id == table.Rows[0]["captainid"].ToString()) //判断当前角色是否是队长
                        {
                            if (a.Rows.Count != 0)                       //判断当前团队是否有填报过志愿
                            {
                                switch (whichwill.SelectedItem.ToString())
                                {
                                case "第一志愿":
                                    if (a.Rows[0].IsNull("firstwill"))
                                    {
                                        a.Rows[0]["firstwill"]     = willteaid;
                                        a.Rows[0]["firstwillname"] = willteaname;
                                        a.Rows[0]["isaccess1"]     = 0;
                                    }
                                    else
                                    {
                                        MessageBox.Show("已经填报第一志愿,如需修改请先退选");
                                        return;
                                    }
                                    break;

                                case "第二志愿":
                                    if (a.Rows[0].IsNull("secondwill"))
                                    {
                                        a.Rows[0]["secondwill"]     = willteaid;
                                        a.Rows[0]["secondwillname"] = willteaname;
                                        a.Rows[0]["isaccess2"]      = 0;
                                    }
                                    else
                                    {
                                        MessageBox.Show("已经填报第二志愿,如需修改请先退选");
                                        return;
                                    }
                                    break;

                                case "第三志愿":
                                    if (a.Rows[0].IsNull("thirdwill"))
                                    {
                                        a.Rows[0]["thirdwill"]     = willteaid;
                                        a.Rows[0]["thirdwillname"] = willteaname;
                                        a.Rows[0]["isaccess3"]     = 0;
                                    }
                                    else
                                    {
                                        MessageBox.Show("已经填报第三志愿,如需修改请先退选");
                                        return;
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                            else
                            {
                                DataRow newteawill = a.NewRow();
                                newteawill["stuname"]     = table.Rows[0]["captainname"];
                                newteawill["stuid"]       = table.Rows[0]["teamnumber"];
                                newteawill["subjectname"] = table.Rows[0]["topicname"];
                                newteawill["isteam"]      = 1;

                                switch (whichwill.SelectedItem.ToString())
                                {
                                case "第一志愿":
                                    newteawill["firstwill"]     = willteaid;
                                    newteawill["firstwillname"] = willteaname;
                                    newteawill["isaccess1"]     = 0;
                                    break;

                                case "第二志愿":
                                    newteawill["secondwill"]     = willteaid;
                                    newteawill["secondwillname"] = willteaname;
                                    newteawill["isaccess2"]      = 0;
                                    break;

                                case "第三志愿":
                                    newteawill["thirdwill"]     = willteaid;
                                    newteawill["thirdwillname"] = willteaname;
                                    newteawill["isaccess3"]     = 0;
                                    break;

                                default:
                                    break;
                                }
                                a.Rows.Add(newteawill);
                            }

                            try
                            {
                                SqlDbHelper.updatedatatable(a, "will");

                                label2.Text = whichwill.Text + "已选择" + willteaname;
                            }
                            catch (System.Data.SqlClient.SqlException)
                            {
                                MessageBox.Show("请完善课题信息或先填报其他志愿");
                            }
                        }
                        else
                        {
                            MessageBox.Show("请由队长来填报志愿");
                        }
                    }
                    else
                    {
                        MessageBox.Show("暂无团队信息");
                    }
                }
                catch (System.NullReferenceException)
                {
                    MessageBox.Show("未选中志愿");
                }
            }

            else if (count > 1)
            {
                MessageBox.Show("一次志愿只能填一位导师哟");
                return;
            }
        }
Beispiel #2
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));
            }
        }
Beispiel #3
0
        private void my_will_Load(object sender, EventArgs e)
        {
            DataTable teamwill = SqlDbHelper.ExecuteDataTable(string.Format("select * from will where stuid=(select teamnumber from team where captainid='{0}' or memberoneid='{0}' or membertwoid='{0}' or memberthreeid='{0}')", id));

            if (teamwill.Rows.Count != 0)
            {
                //firstwill.Rows[0].DefaultCellStyle = new DataGridViewCellStyle { Font = new Font("微软雅黑, 9pt", 11F, FontStyle.Bold) };
                firstwill.Rows[0].Cells[0].Value = teamwill.Rows[0]["firstwillname"].ToString();;
                firstwill.Rows[0].Cells[1].Value = teamwill.Rows[0]["firstwill"].ToString();
                if (teamwill.Rows[0]["isaccess1"].ToString() == "False")
                {
                    firstwill.Rows[0].Cells[2].Value = "未预选";
                    DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
                    btn.Name = "退选";
                    btn.UseColumnTextForButtonValue = true;
                    btn.DefaultCellStyle.NullValue  = "退选";
                    //btn.Text = "退选";
                    btn.HeaderText = "退选";
                    firstwill.Columns.Insert(firstwill.Columns.Count, btn);
                }
                else if (teamwill.Rows[0]["isaccess1"].ToString() == "True")
                {
                    firstwill.Rows[0].Cells[2].Value = "已预选";
                }

                secondwill.Rows[0].Cells[0].Value = teamwill.Rows[0]["secondwillname"].ToString();
                secondwill.Rows[0].Cells[1].Value = teamwill.Rows[0]["secondwill"].ToString();
                if (teamwill.Rows[0]["isaccess2"].ToString() == "False")
                {
                    secondwill.Rows[0].Cells[2].Value = "未预选";
                    DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
                    btn.Name = "退选";
                    btn.UseColumnTextForButtonValue = true;
                    btn.DefaultCellStyle.NullValue  = "退选";
                    btn.Text       = "退选";
                    btn.HeaderText = "退选";
                    secondwill.Columns.Insert(secondwill.Columns.Count, btn);
                }
                else if (teamwill.Rows[0]["isaccess2"].ToString() == "True")
                {
                    secondwill.Rows[0].Cells[2].Value = "已预选";
                }

                thirdwill.Rows[0].Cells[0].Value = teamwill.Rows[0]["thirdwillname"].ToString();
                thirdwill.Rows[0].Cells[1].Value = teamwill.Rows[0]["thirdwill"].ToString();
                if (teamwill.Rows[0]["isaccess3"].ToString() == "False")
                {
                    thirdwill.Rows[0].Cells[2].Value = "未预选";
                    DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
                    btn.Name = "退选";
                    btn.UseColumnTextForButtonValue = true;
                    btn.DefaultCellStyle.NullValue  = "退选";
                    btn.Text       = "退选";
                    btn.HeaderText = "退选";
                    thirdwill.Columns.Insert(thirdwill.Columns.Count, btn);
                }
                else if (teamwill.Rows[0]["isaccess3"].ToString() == "True")
                {
                    thirdwill.Rows[0].Cells[2].Value = "已预选";
                }
            }
            else
            {
                firstwill.Rows[0].Cells[0].Value  = null;
                firstwill.Rows[0].Cells[1].Value  = null;
                secondwill.Rows[0].Cells[0].Value = null;
                secondwill.Rows[0].Cells[1].Value = null;
                thirdwill.Rows[0].Cells[0].Value  = null;
                thirdwill.Rows[0].Cells[1].Value  = null;
            }

            //分配结果
            finish.DataSource = bll.sure(id);
        }