📄 departmentframe.cs
字号:
#region 命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
#endregion
namespace WindowsApplication
{
#region 职工结构
public struct Employee
{
// string Emp_id;//职工号
// string Emp_Name;//职工名称
// string KaHao_ID;//卡号
// string ChenShiName;//城市
}
#endregion
#region Main Class
public class DepartmentFrame : System.Windows.Forms.Form
{
#region DataBaseVariable Define
private DataTable dsTable=new DataTable();
#endregion
#region Variable Define
private CurrencyManager orders=null;
#endregion
#region Controls Collection
private System.Windows.Forms.ToolBar tool;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolBarButton tFirst;
private System.Windows.Forms.ToolBarButton tLast;
private System.Windows.Forms.ToolBarButton tNext;
private System.Windows.Forms.ToolBarButton tEnd;
private System.Windows.Forms.ToolBarButton tAdd;
private System.Windows.Forms.ToolBarButton tModify;
private System.Windows.Forms.ToolBarButton tDelete;
private System.Windows.Forms.ToolBarButton tSave;
private System.Windows.Forms.ToolBarButton tCancel;
private System.Windows.Forms.ToolBarButton tExit;
private System.Windows.Forms.ImageList image;
private System.Windows.Forms.DataGrid dataGrid;
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 label6;
private System.Windows.Forms.ComboBox empSexText;
private System.Windows.Forms.ComboBox emp_DepartNo;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter;
private System.Data.SqlClient.SqlConnection sqlConnection;
private WindowsApplication.empDataSet empDataSet;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.ComboBox empIDText;
private System.Windows.Forms.TextBox empTextID;
private System.Windows.Forms.TextBox empNameText;
private System.Windows.Forms.TextBox empAddress;
private System.ComponentModel.IContainer components;
#endregion
#region Structure Function
public DepartmentFrame()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DepartmentFrame));
this.tool = new System.Windows.Forms.ToolBar();
this.tFirst = new System.Windows.Forms.ToolBarButton();
this.tLast = new System.Windows.Forms.ToolBarButton();
this.tNext = new System.Windows.Forms.ToolBarButton();
this.tEnd = new System.Windows.Forms.ToolBarButton();
this.tAdd = new System.Windows.Forms.ToolBarButton();
this.tModify = new System.Windows.Forms.ToolBarButton();
this.tDelete = new System.Windows.Forms.ToolBarButton();
this.tSave = new System.Windows.Forms.ToolBarButton();
this.tCancel = new System.Windows.Forms.ToolBarButton();
this.tExit = new System.Windows.Forms.ToolBarButton();
this.image = new System.Windows.Forms.ImageList(this.components);
this.dataGrid = new System.Windows.Forms.DataGrid();
this.btnSearch = new System.Windows.Forms.Button();
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.empSexText = new System.Windows.Forms.ComboBox();
this.label5 = new System.Windows.Forms.Label();
this.emp_DepartNo = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.empDataSet = new WindowsApplication.empDataSet();
this.empIDText = new System.Windows.Forms.ComboBox();
this.empTextID = new System.Windows.Forms.TextBox();
this.empNameText = new System.Windows.Forms.TextBox();
this.empAddress = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.empDataSet)).BeginInit();
this.SuspendLayout();
//
// tool
//
this.tool.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this.tool.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.tFirst,
this.tLast,
this.tNext,
this.tEnd,
this.tAdd,
this.tModify,
this.tDelete,
this.tSave,
this.tCancel,
this.tExit});
this.tool.ButtonSize = new System.Drawing.Size(30, 40);
this.tool.Cursor = System.Windows.Forms.Cursors.Hand;
this.tool.DropDownArrows = true;
this.tool.ImageList = this.image;
this.tool.Location = new System.Drawing.Point(0, 0);
this.tool.Name = "tool";
this.tool.ShowToolTips = true;
this.tool.Size = new System.Drawing.Size(714, 41);
this.tool.TabIndex = 0;
this.tool.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tool_ButtonClick);
//
// tFirst
//
this.tFirst.ImageIndex = 0;
this.tFirst.Text = "首记录";
//
// tLast
//
this.tLast.ImageIndex = 1;
this.tLast.Text = "上一条记录";
//
// tNext
//
this.tNext.ImageIndex = 2;
this.tNext.Text = "下一条记录";
//
// tEnd
//
this.tEnd.ImageIndex = 3;
this.tEnd.Text = "尾记录";
//
// tAdd
//
this.tAdd.ImageIndex = 4;
this.tAdd.Text = "新增";
//
// tModify
//
this.tModify.ImageIndex = 5;
this.tModify.Text = "修改";
//
// tDelete
//
this.tDelete.ImageIndex = 6;
this.tDelete.Text = "删除";
//
// tSave
//
this.tSave.ImageIndex = 7;
this.tSave.Text = "保存";
//
// tCancel
//
this.tCancel.ImageIndex = 9;
this.tCancel.Text = "取消";
//
// tExit
//
this.tExit.ImageIndex = 8;
this.tExit.Text = "退出";
//
// image
//
this.image.ImageSize = new System.Drawing.Size(16, 16);
this.image.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("image.ImageStream")));
this.image.TransparentColor = System.Drawing.Color.Transparent;
//
// dataGrid
//
this.dataGrid.AlternatingBackColor = System.Drawing.Color.LightGoldenrodYellow;
this.dataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.dataGrid.BackColor = System.Drawing.Color.White;
this.dataGrid.BackgroundColor = System.Drawing.Color.LightGoldenrodYellow;
this.dataGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.dataGrid.CaptionBackColor = System.Drawing.Color.LightGoldenrodYellow;
this.dataGrid.CaptionFont = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold);
this.dataGrid.CaptionForeColor = System.Drawing.Color.DarkSlateBlue;
this.dataGrid.CaptionVisible = false;
this.dataGrid.DataMember = "";
this.dataGrid.FlatMode = true;
this.dataGrid.Font = new System.Drawing.Font("Tahoma", 8F);
this.dataGrid.ForeColor = System.Drawing.Color.DarkSlateBlue;
this.dataGrid.GridLineColor = System.Drawing.Color.Peru;
this.dataGrid.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
this.dataGrid.HeaderBackColor = System.Drawing.Color.Maroon;
this.dataGrid.HeaderFont = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold);
this.dataGrid.HeaderForeColor = System.Drawing.Color.LightGoldenrodYellow;
this.dataGrid.LinkColor = System.Drawing.Color.Maroon;
this.dataGrid.Location = new System.Drawing.Point(0, 96);
this.dataGrid.Name = "dataGrid";
this.dataGrid.ParentRowsBackColor = System.Drawing.Color.BurlyWood;
this.dataGrid.ParentRowsForeColor = System.Drawing.Color.DarkSlateBlue;
this.dataGrid.ReadOnly = true;
this.dataGrid.SelectionBackColor = System.Drawing.Color.DarkSlateBlue;
this.dataGrid.SelectionForeColor = System.Drawing.Color.GhostWhite;
this.dataGrid.Size = new System.Drawing.Size(720, 200);
this.dataGrid.TabIndex = 1;
//
// btnSearch
//
this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSearch.Location = new System.Drawing.Point(472, 64);
this.btnSearch.Name = "btnSearch";
this.btnSearch.TabIndex = 2;
this.btnSearch.Text = "查询(&S)";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(168, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 23);
this.label1.TabIndex = 6;
this.label1.Text = "职工号:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(-24, 312);
this.label2.Name = "label2";
this.label2.TabIndex = 9;
this.label2.Text = "职工号";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Location = new System.Drawing.Point(136, 312);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 23);
this.label3.TabIndex = 11;
this.label3.Text = "职工名称";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.Location = new System.Drawing.Point(280, 312);
this.label4.Name = "label4";
this.label4.TabIndex = 13;
this.label4.Text = "性别";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// empSexText
//
this.empSexText.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.empSexText.Cursor = System.Windows.Forms.Cursors.Hand;
this.empSexText.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
this.empSexText.Items.AddRange(new object[] {
"男",
"女"});
this.empSexText.Location = new System.Drawing.Point(296, 352);
this.empSexText.Name = "empSexText";
this.empSexText.Size = new System.Drawing.Size(112, 20);
this.empSexText.TabIndex = 14;
//
// label5
//
this.label5.Location = new System.Drawing.Point(400, 312);
this.label5.Name = "label5";
this.label5.TabIndex = 16;
this.label5.Text = "住址";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// emp_DepartNo
//
this.emp_DepartNo.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.emp_DepartNo.Cursor = System.Windows.Forms.Cursors.Hand;
this.emp_DepartNo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
this.emp_DepartNo.Items.AddRange(new object[] {
""});
this.emp_DepartNo.Location = new System.Drawing.Point(568, 352);
this.emp_DepartNo.Name = "emp_DepartNo";
this.emp_DepartNo.Size = new System.Drawing.Size(112, 20);
this.emp_DepartNo.TabIndex = 18;
//
// label6
//
this.label6.Location = new System.Drawing.Point(544, 312);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(88, 23);
this.label6.TabIndex = 17;
this.label6.Text = "部门号码";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// sqlDataAdapter
//
this.sqlDataAdapter.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Employee", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("职工号", "职工号"),
new System.Data.Common.DataColumnMapping("职工名称", "职工名称"),
new System.Data.Common.DataColumnMapping("性别", "性别"),
new System.Data.Common.DataColumnMapping("部门号", "部门号"),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -