private void btn_close_Click(object sender, EventArgs e)
        {
            Close();
            Form_adminMain adminMain = new Form_adminMain();

            adminMain.ShowDialog();
        }
Ejemplo n.º 2
0
        private void delete(String teacherid)
        {
            try
            {
                string        strCon    = "server=127.0.0.1;uid=sa;pwd=123456;database=ClassAttendanceManageSystem";
                SqlConnection myconn    = new SqlConnection(strCon);
                DataSet       myDataSet = new DataSet();
                string        strcom    = "Select *from teacherInfo";
                string        str       = "DELETE FROM teacherInfo WHERE teacherID ='" + teacherid + "'";
                myconn.Open();
                SqlCommand xg;
                xg = new SqlCommand(str, myconn);

                if (xg.ExecuteNonQuery() > 0) //判断是否成功
                {                             //执行要操作的语句
                    SqlDataAdapter mycommand = new SqlDataAdapter(strcom, myconn);
                    myDataSet.Clear();
                    mycommand.Fill(myDataSet, "teacherInfo");
                    //adminMain.dataGridView1.DataSource = myDataSet.Tables["systemStudent"];
                    MessageBox.Show("删除成功", "提示");
                    Close();
                    Form_adminMain adminMain = new Form_adminMain();
                    adminMain.ShowDialog();
                }
                myconn.Close();
            }
            catch (Exception x)
            {
                MessageBox.Show("error!" + x.ToString());
            }
        }
Ejemplo n.º 3
0
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            Form_adminMain a = new Form_adminMain();

            a.Show();
        }
        private void btn_close_Click(object sender, EventArgs e)
        {
            this.Close();
            Form_adminMain a = new Form_adminMain();

            a.Show();
        }
        private void btQuit_Click(object sender, EventArgs e)
        {
            btClose_Click(null, null);
            this.Close();
            Form_adminMain a = new Form_adminMain();

            a.ShowDialog();
        }
Ejemplo n.º 6
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (!judge())
            {
                MessageBox.Show("请正确输入信息", "提示");
                return;
            }

            try
            {
                if (RB1.Checked)
                {
                    sex = RB1.Text;   //取性别值
                }
                else
                {
                    sex = RB2.Text;
                }

                string        strCon    = "server=127.0.0.1;uid=sa;pwd=123456;database=ClassAttendanceManageSystem";
                SqlConnection myconn    = new SqlConnection(strCon);
                DataSet       myDataSet = new DataSet();
                string        strcom    = "Select *from teacherInfo";
                string        str       = "insert into teacherInfo VALUES ('" + textBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + sex.Trim() + "','" + textBox3.Text.Trim() + "','" + textBox4.Text.Trim() + "')";
                myconn.Open();
                SqlCommand xg;
                xg = new SqlCommand(str, myconn);

                if (xg.ExecuteNonQuery() > 0) //判断插入数据是否成功
                {                             //执行要操作的语句
                    SqlDataAdapter mycommand = new SqlDataAdapter(strcom, myconn);
                    myDataSet.Clear();
                    mycommand.Fill(myDataSet, "teacherInfo");
                    //adminMain.dataGridView1.DataSource = myDataSet.Tables["systemStudent"];
                    MessageBox.Show("添加成功", "提示");
                    Close();
                    Form_adminMain adminMain = new Form_adminMain();
                    adminMain.ShowDialog();
                }
                myconn.Close();
            }
            catch (Exception x)
            {
                MessageBox.Show("error!" + x.ToString());
            }
        }
        private void btn_change_Click(object sender, EventArgs e)
        {
            try
            {
                if (RB1.Checked)
                {
                    sex = RB1.Text;   //取性别值
                }
                else
                {
                    sex = RB2.Text;
                }

                string        strCon    = "server=127.0.0.1;uid=sa;pwd=123456;database=ClassAttendanceManageSystem";
                SqlConnection myconn    = new SqlConnection(strCon);
                DataSet       myDataSet = new DataSet();
                string        strcom    = "Select *from studentInfo";
                string        str       = "UPDATE studentInfo SET stuID='" + textBox1.Text.Trim() + "',stuName='" + textBox2.Text.Trim() + "',stuSex='" + sex.Trim() + "',classID='" + textBox4.Text.Trim() + "',className='" + textBox6.Text.Trim() + "',cardID='" + textBox8.Text.Trim() + "',courseID='" + textBox9.Text.Trim() + "',stuPassword='******' where stuID='" + textBox1.Text + "'";
                myconn.Open();
                SqlCommand xg;
                xg = new SqlCommand(str, myconn);

                if (xg.ExecuteNonQuery() > 0) //判断插入数据是否成功
                {                             //执行要操作的语句
                    SqlDataAdapter mycommand = new SqlDataAdapter(strcom, myconn);
                    myDataSet.Clear();
                    mycommand.Fill(myDataSet, "studentInfo");
                    //adminMain.dataGridView1.DataSource = myDataSet.Tables["systemStudent"];
                    MessageBox.Show("修改成功", "提示");
                    Close();
                    Form_adminMain adminMain = new Form_adminMain();
                    adminMain.ShowDialog();
                }
                myconn.Close();
            }
            catch (Exception x)
            {
                MessageBox.Show("error!" + x.ToString());
            }
        }
Ejemplo n.º 8
0
        private void button_login_Click(object sender, EventArgs e)
        {
            //这里写入刚刚的判断语句

            if (!judge())
            {
                MessageBox.Show("账号或密码为空,请正确输入信息", "提示");

                return;
            }

            try
            {
                string        strCon     = "server=127.0.0.1;uid=sa;pwd=123456;database=ClassAttendanceManageSystem";
                SqlConnection connection = new SqlConnection(strCon);
                DataSet       myDataSet  = new DataSet();

                if (flag == 1) //radioButton1_stu  判断是否为学生用户
                {
                    string sql = "Select *from studentInfo where stuID ='" + textBox1.Text.Trim() +
                                 "' and stuPassword='******'";
                    connection.Open();
                    SqlDataAdapter mycommand = new SqlDataAdapter(sql, connection);
                    myDataSet.Clear();
                    mycommand.Fill(myDataSet, "studentInfo");
                    connection.Close();

                    if (myDataSet.Tables["studentInfo"].Rows.Count > 0)
                    {
                        MessageBox.Show("登录成功!", "提示");
                        this.Visible = false;
                        Form_studentMain stu = new Form_studentMain();
                        str  = textBox1.Text; //注意,这句不能放在stu.Show();的后面,否则将传值不到其他窗体;会先执行textBox2.Text =stu.str;再执行str = textBox1.Text;
                        str1 = textBox2.Text; //保存密码
                        stu.Show();
                    }
                    else
                    {
                        MessageBox.Show("用户名或密码错误!", "提示");
                    }
                }

                else if (flag == 2)
                {
                    string sql = "Select *from teacherInfo where teacherID ='" + textBox1.Text.Trim() + "' and teacherPassword='******'";
                    connection.Open();
                    SqlDataAdapter mycommand = new SqlDataAdapter(sql, connection);
                    myDataSet.Clear();
                    mycommand.Fill(myDataSet, "teacherInfo");
                    connection.Close();

                    if (myDataSet.Tables["teacherInfo"].Rows.Count > 0)
                    {
                        MessageBox.Show("登录成功!", "提示");
                        this.Visible = false;
                        Form_teacherMain a = new Form_teacherMain();
                        str  = textBox1.Text; //注意,这句不能放在f2.ShowDialog();的后面,否则会先执行textBox2.Text = f1.str;再执行str = textBox1.Text;
                        str1 = textBox2.Text; //保存密码
                        a.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("用户名或密码错误!", "提示");
                    }
                }
                else if (flag == 3)
                {
                    string sql = "Select *from adminInfo where adminID ='" + textBox1.Text.Trim() + "' and adminPassword='******'";
                    connection.Open();
                    SqlDataAdapter mycommand = new SqlDataAdapter(sql, connection);
                    myDataSet.Clear();
                    mycommand.Fill(myDataSet, "adminInfo");
                    connection.Close();

                    if (myDataSet.Tables["adminInfo"].Rows.Count > 0)
                    {
                        MessageBox.Show("登录成功!", "提示");
                        this.Visible = false;
                        Form_adminMain a = new Form_adminMain();
                        str  = textBox1.Text; //注意,这句不能放在f2.ShowDialog();的后面,否则会先执行textBox2.Text = f1.str;再执行str = textBox1.Text;
                        str1 = textBox2.Text; //保存密码
                        a.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("用户名或密码错误!", "提示");
                    }
                }
                else
                {
                    MessageBox.Show("请选择用户类型!", "提示");
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("error!" + x.ToString());
            }
        }