📄 frmupdatecourse.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Student
{
using Aptech.Student.DataAccess;
using Aptech.Student.Business;
/// <summary>
/// frmUpdateCourse 的摘要说明。
/// </summary>
public class frmUpdateCourse : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.DateTimePicker txtFinishDate;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtClassName;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txtRemark;
private System.Windows.Forms.TextBox txtSubjectName;
private System.Windows.Forms.Label lblStudentNo;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.DateTimePicker txtBeginDate;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSubmit;
private int m_iCourseId;
public frmUpdateCourse(int iCourseId)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
m_iCourseId = iCourseId;
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void GetCourseInfo()
{
Courses courses = new Courses();
DataSet dataSet = new DataSet();
try
{
dataSet = courses.SelectCourse(
m_iCourseId,
-1,
-1);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
DataRow row = dataSet.Tables[0].Rows[0];
this.txtBeginDate.Value = Convert.ToDateTime(row["BeginDate"]);
this.txtFinishDate.Value = Convert.ToDateTime(row["FinishDate"]);
this.txtClassName.Text = row["ClassName"].ToString();
this.txtRemark.Text = row["Remark"].ToString();
this.txtSubjectName.Text = row["SubjectName"].ToString();
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtFinishDate = new System.Windows.Forms.DateTimePicker();
this.label3 = new System.Windows.Forms.Label();
this.txtClassName = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.txtRemark = new System.Windows.Forms.TextBox();
this.txtSubjectName = new System.Windows.Forms.TextBox();
this.lblStudentNo = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtBeginDate = new System.Windows.Forms.DateTimePicker();
this.btnDelete = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.btnSubmit = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtBeginDate);
this.groupBox1.Controls.Add(this.txtFinishDate);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.txtClassName);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.txtRemark);
this.groupBox1.Controls.Add(this.txtSubjectName);
this.groupBox1.Controls.Add(this.lblStudentNo);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Location = new System.Drawing.Point(-8, -8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(500, 296);
this.groupBox1.TabIndex = 16;
this.groupBox1.TabStop = false;
//
// txtFinishDate
//
this.txtFinishDate.CustomFormat = "yyyy-MM-dd HH:mm:ss";
this.txtFinishDate.Location = new System.Drawing.Point(120, 112);
this.txtFinishDate.Name = "txtFinishDate";
this.txtFinishDate.Size = new System.Drawing.Size(160, 21);
this.txtFinishDate.TabIndex = 10;
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(70, 23);
this.label3.TabIndex = 3;
this.label3.Text = "开课日期:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtClassName
//
this.txtClassName.Location = new System.Drawing.Point(120, 16);
this.txtClassName.Name = "txtClassName";
this.txtClassName.ReadOnly = true;
this.txtClassName.Size = new System.Drawing.Size(160, 21);
this.txtClassName.TabIndex = 0;
this.txtClassName.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(40, 112);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(70, 23);
this.label4.TabIndex = 4;
this.label4.Text = "结课日期:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtRemark
//
this.txtRemark.Location = new System.Drawing.Point(120, 144);
this.txtRemark.Multiline = true;
this.txtRemark.Name = "txtRemark";
this.txtRemark.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal;
this.txtRemark.Size = new System.Drawing.Size(320, 104);
this.txtRemark.TabIndex = 6;
this.txtRemark.Text = "";
//
// txtSubjectName
//
this.txtSubjectName.Location = new System.Drawing.Point(120, 48);
this.txtSubjectName.Name = "txtSubjectName";
this.txtSubjectName.ReadOnly = true;
this.txtSubjectName.Size = new System.Drawing.Size(160, 21);
this.txtSubjectName.TabIndex = 8;
this.txtSubjectName.Text = "";
//
// lblStudentNo
//
this.lblStudentNo.Location = new System.Drawing.Point(40, 16);
this.lblStudentNo.Name = "lblStudentNo";
this.lblStudentNo.Size = new System.Drawing.Size(70, 23);
this.lblStudentNo.TabIndex = 1;
this.lblStudentNo.Text = "班:";
this.lblStudentNo.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 144);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(70, 23);
this.label1.TabIndex = 7;
this.label1.Text = "备注:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.Location = new System.Drawing.Point(40, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(70, 23);
this.label2.TabIndex = 2;
this.label2.Text = "科目:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtBeginDate
//
this.txtBeginDate.CustomFormat = "yyyy-MM-dd HH:mm:ss";
this.txtBeginDate.Location = new System.Drawing.Point(120, 80);
this.txtBeginDate.Name = "txtBeginDate";
this.txtBeginDate.Size = new System.Drawing.Size(160, 21);
this.txtBeginDate.TabIndex = 12;
//
// btnDelete
//
this.btnDelete.Location = new System.Drawing.Point(208, 296);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(75, 22);
this.btnDelete.TabIndex = 19;
this.btnDelete.Text = "删除";
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnClose
//
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(296, 296);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 22);
this.btnClose.TabIndex = 18;
this.btnClose.Text = "关闭";
//
// btnSubmit
//
this.btnSubmit.Location = new System.Drawing.Point(128, 296);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(75, 22);
this.btnSubmit.TabIndex = 17;
this.btnSubmit.Text = "更改";
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
//
// frmUpdateCourse
//
this.AcceptButton = this.btnSubmit;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnClose;
this.ClientSize = new System.Drawing.Size(472, 326);
this.Controls.Add(this.btnDelete);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnSubmit);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmUpdateCourse";
this.Text = "frmUpdateCourse";
this.Load += new System.EventHandler(this.frmUpdateCourse_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void frmUpdateCourse_Load(object sender, System.EventArgs e)
{
GetCourseInfo();
}
private void btnDelete_Click(object sender, System.EventArgs e)
{
Courses courses = new Courses();
courses.DeleteCourse(
m_iCourseId,
-1,
-1);
MessageBox.Show("删除成功。");
this.Close();
}
private void btnSubmit_Click(object sender, System.EventArgs e)
{
Courses courses = new Courses();
courses.UpdateCourse(
m_iCourseId,
txtBeginDate.Value,
txtFinishDate.Value,
txtRemark.Text);
MessageBox.Show("操作完成。");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -