frmupdateclass.cs

来自「大二做的课程设计。一个学生信息管理系统」· CS 代码 · 共 123 行

CS
123
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Students1
{
    using StudentLibrary.Business;
    public partial class frmUpdateClass : Form
    {
        private int iClassId;
        
        public frmUpdateClass()
        {
            InitializeComponent();
        }


        public frmUpdateClass(int iClassId)
        {
            this.iClassId = iClassId;
            InitializeComponent();
        }

        private void GetClassInfo()
        {
            Classs classs = new Classs();
            DataSet dataset = new DataSet();
            try
            {
                dataset = classs.SelectClass(iClassId, "");
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
                this.Close();
            }
            if (dataset.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("班级信息不存在!");
                this.Close();
            }
            DataRow row = dataset.Tables[0].Rows[0];
            this.txtClassName.Text = row["ClassName"].ToString();
            this.txtRemarkText.Text = row["Remark"].ToString();
            this.txtEntranceDate.Value = Convert.ToDateTime(row["EntranceDate"].ToString());

 
        }

        private void GetCourse()
        {
            Classs classs = new Classs();
            DataSet dataset = new DataSet();
            try
            {
                dataset = classs.SelectClassCourse(iClassId);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            for (int i = 0; i < dataset.Tables[0].Rows.Count; i++)
            {
                DataRow row = dataset.Tables[0].Rows[i];
                string[] sItems = new string[3];
                sItems[0] = row["SubjectName"].ToString();
                sItems[1] = row["SubjectId"].ToString();
                sItems[2] = row["CourseId"].ToString();

                ListViewItem item = new ListViewItem(sItems, 2);
                item.Checked = (row["CourseId"] != System.DBNull.Value);
                this.listView1.Items.Add(item);
 
            }
            classs.Dispose();
        }
        private void frmUpdateClass_Load(object sender, EventArgs e)
        {
            GetClassInfo();
            GetCourse();
        }

        
        //更改班级信息
        private void button1_Click(object sender, EventArgs e)
        {
            Classs classs = new Classs();
            classs.UpdateClass(iClassId, this.txtClassName.Text, this.txtEntranceDate.Value, this.txtRemarkText.Text);
            MessageBox.Show("更新成功!");
            this.Close();
        }
        //删除班级信息
        private void button2_Click(object sender, EventArgs e)
        {
            Classs classs = new Classs();
            try
            {
                classs.DeleteClass(iClassId);
            }
            catch(Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            MessageBox.Show("删除成功!");
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

      

       

       
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?