Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string Tno   = textBox1.Text.Trim();
            string Tname = textBox2.Text;
            string Sex   = textBox3.Text;
            string Age   = textBox4.Text;
            string Prof  = textBox5.Text;
            string Sal   = textBox6.Text;
            string Dept  = textBox7.Text;

            Teacher.TeacherInfoData data = new Teacher.TeacherInfoData();

            data.Tno   = Tno;
            data.Tname = Tname;
            data.Sex   = Sex;
            data.Age   = Age;
            data.Prof  = Prof;
            data.Sal   = Sal;
            data.Dept  = Dept;

            try
            {
                ds = Teacher.TeacherInfoOperation.getTeacherInfo(data);
                this.dataGridView1.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Beispiel #2
0
        public InsertTeacher(string flag)
        {
            InitializeComponent();

            comboBox3.Items.Add("男");
            comboBox3.Items.Add("女");

            this.comboBox5.Items.Add("教授");
            this.comboBox5.Items.Add("副教授");
            this.comboBox5.Items.Add("讲师");
            this.comboBox5.Items.Add("助教");

            this.comboBox8.Items.Add("计算机");
            this.comboBox8.Items.Add("电子商务");
            this.comboBox8.Items.Add("信科");
            this.comboBox8.Items.Add("信管");
            this.comboBox8.Items.Add("信息");
            this.FLAG = flag;

            textBox1.Text  = "";
            textBox2.Text  = "";
            comboBox3.Text = "";
            textBox4.Text  = "";
            comboBox5.Text = "";
            textBox6.Text  = "";
            textBox7.Text  = "";
            comboBox8.Text = "";


            if (flag != "")
            {
                Teacher.TeacherInfoData data = new Teacher.TeacherInfoData();
                data.Tno = flag;
                DataSet ds = Teacher.TeacherInfoOperation.getTeacherInfo(data);
                this.textBox1.Text    = flag;
                this.textBox2.Text    = ds.Tables[0].Rows[0]["教师名"].ToString();
                this.comboBox3.Text   = ds.Tables[0].Rows[0]["性别"].ToString();
                this.textBox4.Text    = ds.Tables[0].Rows[0]["年龄"].ToString();
                this.comboBox5.Text   = ds.Tables[0].Rows[0]["职称"].ToString();
                this.textBox6.Text    = ds.Tables[0].Rows[0]["薪水"].ToString();
                this.textBox7.Text    = ds.Tables[0].Rows[0]["津贴"].ToString();
                this.comboBox8.Text   = ds.Tables[0].Rows[0]["所教专业"].ToString();
                this.textBox1.Enabled = false;
                this.Text             = "Update";
            }
        }
Beispiel #3
0
        //获取查询教师信息
        public static DataSet getTeacherInfo(Teacher.TeacherInfoData data)
        {
            string condition = "";

            if (data.Tno != null && data.Tno != "")
            {
                condition += "and Tno='" + data.Tno + "'";
            }
            if (data.Tname != null && data.Tname != "")
            {
                condition += "and Tname='" + data.Tname + "'";
            }
            if (data.Sex != null && data.Sex != "")
            {
                condition += "and Sex='" + data.Sex + "'";
            }
            if (data.Age != null && data.Age != "")
            {
                condition += "and Age='" + data.Age + "'";
            }
            if (data.Prof != null && data.Prof != "")
            {
                condition += "and Prof='" + data.Prof + "'";
            }
            if (data.Sal != null && data.Sal != "")
            {
                condition += "and Sal='" + data.Sal + "'";
            }
            if (data.Comm != null && data.Comm != "")
            {
                condition += "and Comm='" + data.Comm + "'";
            }
            if (data.Dept != null && data.Dept != "")
            {
                condition += "and Dept='" + data.Dept + "'";
            }
            string sql = "select Tno 教师号,Tname 教师名, Sex 性别,Age 年龄,Prof 职称,Sal 薪水,Comm 津贴,Dept 所教专业 from Teacher where 2=2 " + condition;

            return(dataAccess.GetDataSet(sql, "Teacher"));
        }
Beispiel #4
0
        //修改教师信息
        public static bool updateTeacherInfo(Teacher.TeacherInfoData data)
        {
            string sql = "update Teacher set Tname='" + data.Tname + "',Sex='" + data.Sex + "',Age=" + data.Age + ",Prof='" + data.Prof + "',Sal=" + data.Sal + ",Comm=" + data.Comm + ",Dept='" + data.Dept + "' where Tno='" + data.Tno + "'";

            return(dataAccess.ExecuteSQL(sql));
        }
Beispiel #5
0
        //插入教师记录
        public static bool insertTeacherInfo(Teacher.TeacherInfoData data)
        {
            string sql = "insert into Teacher(Tno,Tname,Sex,Age,Prof,Sal,Comm,Dept) values('" + data.Tno + "','" + data.Tname + "','" + data.Sex + "'," + data.Age + ",'" + data.Prof + "'," + data.Sal + "," + data.Comm + ",'" + data.Dept + "')";

            return(dataAccess.ExecuteSQL(sql));
        }
Beispiel #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            int index = this.dataGridView1.CurrentRow.Index;

            if (index < 0)
            {
                MessageBox.Show("请选择要删除的记录!", "提示");
                return;
            }
            else
            {
                if (MessageBox.Show("确定要删除吗?", "删除后无法撤回", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    string tno = ds.Tables[0].Rows[index]["教师号"].ToString();
                    try
                    {
                        if (Teacher.TeacherInfoOperation.deleteTeacherInfo(tno))
                        {
                            MessageBox.Show("删除成功!", "提示");
                            //binddatagrid
                            string Tno   = textBox1.Text.Trim();
                            string Tname = textBox2.Text;
                            string Sex   = textBox3.Text;
                            string Age   = textBox4.Text;
                            string Prof  = textBox5.Text;
                            string Sal   = textBox6.Text;
                            string Dept  = textBox7.Text;

                            Teacher.TeacherInfoData data = new Teacher.TeacherInfoData();


                            data.Tno   = Tno;
                            data.Tname = Tname;
                            data.Sex   = Sex;
                            data.Age   = Age;
                            data.Prof  = Prof;
                            data.Sal   = Sal;
                            data.Dept  = Dept;

                            try
                            {
                                ds = Teacher.TeacherInfoOperation.getTeacherInfo(data);
                                this.dataGridView1.DataSource = ds.Tables[0];
                            }
                            catch (Exception ex)
                            {
                                ex.ToString();
                            }
                        }
                        else
                        {
                            MessageBox.Show("删除失败", "错误");
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                        MessageBox.Show("删除失败", "错误");
                    }
                }
            }
        }
Beispiel #7
0
 private void Teacher_overview_Load(object sender, EventArgs e)
 {
     Teacher.TeacherInfoData data = new Teacher.TeacherInfoData();
     ds = Teacher.TeacherInfoOperation.getTeacherInfo(data);
     this.dataGridView1.DataSource = ds.Tables[0];
 }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            string Tno   = textBox1.Text.Trim();
            string Tname = textBox2.Text;
            string Sex   = comboBox3.Text;
            string Age   = textBox4.Text;
            string Prof  = comboBox5.Text;
            string Sal   = textBox6.Text;
            string Comm  = textBox7.Text;
            string Dept  = comboBox8.Text;

            if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "")
            {
                MessageBox.Show("请输入完整信息!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBox1.Text.Trim() == null || textBox2.Text.Trim() == null || comboBox3.Text.Trim() == null || textBox4.Text.Trim() == null || comboBox5.Text.Trim() == null)
            {
                MessageBox.Show("请输入完整信息!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Teacher.TeacherInfoData data = new Teacher.TeacherInfoData();

            data.Tno   = Tno;
            data.Tname = Tname;
            data.Sex   = Sex;
            data.Age   = Age;
            data.Prof  = Prof;
            data.Sal   = Sal;
            data.Comm  = Comm;
            data.Dept  = Dept;

            try
            {
                if (FLAG == "")
                {
                    if (Teacher.TeacherInfoOperation.insertTeacherInfo(data))
                    {
                        MessageBox.Show("添加成功", "提示");
                        this.textBox1.Text  = "";
                        this.textBox2.Text  = "";
                        this.comboBox3.Text = "";
                        this.textBox4.Text  = "";
                        this.comboBox5.Text = "";
                        this.textBox6.Text  = "";
                        this.textBox7.Text  = "";
                        this.comboBox8.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("添加失败", "提示");
                    }
                }
                else
                {
                    if (Teacher.TeacherInfoOperation.updateTeacherInfo(data))
                    {
                        MessageBox.Show("修改成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show("修改失败", "提示");
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                MessageBox.Show("保存失败", "错误");
            }
        }