?? frmplatfdeptinfo.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
using GlobleUtility;
using Charge;
namespace PlatF
{
/// <summary>
/// 部門詳細信息的查看修改界面。
/// </summary>
public class CfrmPlatFDeptInfo : System.Windows.Forms.Form
{
#region
private System.Windows.Forms.GroupBox gbDept;
private System.Windows.Forms.Label labId;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtDeptName;//“部門名稱“文本框
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ImageList imageListtbr;
private System.Windows.Forms.ToolBar tbrDept;
private System.Windows.Forms.ToolBarButton toolBarButton8;
private System.Windows.Forms.ToolBarButton tbrButtonSave;//工具欄上“保存”按鈕
private System.Windows.Forms.ToolBarButton tbrButtonExit;//工具欄上“退出”按鈕
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.ComboBox cbbIsTeach;//“是否下屬教工”下拉框
private System.Windows.Forms.ComboBox cbbIsStud; //“是否下屬學生”下拉框
private System.Windows.Forms.TextBox txtOwnerDeptName;//“上級部門”文本框
private System.Windows.Forms.TextBox txtDeptDesc;//”部門描述“文本框
private System.Windows.Forms.TextBox txtDeptNumber;//”部門人數“文本框
private System.Windows.Forms.Button btnDeptSel;//上級部門選擇安鈕
#endregion
ListView tp_lvDept;
private string OrgName; //保存學校名稱
private int OrgID; //保存學校ID
private string OwnerDeptName; //保存初始上級部門名稱
private int OwnerDeptID; //保存上級部門ID
public CfrmPlatFDeptInfo(ListView lvDept,int AddSign)
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//初始化pnlDept部門顯示控件
//數據庫查詢操作,listview中按照名稱順序顯示記錄
System.Data.OracleClient.OracleConnection Org_myConn = Connection.DBConnection;
if (Org_myConn == null)
{
return;
}
//判斷有無學校信息存在,如果沒有,則無法新建部門
string Org_mySql = "SELECT OrgName FROM Charge_School_Info";
OracleCommand selCommand = new OracleCommand(Org_mySql,Org_myConn);
OracleDataReader trvDataReader = null;
try
{
trvDataReader = selCommand.ExecuteReader();
}
catch(Exception ee)
{
MessageBox.Show("數據庫查詢出錯,消息如下:\r\n"+ee.Message,"消息:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
if (!trvDataReader.HasRows)
{
MessageBox.Show("在建立部門信息之前必須建立學校信息!");
this.Close();
}
trvTagTemp TagTemp= new trvTagTemp();//為結構trvTagTemp分配內存
TreeNode rootNode = new TreeNode();
while (trvDataReader.Read ())
{
OrgName = trvDataReader.GetValue(0).ToString().Trim();
OrgID = 0;
}
//對父窗體listview的引用
tp_lvDept=lvDept;
//初始化DateTimer,comboBox
cbbIsStud.Items.Add("是");
cbbIsStud.Items.Add("否");
cbbIsStud.SelectedIndex = 1;
cbbIsTeach.Items.Add("是");
cbbIsTeach.Items.Add("否");
cbbIsTeach.SelectedIndex = 0;
cbbIsStud.DropDownStyle = ComboBoxStyle.DropDownList;
cbbIsTeach.DropDownStyle = ComboBoxStyle.DropDownList;
//新增信息操作窗體
if (AddSign ==1)
{
//toolbar設置
tbrButtonSave.Enabled = false;
//groupbox內控件設置
txtDeptName.ReadOnly = false;
txtDeptDesc.ReadOnly = false;
txtDeptNumber.ReadOnly =false;
cbbIsStud.Enabled =true;
cbbIsTeach.Enabled =true;
txtOwnerDeptName.ReadOnly = true;
btnDeptSel.Enabled = true;
labId.Text = "";
//初始化部門信息
txtDeptName.Text = "";
txtDeptDesc.Text = "";
txtDeptNumber.Text = "";
//初始化上級部門名稱,默認為學校名稱
txtOwnerDeptName.Text = OrgName;
txtOwnerDeptName.Tag = OrgID;
//在變量中保存當前上級部門名稱與ID
OwnerDeptName = OrgName;
OwnerDeptID = OrgID;
txtDeptName.Focus();
return;
}
//
// 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()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CfrmPlatFDeptInfo));
this.gbDept = new System.Windows.Forms.GroupBox();
this.txtDeptDesc = new System.Windows.Forms.TextBox();
this.cbbIsStud = new System.Windows.Forms.ComboBox();
this.label8 = new System.Windows.Forms.Label();
this.txtDeptNumber = new System.Windows.Forms.TextBox();
this.cbbIsTeach = new System.Windows.Forms.ComboBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txtOwnerDeptName = new System.Windows.Forms.TextBox();
this.btnDeptSel = new System.Windows.Forms.Button();
this.txtDeptName = new System.Windows.Forms.TextBox();
this.labId = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.imageListtbr = new System.Windows.Forms.ImageList(this.components);
this.tbrDept = new System.Windows.Forms.ToolBar();
this.toolBarButton8 = new System.Windows.Forms.ToolBarButton();
this.tbrButtonSave = new System.Windows.Forms.ToolBarButton();
this.tbrButtonExit = new System.Windows.Forms.ToolBarButton();
this.gbDept.SuspendLayout();
this.SuspendLayout();
//
// gbDept
//
this.gbDept.Controls.Add(this.txtDeptDesc);
this.gbDept.Controls.Add(this.cbbIsStud);
this.gbDept.Controls.Add(this.label8);
this.gbDept.Controls.Add(this.txtDeptNumber);
this.gbDept.Controls.Add(this.cbbIsTeach);
this.gbDept.Controls.Add(this.label10);
this.gbDept.Controls.Add(this.label9);
this.gbDept.Controls.Add(this.txtOwnerDeptName);
this.gbDept.Controls.Add(this.btnDeptSel);
this.gbDept.Controls.Add(this.txtDeptName);
this.gbDept.Controls.Add(this.labId);
this.gbDept.Controls.Add(this.label1);
this.gbDept.Controls.Add(this.label2);
this.gbDept.Controls.Add(this.label7);
this.gbDept.Location = new System.Drawing.Point(8, 64);
this.gbDept.Name = "gbDept";
this.gbDept.Size = new System.Drawing.Size(520, 216);
this.gbDept.TabIndex = 2;
this.gbDept.TabStop = false;
this.gbDept.Text = "部門信息";
//
// txtDeptDesc
//
this.txtDeptDesc.Location = new System.Drawing.Point(72, 56);
this.txtDeptDesc.MaxLength = 100;
this.txtDeptDesc.Multiline = true;
this.txtDeptDesc.Name = "txtDeptDesc";
this.txtDeptDesc.Size = new System.Drawing.Size(440, 104);
this.txtDeptDesc.TabIndex = 6;
this.txtDeptDesc.Text = "textBox2";
//
// cbbIsStud
//
this.cbbIsStud.Location = new System.Drawing.Point(256, 176);
this.cbbIsStud.Name = "cbbIsStud";
this.cbbIsStud.Size = new System.Drawing.Size(72, 20);
this.cbbIsStud.TabIndex = 8;
this.cbbIsStud.Text = "comboBox2";
//
// label8
//
this.label8.Location = new System.Drawing.Point(160, 176);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(96, 23);
this.label8.TabIndex = 25;
this.label8.Text = "是否下屬學生:";
//
// txtDeptNumber
//
this.txtDeptNumber.ImeMode = System.Windows.Forms.ImeMode.Alpha;
this.txtDeptNumber.Location = new System.Drawing.Point(72, 176);
this.txtDeptNumber.MaxLength = 10;
this.txtDeptNumber.Name = "txtDeptNumber";
this.txtDeptNumber.Size = new System.Drawing.Size(72, 21);
this.txtDeptNumber.TabIndex = 7;
this.txtDeptNumber.Text = "textBox1";
//
// cbbIsTeach
//
this.cbbIsTeach.Location = new System.Drawing.Point(440, 176);
this.cbbIsTeach.Name = "cbbIsTeach";
this.cbbIsTeach.Size = new System.Drawing.Size(72, 20);
this.cbbIsTeach.TabIndex = 9;
this.cbbIsTeach.Text = "comboBox1";
//
// label10
//
this.label10.Location = new System.Drawing.Point(8, 88);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(72, 23);
this.label10.TabIndex = 29;
this.label10.Text = "部門描述:";
//
// label9
//
this.label9.Location = new System.Drawing.Point(344, 176);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(96, 23);
this.label9.TabIndex = 26;
this.label9.Text = "是否下屬教工:";
//
// txtOwnerDeptName
//
this.txtOwnerDeptName.Location = new System.Drawing.Point(328, 24);
this.txtOwnerDeptName.Name = "txtOwnerDeptName";
this.txtOwnerDeptName.Size = new System.Drawing.Size(168, 21);
this.txtOwnerDeptName.TabIndex = 2;
this.txtOwnerDeptName.Text = "textBox1";
this.txtOwnerDeptName.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtOwnerDeptName_KeyUp);
//
// btnDeptSel
//
this.btnDeptSel.Font = new System.Drawing.Font("宋體", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnDeptSel.Location = new System.Drawing.Point(496, 24);
this.btnDeptSel.Name = "btnDeptSel";
this.btnDeptSel.Size = new System.Drawing.Size(16, 24);
this.btnDeptSel.TabIndex = 3;
this.btnDeptSel.Text = "▼";
this.btnDeptSel.Click += new System.EventHandler(this.btnDeptSel_Click);
//
// txtDeptName
//
this.txtDeptName.Location = new System.Drawing.Point(72, 24);
this.txtDeptName.MaxLength = 20;
this.txtDeptName.Name = "txtDeptName";
this.txtDeptName.Size = new System.Drawing.Size(184, 21);
this.txtDeptName.TabIndex = 1;
this.txtDeptName.Text = "textBox1";
this.txtDeptName.TextChanged += new System.EventHandler(this.txtDeptName_TextChanged);
//
// labId
//
this.labId.Location = new System.Drawing.Point(16, 96);
this.labId.Name = "labId";
this.labId.TabIndex = 11;
this.labId.Visible = false;
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 0;
this.label1.Text = "部門名稱:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(264, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 16);
this.label2.TabIndex = 2;
this.label2.Text = "上級部門:";
//
// label7
//
this.label7.Location = new System.Drawing.Point(0, 176);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(72, 23);
this.label7.TabIndex = 24;
this.label7.Text = "部門人數:";
//
// imageListtbr
//
this.imageListtbr.ImageSize = new System.Drawing.Size(32, 32);
this.imageListtbr.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListtbr.ImageStream")));
this.imageListtbr.TransparentColor = System.Drawing.Color.Transparent;
//
// tbrDept
//
this.tbrDept.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton8,
this.tbrButtonSave,
this.tbrButtonExit});
this.tbrDept.ButtonSize = new System.Drawing.Size(52, 52);
this.tbrDept.DropDownArrows = true;
this.tbrDept.ImageList = this.imageListtbr;
this.tbrDept.Location = new System.Drawing.Point(0, 0);
this.tbrDept.Name = "tbrDept";
this.tbrDept.ShowToolTips = true;
this.tbrDept.Size = new System.Drawing.Size(536, 58);
this.tbrDept.TabIndex = 10;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -