📄 frmplatfdept.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
using System.Threading;
using GlobleUtility;
namespace PlatF
{
/// <summary>
/// 部门信息的查询界面。
/// </summary>
public class CfrmPlatFDept : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView lvDept;
private System.Windows.Forms.ImageList imageListtbr;
private System.Windows.Forms.ToolBar tbrDept;
private System.Windows.Forms.ToolBarButton toolBarButton8;
private System.Windows.Forms.ToolBarButton tbrButtonAdd;
private System.Windows.Forms.ToolBarButton tbrButtonDel;
private System.Windows.Forms.ToolBarButton tbrButtonExit;
private System.Windows.Forms.Label labview;
private System.ComponentModel.IContainer components;
private ArrayList arrayPipe;
public CfrmPlatFDept()
{
//
// 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()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CfrmPlatFDept));
this.lvDept = new System.Windows.Forms.ListView();
this.imageListtbr = new System.Windows.Forms.ImageList(this.components);
this.tbrDept = new System.Windows.Forms.ToolBar();
this.toolBarButton8 = new System.Windows.Forms.ToolBarButton();
this.tbrButtonAdd = new System.Windows.Forms.ToolBarButton();
this.tbrButtonDel = new System.Windows.Forms.ToolBarButton();
this.tbrButtonExit = new System.Windows.Forms.ToolBarButton();
this.labview = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lvDept
//
this.lvDept.BackColor = System.Drawing.SystemColors.Info;
this.lvDept.Location = new System.Drawing.Point(8, 104);
this.lvDept.Name = "lvDept";
this.lvDept.Size = new System.Drawing.Size(696, 304);
this.lvDept.TabIndex = 0;
this.lvDept.DoubleClick += new System.EventHandler(this.lvDept_DoubleClick);
this.lvDept.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvDept_ColumnClick);
//
// 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.tbrButtonAdd,
this.tbrButtonDel,
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(712, 58);
this.tbrDept.TabIndex = 8;
this.tbrDept.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbrDept_ButtonClick);
//
// toolBarButton8
//
this.toolBarButton8.Enabled = false;
this.toolBarButton8.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbrButtonAdd
//
this.tbrButtonAdd.ImageIndex = 0;
this.tbrButtonAdd.Text = "新增";
this.tbrButtonAdd.ToolTipText = "新增";
//
// tbrButtonDel
//
this.tbrButtonDel.ImageIndex = 3;
this.tbrButtonDel.Text = "删除";
this.tbrButtonDel.ToolTipText = "删除";
//
// tbrButtonExit
//
this.tbrButtonExit.ImageIndex = 6;
this.tbrButtonExit.Text = "退出";
this.tbrButtonExit.ToolTipText = "退出";
//
// labview
//
this.labview.Font = new System.Drawing.Font("黑体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.labview.Location = new System.Drawing.Point(8, 64);
this.labview.Name = "labview";
this.labview.Size = new System.Drawing.Size(696, 32);
this.labview.TabIndex = 9;
this.labview.Text = "部门信息:";
//
// CfrmPlatFDept
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(712, 429);
this.Controls.Add(this.labview);
this.Controls.Add(this.tbrDept);
this.Controls.Add(this.lvDept);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CfrmPlatFDept";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "部门信息维护";
this.Load += new System.EventHandler(this.CfrmPlatFDept_Load);
this.ResumeLayout(false);
}
#endregion
private void CfrmPlatFDept_Load(object sender, System.EventArgs e)
{
//窗体初始化
Deptview();
//对arrayPipe分配内存空间,保存查询窗体传递回来的sql查询语句
this.arrayPipe = new ArrayList();
}
/******************************************************************
* 功能:将listview与数据库记录集绑定,并在listview中显示出来,数据库记录集使用OracleDataReader
*
* 输入参数:1、lvDataReader,使用OracleDataReader生成的记录集,将其绑定在sLV上
* 2、sLV,要绑定的listview名称
* 输出参数:无
*
* 最后修改时间:04-08-12 by cellz
* ******************************************************************************/
private void BindingsListView(OracleDataReader lvDataReader,ListView sLV)
{
sLV.View=View.Details;
sLV.GridLines=true;
sLV.ListViewItemSorter=null;
for(int i=0;i<lvDataReader.FieldCount;i++)
{
//生成listview列头标
sLV.Columns.Add (lvDataReader.GetName(i),80,HorizontalAlignment.Center);
}
sLV.Columns.RemoveAt(0); //因为首列标是无意义的id字段,所以删除首列标
lvTagTemp TagTemp= new lvTagTemp();//为结构lvTagTemp分配内存
while (lvDataReader.Read ())
{
ListViewItem cmicItem=new ListViewItem();
//将第一个id字段以结构的形式赋给viewitem的tag属性
TagTemp.temp_id = lvDataReader.GetValue(0).ToString().Trim();
cmicItem.Tag = TagTemp;
//(cmicItem.Tag as lvTagTemp).temp_id ; //tag属性的使用方法
//将第二个字段赋给viewitem的第一列
cmicItem.Text= lvDataReader.GetValue(1).ToString().Trim();
//从第三个字段开始依次从viewitem的第二列开始显示
for(int i=2;i<lvDataReader.FieldCount;i++)
{
cmicItem.SubItems.Add(lvDataReader.GetValue(i).ToString().Trim());
}
sLV.Items.Add(cmicItem);
}
}
/***************************************************************************************************************
* 功能:将listview与数据库记录集绑定,并在listview中显示出来,数据库记录集使用DataSet
*
*输入参数:1、sDs,使用DataSet生成的记录集,将其绑定在sLV上
* 2、sLV,要绑定的listview名称
* 输出参数:无
*
* 最后修改时间:04-08-12 by cellz
* ************************************************************************************************************/
private void BindingsListView(DataSet sDs,ListView sLV)
{
sLV.View=View.Details;
sLV.GridLines=true;
sLV.ListViewItemSorter=null;
if(sDs.Tables.Count!=0)
{
DataTable cmicDt=sDs.Tables[0];
foreach(DataColumn sDc in cmicDt.Columns)
{
//生成listview列头标,调用CaseName函数以中文显示列头
sLV.Columns.Add(sDc.ColumnName,80,HorizontalAlignment.Center);
}
sLV.Columns.RemoveAt(0); //因为首列标是无意义的id字段,所以删除首列标
lvTagTemp TagTemp= new lvTagTemp();//为结构lvTagTemp分配内存
for(int i=0;i<cmicDt.Rows.Count;i++)
{
ListViewItem cmicItem=new ListViewItem();
//将第一个id字段以结构的形式赋给viewitem的tag属性
TagTemp.temp_id = cmicDt.Rows[i][0].ToString().Trim();
cmicItem.Tag = TagTemp;
//将第二个字段赋给viewitem的第一列
cmicItem.Text= cmicDt.Rows[i][1].ToString().Trim();
//从第三个字段开始依次从viewitem的第二列开始显示
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -