Ejemplo n.º 1
0
        //”提交“按钮
        private void button1_Click(object sender, EventArgs e)
        {
            int isTe;

            if (textBox1.Text == "" || textBox2.Text == "" || comboBox2.Text == "" || comboBox1.Text == "")
            {
                MessageBox.Show("请输入完整信息!");
            }
            else
            {
                if (comboBox2.Text == "已参加过考试")
                {
                    isTe = 1;
                }
                else
                {
                    isTe = 0;
                }

                if (ComVal.StuNA == "")
                {  //s说明是添加的操作
                    string sql = "insert into UserInfo(userIde,userName,userAcc,userPwd,isTest,userSex,picPath) values(0,'"
                                 + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "'," + isTe + ",'" + comboBox1.Text + "','" + ComVal.PicPath + "')";
                    DataClass.OperaData(sql);
                }
                else
                {
                    //说明这是修改的操作
                    //修改成功后,释放ComVal中存放的相关数据,方便再次操作
                    ComVal.StuNA = "";

                    string sql = "update UserInfo set userAcc='" + textBox2.Text + "',userPwd='"
                                 + textBox3.Text + "',isTest=" + isTe + ",userSex='" + comboBox1.Text + "',picPath='" + ComVal.PicPath + "' where userName='******'";
                    DataClass.OperaData(sql);
                }
                StuManage stum = new StuManage();
                Admin.stum.Show();                    //打开之前隐藏的”学生管理“窗体
                Admin.stum.StuManage_Load(sender, e); //刷新
                this.Close();
            }
        }
Ejemplo n.º 2
0
        public static StuManage stum; //声明静态公有变量
        public void Admin_Load(object sender, EventArgs e)
        {
            stum = new StuManage();                               //创建”学生管理“窗体的实例
            menuStrip1.BackColor             = Color.Transparent;
            statusStrip1.BackColor           = Color.Transparent; //设置底色透明
            dataGridView1.AllowUserToAddRows = false;
            dataGridView2.AllowUserToAddRows = false;             //禁止显示最后一行
            toolStripStatusLabel1.Text       = "姓名:" + ComVal.userName + "   身份:管理员";
            string sql =
                "select ID as 系统编号,question as 选择题题目,A as 选项A ,B as 选项B ,C as 选项C ,D as 选项D ,rightKey as 正确选项 from TestInfo where testType=0";

            DataClass.DataGridViewBing(dataGridView1, sql);//显示选择题
            string sql1 = "select ID as 系统编号,question as 判断题题目,rightKey as 真假判断 from TestInfo where testType=1";

            DataClass.DataGridViewBing(dataGridView2, sql1);//显示判断题

            //设置dataGridView的显示大小
            dataGridView1.Columns[1].Width = dataGridView1.Columns[2].Width = dataGridView1.Columns[3].Width = dataGridView1.Columns[4].Width = dataGridView1.Columns[5].Width = 170;
            dataGridView2.Columns[0].Width = 80;  //设置第一列宽度
            dataGridView2.Columns[1].Width = 910; //设置第二例宽度
            dataGridView2.Columns[2].Width = 80;  //设置第二例宽度
        }