📄 frmstudentafdinfo.cs
字号:
using System;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using BusinessRule;
using DataAccess;
namespace Forms
{
/// <summary>
/// frmStudentAFDInfo 的摘要说明。
/// </summary>
public class frmStudentAFDInfo : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtRemark;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.TextBox txtHours;
private DataTable myDt ;
private Teacher teacher;
private AdminTeacher Ateacher = null;
private PrelectTeacher Pteacher = null;
private MasterTeacher Mteacher = null;
private System.Windows.Forms.GroupBox grpStudent;
private System.Windows.Forms.ComboBox cboClaID;
private System.Windows.Forms.Label lblClaID;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cboStuName;
private System.Windows.Forms.ComboBox cboType;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmStudentAFDInfo()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
Post.EventSendLoginedID += new DataAccess.Post.SendMsgDelegate(Post_EventSendStudentAFDInfo);
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.grpStudent = new System.Windows.Forms.GroupBox();
this.cboStuName = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.cboClaID = new System.Windows.Forms.ComboBox();
this.lblClaID = new System.Windows.Forms.Label();
this.btnExit = new System.Windows.Forms.Button();
this.txtHours = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.label4 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txtRemark = new System.Windows.Forms.TextBox();
this.btnAdd = new System.Windows.Forms.Button();
this.cboType = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.grpStudent.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.cboType);
this.groupBox1.Controls.Add(this.grpStudent);
this.groupBox1.Controls.Add(this.btnExit);
this.groupBox1.Controls.Add(this.txtHours);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.dateTimePicker1);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.txtRemark);
this.groupBox1.Controls.Add(this.btnAdd);
this.groupBox1.Location = new System.Drawing.Point(8, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(520, 216);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
//
// grpStudent
//
this.grpStudent.Controls.Add(this.cboStuName);
this.grpStudent.Controls.Add(this.label1);
this.grpStudent.Controls.Add(this.cboClaID);
this.grpStudent.Controls.Add(this.lblClaID);
this.grpStudent.Location = new System.Drawing.Point(24, 17);
this.grpStudent.Name = "grpStudent";
this.grpStudent.Size = new System.Drawing.Size(208, 111);
this.grpStudent.TabIndex = 16;
this.grpStudent.TabStop = false;
this.grpStudent.Text = "学员选择";
//
// cboStuName
//
this.cboStuName.ItemHeight = 12;
this.cboStuName.Location = new System.Drawing.Point(72, 64);
this.cboStuName.Name = "cboStuName";
this.cboStuName.Size = new System.Drawing.Size(121, 20);
this.cboStuName.TabIndex = 15;
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 23);
this.label1.TabIndex = 14;
this.label1.Text = "学员:";
//
// cboClaID
//
this.cboClaID.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboClaID.ItemHeight = 12;
this.cboClaID.Location = new System.Drawing.Point(72, 25);
this.cboClaID.Name = "cboClaID";
this.cboClaID.Size = new System.Drawing.Size(121, 20);
this.cboClaID.TabIndex = 13;
this.cboClaID.SelectedIndexChanged += new System.EventHandler(this.cboClaID_SelectedIndexChanged);
//
// lblClaID
//
this.lblClaID.Location = new System.Drawing.Point(16, 25);
this.lblClaID.Name = "lblClaID";
this.lblClaID.Size = new System.Drawing.Size(44, 23);
this.lblClaID.TabIndex = 12;
this.lblClaID.Text = "班级:";
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(384, 176);
this.btnExit.Name = "btnExit";
this.btnExit.TabIndex = 15;
this.btnExit.Text = "退出(&E)";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// txtHours
//
this.txtHours.Location = new System.Drawing.Point(344, 104);
this.txtHours.Name = "txtHours";
this.txtHours.Size = new System.Drawing.Size(128, 21);
this.txtHours.TabIndex = 14;
this.txtHours.Text = "";
//
// label6
//
this.label6.Location = new System.Drawing.Point(256, 104);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 23);
this.label6.TabIndex = 13;
this.label6.Text = "缺勤课时";
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(344, 40);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(128, 21);
this.dateTimePicker1.TabIndex = 12;
this.dateTimePicker1.Value = new System.DateTime(2006, 10, 23, 16, 40, 57, 656);
//
// label4
//
this.label4.Location = new System.Drawing.Point(256, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 23);
this.label4.TabIndex = 3;
this.label4.Text = "缺勤类型; ";
//
// label2
//
this.label2.Location = new System.Drawing.Point(256, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 1;
this.label2.Text = "缺勤日期:";
//
// label5
//
this.label5.Location = new System.Drawing.Point(24, 144);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 23);
this.label5.TabIndex = 4;
this.label5.Text = "备注:";
//
// txtRemark
//
this.txtRemark.Location = new System.Drawing.Point(112, 136);
this.txtRemark.Multiline = true;
this.txtRemark.Name = "txtRemark";
this.txtRemark.Size = new System.Drawing.Size(352, 32);
this.txtRemark.TabIndex = 10;
this.txtRemark.Text = "";
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(288, 176);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(80, 24);
this.btnAdd.TabIndex = 6;
this.btnAdd.Text = "添加(&A)";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// cboType
//
this.cboType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboType.ItemHeight = 12;
this.cboType.Items.AddRange(new object[] {
"迟到",
"早退",
"旷课",
"请假"});
this.cboType.Location = new System.Drawing.Point(344, 72);
this.cboType.Name = "cboType";
this.cboType.Size = new System.Drawing.Size(128, 20);
this.cboType.TabIndex = 17;
//
// frmStudentAFDInfo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(536, 229);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "frmStudentAFDInfo";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "添加学员缺勤信息";
this.Load += new System.EventHandler(this.frmStudentAFDInfo_Load);
this.groupBox1.ResumeLayout(false);
this.grpStudent.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
//获得实例化好的用户实例
public Teacher User
{
get
{
if(Ateacher != null)
{
return Ateacher;
}
else if(Mteacher != null)
{
return Mteacher;
}
else
{
return Pteacher;
}
}
}
//订阅“邮递员”
private void Post_EventSendStudentAFDInfo(object obj,object teacher,string formName)
{
if(teacher.GetType().ToString().Equals("BusinessRule.AdminTeacher"))
{
this.Ateacher = (AdminTeacher)teacher;
}
else if(teacher.GetType().ToString().Equals("BusinessRule.MasterTeacher"))
{
this.Mteacher = (MasterTeacher)teacher;
}
else
{
this.Pteacher = (PrelectTeacher)teacher;
}
Post.EventSendLoginedID -= new DataAccess.Post.SendMsgDelegate(Post_EventSendStudentAFDInfo);
}
//窗体加载事件
private void frmStudentAFDInfo_Load(object sender, System.EventArgs e)
{
foreach(string claID in this.User.TeaClasses)
{
if(User.CheckClassIsOn(claID))
{
cboClaID.Items.Add(claID);
}
}
if(cboClaID.Items.Count != 0 )
{
cboClaID.SelectedIndex = 0;
}
cboType.SelectedIndex = 0;
}
//选择班级
private void cboClaID_SelectedIndexChanged(object sender, System.EventArgs e)
{
myDt = this.User.GetStuIDStuNameByClaID(cboClaID.Text);
for(int i = 0;i < myDt.Rows.Count;i++)
{
cboStuName.Items.Add(myDt.Rows[i]["stuName"].ToString());
}
cboStuName.SelectedIndex = 0;
}
private void btnAdd_Click(object sender, System.EventArgs e)
{
StudentDuty studentDuty = new StudentDuty();
studentDuty.ClaID = this.cboClaID.SelectedText.ToString();
// studentDuty.Hours = int.Parse(this.txtHours.Text.Trim());
studentDuty.Remark = this.txtRemark.Text.Trim();
foreach(DataRow dr in myDt.Rows)
{
if(dr["stuName"].Equals(cboStuName.Text))
{
studentDuty.StuID = int.Parse(dr["stuID"].ToString());
}
}
// studentDuty.Type =int.Parse(cboType.Text);
studentDuty.AfdDate = this.dateTimePicker1.Text.ToString();
MessageBox.Show("添加成功\n数据已保存","成功", MessageBoxButtons.OK,MessageBoxIcon.Information);
this.Close();
// Teacher teacher = this.User;
// if(teacher.GetType().ToString().Equals("BusinessRule.AdminTeacher"))
// {
// this.Ateacher = (AdminTeacher)teacher;
// }
// else if(teacher.GetType().ToString().Equals("BusinessRule.MasterTeacher"))
// {
// this.Mteacher = (MasterTeacher)teacher;
// }
// else
// {
// this.Pteacher = (PrelectTeacher)teacher;
// }
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -