📄 societyinforecord.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace PM
{
/// <summary>
/// SocietyInfoRecord 的摘要说明。
/// </summary>
public class SocietyInfoRecord : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox No_cb;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox Name_txt;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox sName_txt;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox Location_cb;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox Unit_txt;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox Remarks_txt;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private DataTable dt = new DataTable();
private string ID = string.Empty;
public SocietyInfoRecord()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SocietyInfoRecord));
this.label1 = new System.Windows.Forms.Label();
this.No_cb = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.Name_txt = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.sName_txt = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.Location_cb = new System.Windows.Forms.ComboBox();
this.label5 = new System.Windows.Forms.Label();
this.Unit_txt = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.Remarks_txt = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 0;
this.label1.Text = "员工编号";
//
// No_cb
//
this.No_cb.Location = new System.Drawing.Point(80, 16);
this.No_cb.Name = "No_cb";
this.No_cb.Size = new System.Drawing.Size(100, 20);
this.No_cb.TabIndex = 1;
this.No_cb.SelectedIndexChanged += new System.EventHandler(this.No_cb_SelectedIndexChanged);
//
// label2
//
this.label2.Location = new System.Drawing.Point(208, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "员工姓名";
//
// Name_txt
//
this.Name_txt.Enabled = false;
this.Name_txt.Location = new System.Drawing.Point(272, 16);
this.Name_txt.Name = "Name_txt";
this.Name_txt.TabIndex = 3;
this.Name_txt.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(32, 72);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(32, 16);
this.label3.TabIndex = 4;
this.label3.Text = "姓名";
//
// sName_txt
//
this.sName_txt.Location = new System.Drawing.Point(80, 64);
this.sName_txt.Name = "sName_txt";
this.sName_txt.TabIndex = 5;
this.sName_txt.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(216, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 16);
this.label4.TabIndex = 6;
this.label4.Text = "关系";
//
// Location_cb
//
this.Location_cb.Items.AddRange(new object[] {
"父子",
"母子",
"叔父",
"叔侄",
"爷孙"});
this.Location_cb.Location = new System.Drawing.Point(272, 64);
this.Location_cb.Name = "Location_cb";
this.Location_cb.Size = new System.Drawing.Size(100, 20);
this.Location_cb.TabIndex = 7;
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 120);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 16);
this.label5.TabIndex = 8;
this.label5.Text = "单位与职务";
//
// Unit_txt
//
this.Unit_txt.Location = new System.Drawing.Point(88, 112);
this.Unit_txt.Name = "Unit_txt";
this.Unit_txt.Size = new System.Drawing.Size(288, 21);
this.Unit_txt.TabIndex = 9;
this.Unit_txt.Text = "";
//
// label6
//
this.label6.Location = new System.Drawing.Point(32, 160);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(32, 16);
this.label6.TabIndex = 10;
this.label6.Text = "备注";
//
// Remarks_txt
//
this.Remarks_txt.Location = new System.Drawing.Point(88, 152);
this.Remarks_txt.Multiline = true;
this.Remarks_txt.Name = "Remarks_txt";
this.Remarks_txt.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.Remarks_txt.Size = new System.Drawing.Size(288, 72);
this.Remarks_txt.TabIndex = 11;
this.Remarks_txt.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(88, 240);
this.button1.Name = "button1";
this.button1.TabIndex = 12;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(296, 240);
this.button2.Name = "button2";
this.button2.TabIndex = 12;
this.button2.Text = "取消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// SocietyInfoRecord
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(408, 277);
this.Controls.Add(this.button1);
this.Controls.Add(this.Remarks_txt);
this.Controls.Add(this.label6);
this.Controls.Add(this.Unit_txt);
this.Controls.Add(this.label5);
this.Controls.Add(this.Location_cb);
this.Controls.Add(this.label4);
this.Controls.Add(this.sName_txt);
this.Controls.Add(this.label3);
this.Controls.Add(this.Name_txt);
this.Controls.Add(this.label2);
this.Controls.Add(this.No_cb);
this.Controls.Add(this.label1);
this.Controls.Add(this.button2);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SocietyInfoRecord";
this.Text = "社会关系添加";
this.Closing += new System.ComponentModel.CancelEventHandler(this.SocietyInfoRecord_Closing);
this.Load += new System.EventHandler(this.SocietyInfoRecord_Load);
this.ResumeLayout(false);
}
#endregion
#region 窗体出现绑定有关数据
private void SocietyInfoRecord_Load(object sender, System.EventArgs e)
{
SocietyInfoForm.siff.Enabled = false;
if(SocietyInfoForm.sID == "insert")
{
DBNo_cb();
}
if(SocietyInfoForm.sID == "update")
{
string []ss = SocietyInfoForm.siff.sb.ToString().Split('#');
this.No_cb.DropDownStyle = ComboBoxStyle.Simple;
this.No_cb.Enabled = false;
this.ID = ss[0];
this.No_cb.Text = ss[1];
this.Name_txt.Text = ss[2];
this.sName_txt.Text = ss[3];
this.Location_cb.Text = ss[4];
this.Unit_txt.Text = ss[5];
this.Remarks_txt.Text = ss[6];
}
}
#endregion
#region 绑定员工编号数据
private void DBNo_cb()
{
string s = "select * from EmployInfo order by eId asc";
Base bb = new Base();
this.dt = bb.ExeSQLdt(s);
for(int i = 0 ; i < this.dt.Rows.Count ; i ++)
{
this.No_cb.Items.Add(this.dt.Rows[i]["eId"].ToString());
}
}
#endregion
#region 窗体关闭让SocietyInfoForm 变为活动的
private void SocietyInfoRecord_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
SocietyInfoForm.siff.Enabled = true;
}
#endregion
#region 员工编号 变化,员工姓名相映的变化
private void No_cb_SelectedIndexChanged(object sender, System.EventArgs e)
{
for(int i = 0 ; i < this.dt.Rows.Count ; i ++)
{
if(this.No_cb.Text == this.dt.Rows[i]["eId"].ToString())
{
this.Name_txt.Text = this.dt.Rows[i]["eName"].ToString();
break;
}
}
}
#endregion
#region 取消
private void button2_Click(object sender, System.EventArgs e)
{
SocietyInfoForm.siff.Enabled = true;
this.Close();
}
#endregion
#region 确定 (确定添加一条记录或修改一条记录)
private void button1_Click(object sender, System.EventArgs e)
{
if(SocietyInfoForm.sID == "insert")
{
string s = "insert into SocietyInfo (seId,sName,sLaction,sUinte,sRemarks) values (" + int.Parse(this.No_cb.Text.Trim()) + ",'" + this.sName_txt.Text + "','" + this.Location_cb.Text;
s += "','" + this.Unit_txt.Text + "','" + this.Remarks_txt.Text + "')";
Base b = new Base();
b.ExeSQL(s);
MessageBox.Show("修改成功!");
}
if(SocietyInfoForm.sID == "update")
{
string s = "update SocietyInfo set sName='" + this.sName_txt.Text + "',sLaction='" + this.Location_cb.Text + "',sUinte='";
s += this.Unit_txt.Text + "',sRemarks='" + this.Remarks_txt.Text + "' where sssId=" + int.Parse(this.ID.Trim());
Base bb =new Base();
bb.ExeSQL(s);
MessageBox.Show("修改成功!");
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -