コード例 #1
0
        private void AddCourse()
        {
            int result = MysqlUtil.DoInsert("t_course",
                                            new string[] { "cid", "cname", "remake" },
                                            new object[] { c_id.Text.Trim(), c_name.Text.Trim(), c_marke.Text.Trim() }
                                            );

            if (result == 1)
            {
                MessageBox.Show("添加成功", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                //添加成功后置空表单
                this.setNull();
                this.Close();
            }
            else
            {
                MessageBox.Show("添加失败", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        private void AddStudent()
        {
            string sex    = radio_boy.Checked ? "男" : "女";
            int    result = MysqlUtil.DoInsert("t_students",
                                               new string[] { "sid", "sname", "sex", "age", "major", "cid", "class_id" },
                                               new object[] { stu_id.Text.Trim(), stu_name.Text.Trim(), sex, Convert.ToInt32(stu_age.Text.Trim()), stu_major.Text.Trim(), stu_course.SelectedValue, Convert.ToInt32(stu_class.Text.Trim()) }
                                               );

            if (result == 1)
            {
                MessageBox.Show("添加成功", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                //添加成功后置空表单
                this.SetNull();
                this.Close();
            }
            else
            {
                MessageBox.Show("添加失败", "系统提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }