📄 formedit.cs
字号:
this.dataGridTextBoxColumn9.Format = "";
this.dataGridTextBoxColumn9.FormatInfo = null;
this.dataGridTextBoxColumn9.HeaderText = "处分日期";
this.dataGridTextBoxColumn9.MappingName = "punishment_date";
this.dataGridTextBoxColumn9.Width = 75;
//
// panel7
//
this.panel7.BackColor = System.Drawing.SystemColors.GrayText;
this.panel7.Location = new System.Drawing.Point(10, 50);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(436, 1);
this.panel7.TabIndex = 10;
//
// label22
//
this.label22.Location = new System.Drawing.Point(80, 22);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(168, 16);
this.label22.TabIndex = 9;
this.label22.Text = "学生的处分纪录";
//
// pictureBox6
//
this.pictureBox6.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox6.Image")));
this.pictureBox6.Location = new System.Drawing.Point(18, 4);
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.Size = new System.Drawing.Size(48, 40);
this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox6.TabIndex = 8;
this.pictureBox6.TabStop = false;
//
// txtAwardContent
//
this.txtAwardContent.Location = new System.Drawing.Point(48, 184);
this.txtAwardContent.MaxLength = 50;
this.txtAwardContent.Name = "txtAwardContent";
this.txtAwardContent.Size = new System.Drawing.Size(136, 21);
this.txtAwardContent.TabIndex = 25;
this.txtAwardContent.Text = "";
//
// label26
//
this.label26.BackColor = System.Drawing.Color.Transparent;
this.label26.Location = new System.Drawing.Point(0, 184);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(48, 23);
this.label26.TabIndex = 25;
this.label26.Text = "类型:";
this.label26.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label27
//
this.label27.BackColor = System.Drawing.Color.Transparent;
this.label27.Location = new System.Drawing.Point(0, 184);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(48, 23);
this.label27.TabIndex = 32;
this.label27.Text = "类型:";
this.label27.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnDeletePunishment
//
this.btnDeletePunishment.BackColor = System.Drawing.SystemColors.Control;
this.btnDeletePunishment.Location = new System.Drawing.Point(371, 183);
this.btnDeletePunishment.Name = "btnDeletePunishment";
this.btnDeletePunishment.TabIndex = 31;
this.btnDeletePunishment.Text = "删除";
this.btnDeletePunishment.Click += new System.EventHandler(this.btnDeletePunishment_Click);
//
// btnAddPunishment
//
this.btnAddPunishment.BackColor = System.Drawing.SystemColors.Control;
this.btnAddPunishment.Location = new System.Drawing.Point(291, 183);
this.btnAddPunishment.Name = "btnAddPunishment";
this.btnAddPunishment.TabIndex = 30;
this.btnAddPunishment.Text = "添加";
this.btnAddPunishment.Click += new System.EventHandler(this.btnAddPunishment_Click);
//
// txtPunishmentReason
//
this.txtPunishmentReason.Location = new System.Drawing.Point(48, 216);
this.txtPunishmentReason.Name = "txtPunishmentReason";
this.txtPunishmentReason.Size = new System.Drawing.Size(400, 21);
this.txtPunishmentReason.TabIndex = 27;
this.txtPunishmentReason.Text = "";
//
// label28
//
this.label28.BackColor = System.Drawing.Color.Transparent;
this.label28.Location = new System.Drawing.Point(0, 219);
this.label28.Name = "label28";
this.label28.Size = new System.Drawing.Size(48, 16);
this.label28.TabIndex = 29;
this.label28.Text = "原因:";
this.label28.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// dateTimePunishment
//
this.dateTimePunishment.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dateTimePunishment.Location = new System.Drawing.Point(180, 184);
this.dateTimePunishment.Name = "dateTimePunishment";
this.dateTimePunishment.Size = new System.Drawing.Size(104, 21);
this.dateTimePunishment.TabIndex = 28;
//
// cmbPunishmentType
//
this.cmbPunishmentType.DataSource = this.dsStuAddedInfo.punishmentTypes;
this.cmbPunishmentType.DisplayMember = "punishmentType_name";
this.cmbPunishmentType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbPunishmentType.Location = new System.Drawing.Point(48, 184);
this.cmbPunishmentType.Name = "cmbPunishmentType";
this.cmbPunishmentType.Size = new System.Drawing.Size(120, 20);
this.cmbPunishmentType.TabIndex = 26;
this.cmbPunishmentType.ValueMember = "punishmentType_ID";
//
// FormEdit
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 326);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.HelpButton = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormEdit";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "编辑";
this.Closed += new System.EventHandler(this.FormEdit_Closed);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dsStuAddedInfo)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridChanges)).EndInit();
this.tabPage5.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.gridAwards)).EndInit();
this.tabPage6.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.gridPunishments)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void Bind_dsPunishmentTypes()
{
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Select * From punishmentTypes");
OleDbDataAdapter objAdapter = new OleDbDataAdapter(objCommand);
objAdapter.Fill(dsStuAddedInfo.punishmentTypes);
CommandCloser.CloseOleDbCommand(objCommand);
}
private void Bind_dsChangeTypes()
{
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Select * From changeTypes");
OleDbDataAdapter objAdapter = new OleDbDataAdapter(objCommand);
objAdapter.Fill(dsStuAddedInfo.changeTypes);
CommandCloser.CloseOleDbCommand(objCommand);
}
private void Bind_gridChanges()
{
dsStuAddedInfo.changes.Rows.Clear();
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("SELECT changes.change_ID,changes.change_reason,changes.change_date, changeTypes.changeType_name FROM changeTypes INNER JOIN changes ON changeTypes.changeType_ID = changes.change_changeType Where change_studentID=@StudentID");
objCommand.Parameters.Add("@StudentID",studentID);
OleDbDataAdapter objAdapter = new OleDbDataAdapter(objCommand);
objAdapter.Fill(dsStuAddedInfo.changes);
CommandCloser.CloseOleDbCommand(objCommand);
}
private void Bind_gridAwards()
{
dsStuAddedInfo.awards.Rows.Clear();
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Select * From awards Where award_studentID=@StudentID");
objCommand.Parameters.Add("@StudentID",studentID);
OleDbDataAdapter objAdapter = new OleDbDataAdapter(objCommand);
objAdapter.Fill(dsStuAddedInfo.awards);
CommandCloser.CloseOleDbCommand(objCommand);
}
private void Bind_gridPunishments()
{
dsStuAddedInfo.punishments.Rows.Clear();
OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("SELECT punishments.*, punishmentTypes.* FROM punishmentTypes INNER JOIN punishments ON punishmentTypes.punishmentType_ID = punishments.punishment_typeID Where punishment_studentID=@StudentID");
objCommand.Parameters.Add("@StudentID",studentID);
OleDbDataAdapter objAdapter = new OleDbDataAdapter(objCommand);
objAdapter.Fill(dsStuAddedInfo.punishments);
CommandCloser.CloseOleDbCommand(objCommand);
}
private void btnOK_Click(object sender, System.EventArgs e)
{
if(txtBoxName.Text.Trim()!="")
{
entity.StudentName = txtBoxName.Text.Trim();
}
else
{
MessageBox.Show("请输入学生姓名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
entity.StudentSex = rdoBtnMale.Checked ? "男":"女";
if(StringValidation.isChinaIDCardNumString(txtBoxIDCardNum.Text.Trim()))
{
entity.StudentIDCardNum = txtBoxIDCardNum.Text.Trim();
}
else
{
MessageBox.Show("请输入18或15位数字的学生身份证号码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
entity.StudentBirthday = System.DateTime.Parse(dateTimePickerBirth.Text.Trim());
entity.StudentNative = txtBoxNative.Text.Trim();
entity.StudentClass = cmbBoxClass.Text.Substring(0,6);
entity.StudentID = txtBoxStuID.Text.Trim();
entity.StudentEnterYear = cmbBoxEnterYear.Text.Trim().Substring(0,4);
entity.StudentStuType = cmbBoxStuType.Text.Trim().Substring(0,1);
entity.StudentHomeTel = txtBoxHomeAdd.Text.Trim();
entity.StudentHomeTel = txtBoxHomeTel.Text.Trim();
entity.StudentFlatTel = txtBoxFlatTel.Text.Trim();
entity.StudentMobile = txtBoxMobile.Text.Trim();
if(txtBoxEmail.Text.Trim()=="" || StringValidation.isEmailString(txtBoxEmail.Text.Trim()))
{
entity.StudentEmail = txtBoxEmail.Text.Trim();
}
else
{
MessageBox.Show("您输入的电子邮件地址不是正确的格式,请重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
try
{
manager.Update(entity);
}
catch(Exception e1)
{
MessageBox.Show(e1.Message);
return;
}
this.DialogResult = DialogResult.OK;
this.Close();
this.Dispose();
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
this.Dispose();
}
private void FormEdit_Closed(object sender, System.EventArgs e)
{
System.GC.Collect();
}
private void btnDeleteChange_Click(object sender, System.EventArgs e)
{
DialogResult result = MessageBox.Show("确定要删除这条记录吗?","删除确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
if(result == DialogResult.OK)
{
try
{
changeManager.Delete(dsStuAddedInfo.changes.Rows[gridChanges.CurrentRowIndex]["change_ID"].ToString());
Bind_gridChanges();
}
catch(Exception e1)
{
MessageBox.Show(e1.Message);
}
}
}
private void btnAddChange_Click(object sender, System.EventArgs e)
{
changeEntity.ChangeStudentID = studentID;
changeEntity.ChangeChnageType = cmbChangeType.SelectedValue.ToString().Trim();
changeEntity.ChangeReason = txtChangeReason.Text.Trim();
changeEntity.Cha
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -