⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formcourseadd.cs

📁 学生管理系统Csharp2005 学生管理系统Csharp2005 学生管理系统Csharp2005
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

using StudentManager.DbLayer;

namespace StudentManager
{
    public partial class FormCourseAdd : Form
    {
        public FormCourseAdd()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 查询课程表“Course”中的数据,并绑定导DataGridView中
        /// </summary>
        void LoadData()
        {
            string sql = "select * from [Course]";
            Database db = new Database();
            DataTable dt = db.GetDataTable(sql);
            this.dataGridViewPreView.DataSource = dt;
        }

        /// <summary>
        /// “添加”按钮单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            string sql = "";
            sql += "insert into [Course] values(";
            sql += SqlStringConstructor.GetQuotedString(textBoxCNo.Text) + ",";
            sql += SqlStringConstructor.GetQuotedString(textBoxCName.Text) + ")";

            Database db = new Database();
            if (db.ExecuteSQL(sql) != -1)
                MessageBox.Show("添加成功!");
            else
                MessageBox.Show("添加失败,课程编号重复!");

            this.LoadData();
        }

        /// <summary>
        /// “重置”按钮单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonReset_Click(object sender, EventArgs e)
        {
            textBoxCNo.Text = "";
            textBoxCName.Text = "";
        }

        /// <summary>
        /// “关闭”按钮单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FormCourseAdd_Load(object sender, EventArgs e)
        {

        }
    }
}

⌨️ 快捷键说明

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