📄 editinformation.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace WindowsApplication3
{
/// <summary>
/// EditInformation 的摘要说明。
/// </summary>
public class EditInformation : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.RadioButton rb1;
private System.Windows.Forms.RadioButton rb2;
private System.Windows.Forms.TextBox txtPosition;
private System.Windows.Forms.TextBox txtPassword;
private Admin ain;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.DateTimePicker dtCsrq;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public EditInformation()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(EditInformation));
this.txtPosition = new System.Windows.Forms.TextBox();
this.txtPassword = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.lblName = new System.Windows.Forms.Label();
this.rb1 = new System.Windows.Forms.RadioButton();
this.rb2 = new System.Windows.Forms.RadioButton();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.dtCsrq = new System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// txtPosition
//
this.txtPosition.Location = new System.Drawing.Point(408, 152);
this.txtPosition.Name = "txtPosition";
this.txtPosition.Size = new System.Drawing.Size(128, 21);
this.txtPosition.TabIndex = 3;
this.txtPosition.Text = "";
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(152, 192);
this.txtPassword.Name = "txtPassword";
this.txtPassword.Size = new System.Drawing.Size(112, 21);
this.txtPassword.TabIndex = 4;
this.txtPassword.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(80, 112);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 23);
this.label1.TabIndex = 4;
this.label1.Text = "姓 名:";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(336, 112);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 23);
this.label2.TabIndex = 5;
this.label2.Text = "生 日:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(80, 152);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 23);
this.label3.TabIndex = 6;
this.label3.Text = "性 别:";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// label4
//
this.label4.Location = new System.Drawing.Point(336, 152);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 23);
this.label4.TabIndex = 7;
this.label4.Text = "职 位:";
//
// label5
//
this.label5.Location = new System.Drawing.Point(80, 192);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 23);
this.label5.TabIndex = 8;
this.label5.Text = "密 码:";
//
// lblName
//
this.lblName.Location = new System.Drawing.Point(160, 112);
this.lblName.Name = "lblName";
this.lblName.TabIndex = 9;
//
// rb1
//
this.rb1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.rb1.Location = new System.Drawing.Point(152, 152);
this.rb1.Name = "rb1";
this.rb1.Size = new System.Drawing.Size(32, 24);
this.rb1.TabIndex = 2;
this.rb1.TabStop = true;
this.rb1.Text = "男";
//
// rb2
//
this.rb2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.rb2.Location = new System.Drawing.Point(208, 152);
this.rb2.Name = "rb2";
this.rb2.Size = new System.Drawing.Size(32, 24);
this.rb2.TabIndex = 11;
this.rb2.Text = "女";
//
// pictureBox1
//
this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(472, 248);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(56, 26);
this.pictureBox1.TabIndex = 13;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
this.pictureBox1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter);
this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
//
// dtCsrq
//
this.dtCsrq.Location = new System.Drawing.Point(408, 112);
this.dtCsrq.Name = "dtCsrq";
this.dtCsrq.Size = new System.Drawing.Size(128, 21);
this.dtCsrq.TabIndex = 1;
//
// EditInformation
//
this.Controls.Add(this.dtCsrq);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.label5);
this.Controls.Add(this.lblName);
this.Controls.Add(this.rb1);
this.Controls.Add(this.rb2);
this.Controls.Add(this.txtPosition);
this.Controls.Add(this.txtPassword);
this.Name = "EditInformation";
this.Size = new System.Drawing.Size(600, 450);
this.Load += new System.EventHandler(this.EditInformation_Load);
this.ResumeLayout(false);
}
#endregion
private void EditInformation_Load(object sender, System.EventArgs e)
{
this.dtCsrq.Focus( );
lblName.Text = Form2.adm.Name;
ain = new Admin( Form2.adm.Name );
ain.GetObject( );
if( ain.Sex.Trim( ) == "男" )
{
rb1.Checked = true;
}
else
{
rb2.Checked = true;
}
txtPosition.Text = ain.Position.Trim( );
txtPassword.Text = ain.Password.Trim( );
dtCsrq.Value = DateTime.Parse( ain.Birthday.Trim( )) ;
}
// private void button1_Click(object sender, System.EventArgs e)
// {
// if(ain.Update( rb1.Checked ? "男" : "女",txtPosition.Text.Trim( ) ,txtPassword.Text.Trim( ) ,dtCsrq.Value.ToLongDateString( ) ))
// {
// MessageBox.Show("修改成功!","修改信息窗口",MessageBoxButtons.OK ,MessageBoxIcon.Information );
// }
// else
// {
// MessageBox.Show("失败!","修改信息窗口",MessageBoxButtons.OK ,MessageBoxIcon.Information );
// }
// }
private void pictureBox1_MouseEnter(object sender, System.EventArgs e)
{
pictureBox1.Image = Image.FromFile( "img\\button-修改02.GIF" );
}
private void pictureBox1_MouseLeave(object sender, System.EventArgs e)
{
pictureBox1.Image = Image.FromFile( "img\\button-修改01.GIF" );
}
private void pictureBox1_Click(object sender, System.EventArgs e)
{
if(ain.Update( rb1.Checked ? "男" : "女",txtPosition.Text.Trim( ) ,txtPassword.Text.Trim( ) ,dtCsrq.Value.ToLongDateString( ) ))
{
MessageBox.Show("修改成功!","修改信息窗口",MessageBoxButtons.OK ,MessageBoxIcon.Information );
}
else
{
MessageBox.Show("失败!","修改信息窗口",MessageBoxButtons.OK ,MessageBoxIcon.Information );
}
}
private void label1_Click(object sender, System.EventArgs e)
{
}
private void label3_Click(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -