Exemplo n.º 1
0
 //刷新教师列表
 private void button13_Click(object sender, EventArgs e)
 {
     TeacherBusiness teaBusiness = new TeacherBusiness();
     DataTable dt = teaBusiness.getAllTeacher();
     this.dataGridView2.AutoGenerateColumns = false;
     this.dataGridView2.DataSource = dt;
 }
Exemplo n.º 2
0
        //删除教师
        private void button11_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除吗?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {

                bool isDeleteOk = true;
                TeacherBusiness teaBusiness = new TeacherBusiness();
                DataGridViewSelectedRowCollection toBeDeletedRowsCollection = this.dataGridView2.SelectedRows;
                DataGridViewRow[] tobedeletedrows = new DataGridViewRow[toBeDeletedRowsCollection.Count];
                toBeDeletedRowsCollection.CopyTo(tobedeletedrows, 0);
                foreach (DataGridViewRow temp in tobedeletedrows)
                {
                    if (teaBusiness.deleteTeacher(int.Parse(temp.Cells["tid"].Value.ToString())) == 0)
                        isDeleteOk = false;
                }
                if (isDeleteOk)
                {
                    MessageBox.Show("删除成功!");
                }
                else
                {
                    MessageBox.Show("删除出现错误,请刷新列表后重试!");
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.tb_phone.Text != "" && this.tb_tname.Text != "" && (this.radioButton1.Checked || this.radioButton2.Checked))
            {
                tname = this.tb_tname.Text;
                phone = this.tb_phone.Text;
                if (this.radioButton1.Checked)
                    gender = 1;
                else
                    gender = 0;
                birthday = this.dateTimePicker1.Text;

                TeacherModel teacherModel = new TeacherModel(0, 0, tname, gender, birthday, phone);

                int tid = 0 ;
                TeacherBusiness teacherBusiness = new TeacherBusiness();
                tid = teacherBusiness.addteacher(teacherModel);
                if (tid != 0)
                {
                    MessageBox.Show("成功!");
                }
                else
                {
                    MessageBox.Show("失败,请重试!");
                }
                this.Dispose();
            }
            else
            {
                MessageBox.Show("请填写所有信息!");
            }
        }
Exemplo n.º 4
0
        //教师列表编辑后保存
        private void dataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            TeacherModel teaModelToBeUpdated = new TeacherModel();
            TeacherBusiness teaBusiness = new TeacherBusiness();

            teaModelToBeUpdated.Tid = int.Parse(this.dataGridView2.CurrentRow.Cells["tid"].Value.ToString());

            teaModelToBeUpdated.Tname = this.dataGridView2.CurrentRow.Cells["tname"].Value.ToString();
            teaModelToBeUpdated.Birthday = this.dataGridView2.CurrentRow.Cells["birthday"].Value.ToString();
            teaModelToBeUpdated.Gender = this.dataGridView2.CurrentRow.Cells["tgender"].Value.ToString()=="男"?1:0;
            teaModelToBeUpdated.Phone = this.dataGridView2.CurrentRow.Cells["phone"].Value.ToString();

            int result = teaBusiness.updateteacher(teaModelToBeUpdated);
            if (result != 0)
            {
                MessageBox.Show("更新成功");
            }
            else
            {
                MessageBox.Show("更新失败");
            }
        }
 //新增课程
 private void button2_Click(object sender, EventArgs e)
 {
     int tid = new TeacherBusiness().getTidByUid(this.userModel.Uid);
     FmAddCourse fmAddCourse = new FmAddCourse(tid);
     fmAddCourse.ShowDialog();
 }