📄 frmbasedataman.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data ;
using ExamCenter.BLCTier;
namespace ExamCenter.FormTier
{
/// <summary>
/// FrmDataManage 的摘要说明。
/// </summary>
public class FrmBaseDataMan : System.Windows.Forms.Form
{
//记录树中被选定节点对应的行信息
private BaseDataUnit bduCurrent=new BaseDataUnit();
//dsBDU是包含所有基础数据的数据集,dtBDU是包含所有基础数据的数据表
//dvBDU是dtBDU的默认数据视图
private DataSet dsBDU;
private DataTable dtBDU;
private DataView dvBDU;
private System.Windows.Forms.TreeView trDataFunction;
private System.Windows.Forms.DataGrid dgDisplay;
private System.Windows.Forms.TextBox txtDescription;
private System.Windows.Forms.Button btnAddNode;
private System.Windows.Forms.Button btnDeleteNode;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.Button btnCancelOperation;
private System.Windows.Forms.Button btnModify;
private System.Windows.Forms.GroupBox grpDescription;
private System.Windows.Forms.TextBox txtSectionID;
private System.Windows.Forms.Label lblSectionID;
private System.Windows.Forms.Label lbtName;
private System.Windows.Forms.Label lblDescription;
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.Label lblExit;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ImageList imageList1;
private System.ComponentModel.IContainer components;
public FrmBaseDataMan()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
//获得所有包含所有数据的数据集dsBDU,同时初始化dtBDU和dvBDU
//然后根据dtBDU创建树
dsBDU=new BaseDataManBLC().GetAllBaseData ();
dtBDU=dsBDU.Tables [0];
dvBDU =dtBDU .DefaultView ;
SetDgTableStyle ();
RefreshTree();
//
//将txtID,txtName,txtDescription文本框的Text属性绑定到dvBDU的对应列
this.txtSectionID.DataBindings.Add ("Text",dvBDU,"sectionID");
this.txtName.DataBindings .Add ("Text",dvBDU,"name");
this.txtDescription .DataBindings .Add ("Text",dvBDU,"description");
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmBaseDataMan));
this.trDataFunction = new System.Windows.Forms.TreeView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.dgDisplay = new System.Windows.Forms.DataGrid();
this.txtDescription = new System.Windows.Forms.TextBox();
this.btnAddNode = new System.Windows.Forms.Button();
this.btnDeleteNode = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.txtName = new System.Windows.Forms.TextBox();
this.btnCancelOperation = new System.Windows.Forms.Button();
this.btnModify = new System.Windows.Forms.Button();
this.grpDescription = new System.Windows.Forms.GroupBox();
this.lblDescription = new System.Windows.Forms.Label();
this.lbtName = new System.Windows.Forms.Label();
this.lblSectionID = new System.Windows.Forms.Label();
this.txtSectionID = new System.Windows.Forms.TextBox();
this.lblTitle = new System.Windows.Forms.Label();
this.lblExit = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
((System.ComponentModel.ISupportInitialize)(this.dgDisplay)).BeginInit();
this.grpDescription.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// trDataFunction
//
this.trDataFunction.ImageList = this.imageList1;
this.trDataFunction.Location = new System.Drawing.Point(8, 32);
this.trDataFunction.Name = "trDataFunction";
this.trDataFunction.SelectedImageIndex = 1;
this.trDataFunction.Size = new System.Drawing.Size(184, 408);
this.trDataFunction.TabIndex = 0;
this.trDataFunction.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.trDataFunction_AfterSelect);
this.trDataFunction.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.trDataFunction_BeforeSelect);
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// dgDisplay
//
this.dgDisplay.BackColor = System.Drawing.SystemColors.ScrollBar;
this.dgDisplay.BackgroundColor = System.Drawing.Color.WhiteSmoke;
this.dgDisplay.CaptionVisible = false;
this.dgDisplay.DataMember = "";
this.dgDisplay.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgDisplay.Location = new System.Drawing.Point(8, 17);
this.dgDisplay.Name = "dgDisplay";
this.dgDisplay.ReadOnly = true;
this.dgDisplay.Size = new System.Drawing.Size(408, 175);
this.dgDisplay.TabIndex = 11;
//
// txtDescription
//
this.txtDescription.Location = new System.Drawing.Point(64, 56);
this.txtDescription.MaxLength = 100;
this.txtDescription.Multiline = true;
this.txtDescription.Name = "txtDescription";
this.txtDescription.ReadOnly = true;
this.txtDescription.Size = new System.Drawing.Size(352, 96);
this.txtDescription.TabIndex = 4;
this.txtDescription.Text = "";
//
// btnAddNode
//
this.btnAddNode.BackColor = System.Drawing.Color.Transparent;
this.btnAddNode.Location = new System.Drawing.Point(200, 408);
this.btnAddNode.Name = "btnAddNode";
this.btnAddNode.Size = new System.Drawing.Size(72, 23);
this.btnAddNode.TabIndex = 1;
this.btnAddNode.Text = "添加";
this.btnAddNode.Click += new System.EventHandler(this.btnAddNode_Click);
//
// btnDeleteNode
//
this.btnDeleteNode.BackColor = System.Drawing.Color.Transparent;
this.btnDeleteNode.Location = new System.Drawing.Point(280, 408);
this.btnDeleteNode.Name = "btnDeleteNode";
this.btnDeleteNode.Size = new System.Drawing.Size(72, 23);
this.btnDeleteNode.TabIndex = 7;
this.btnDeleteNode.Text = "删除";
this.btnDeleteNode.Click += new System.EventHandler(this.btnDeleteNode_Click);
//
// btnSave
//
this.btnSave.BackColor = System.Drawing.Color.Transparent;
this.btnSave.Enabled = false;
this.btnSave.Location = new System.Drawing.Point(440, 408);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(72, 23);
this.btnSave.TabIndex = 5;
this.btnSave.Text = "保存";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(216, 24);
this.txtName.MaxLength = 25;
this.txtName.Multiline = true;
this.txtName.Name = "txtName";
this.txtName.ReadOnly = true;
this.txtName.Size = new System.Drawing.Size(200, 21);
this.txtName.TabIndex = 3;
this.txtName.Text = "";
//
// btnCancelOperation
//
this.btnCancelOperation.BackColor = System.Drawing.Color.Transparent;
this.btnCancelOperation.Enabled = false;
this.btnCancelOperation.Location = new System.Drawing.Point(520, 408);
this.btnCancelOperation.Name = "btnCancelOperation";
this.btnCancelOperation.Size = new System.Drawing.Size(88, 23);
this.btnCancelOperation.TabIndex = 6;
this.btnCancelOperation.Text = "撤销全部操作";
this.btnCancelOperation.Click += new System.EventHandler(this.btnCancelOperation_Click);
//
// btnModify
//
this.btnModify.BackColor = System.Drawing.Color.Transparent;
this.btnModify.Location = new System.Drawing.Point(360, 408);
this.btnModify.Name = "btnModify";
this.btnModify.Size = new System.Drawing.Size(72, 23);
this.btnModify.TabIndex = 12;
this.btnModify.Text = "修改";
this.btnModify.Click += new System.EventHandler(this.btnModify_Click);
//
// grpDescription
//
this.grpDescription.BackColor = System.Drawing.Color.Transparent;
this.grpDescription.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblDescription,
this.lbtName,
this.lblSectionID,
this.txtDescription,
this.txtSectionID,
this.txtName});
this.grpDescription.Location = new System.Drawing.Point(196, 240);
this.grpDescription.Name = "grpDescription";
this.grpDescription.Size = new System.Drawing.Size(422, 160);
this.grpDescription.TabIndex = 15;
this.grpDescription.TabStop = false;
this.grpDescription.Text = "详细信息";
this.grpDescription.Enter += new System.EventHandler(this.grpDescription_Enter);
//
// lblDescription
//
this.lblDescription.Location = new System.Drawing.Point(8, 56);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(48, 16);
this.lblDescription.TabIndex = 7;
this.lblDescription.Text = "描述:";
this.lblDescription.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lbtName
//
this.lbtName.Location = new System.Drawing.Point(168, 26);
this.lbtName.Name = "lbtName";
this.lbtName.Size = new System.Drawing.Size(48, 16);
this.lbtName.TabIndex = 6;
this.lbtName.Text = "名称:";
this.lbtName.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblSectionID
//
this.lblSectionID.Location = new System.Drawing.Point(8, 26);
this.lblSectionID.Name = "lblSectionID";
this.lblSectionID.Size = new System.Drawing.Size(48, 16);
this.lblSectionID.TabIndex = 5;
this.lblSectionID.Text = "编号:";
this.lblSectionID.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// txtSectionID
//
this.txtSectionID.Location = new System.Drawing.Point(64, 24);
this.txtSectionID.MaxLength = 10;
this.txtSectionID.Multiline = true;
this.txtSectionID.Name = "txtSectionID";
this.txtSectionID.ReadOnly = true;
this.txtSectionID.Size = new System.Drawing.Size(104, 21);
this.txtSectionID.TabIndex = 0;
this.txtSectionID.Text = "";
//
// lblTitle
//
this.lblTitle.BackColor = System.Drawing.Color.Transparent;
this.lblTitle.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.lblTitle.Location = new System.Drawing.Point(256, 8);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(112, 16);
this.lblTitle.TabIndex = 16;
this.lblTitle.Text = "基 础 数 据 管 理";
//
// lblExit
//
this.lblExit.BackColor = System.Drawing.Color.Transparent;
this.lblExit.Location = new System.Drawing.Point(607, 3);
this.lblExit.Name = "lblExit";
this.lblExit.Size = new System.Drawing.Size(16, 14);
this.lblExit.TabIndex = 17;
this.lblExit.Click += new System.EventHandler(this.lblExit_Click);
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.Color.Transparent;
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.dgDisplay});
this.groupBox1.Location = new System.Drawing.Point(196, 32);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(422, 200);
this.groupBox1.TabIndex = 18;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "列表";
//
// FrmBaseDataMan
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Bitmap)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(625, 445);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblExit,
this.lblTitle,
this.grpDescription,
this.btnModify,
this.btnCancelOperation,
this.btnSave,
this.btnDeleteNode,
this.btnAddNode,
this.trDataFunction,
this.groupBox1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -