📄 xuqiuluruform.cs
字号:
//===========================================================================
// Smarclient FPMS Demo Project a sample project for SmartClient technology.
// Smarclient FPMS Demo is designed and implemented bases Microsoft Application Block tech.
// Author: SFPMS Team, Date 2004-11
// Vision 1.0
// Revison History
//=============================================================================
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using JSW.FPMS.Tool ;
namespace JSW.FPMS.Xiang.ShiTu
{
/// <summary>
/// clsXuQiuLuRuForm 的摘要说明。
/// </summary>
public class XuQiuLuRuForm : System.Windows.Forms.Form
{
#region 成员变量区域
private JSW.FPMS.Xiang.KongZhi.clsXuQiuChaXunKongZhi chaXunShuJu ;
private System.Windows.Forms.GroupBox GB_XinXiZu;
private System.Windows.Forms.GroupBox GB_FanKuiZu;
private System.Windows.Forms.Button BT_QueDing;
private System.Windows.Forms.Button BT_QuXiao;
System.Data.DataSet huoQuShuJu = null ;
private System.Windows.Forms.Panel PT_XinXiZu;
private System.Windows.Forms.Panel PT_FanKuiZu;
//日期控件
private RiQiForm mRiQiForm;
private string mdangQianShuRuK="" ;
//状态 0 乡级(只显示信息组) 1 县级信息组只读 2 调看 只显示信息组 且只读
private int mzhuangTai = 0;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
#endregion
#region 私有方法区域
/// <summary>
/// 窗体关闭事件
/// </summary>
private void XuQiuLuRuForm_Closed(object sender, System.EventArgs e)
{
mRiQiForm=null;
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.GB_XinXiZu = new System.Windows.Forms.GroupBox();
this.PT_XinXiZu = new System.Windows.Forms.Panel();
this.GB_FanKuiZu = new System.Windows.Forms.GroupBox();
this.PT_FanKuiZu = new System.Windows.Forms.Panel();
this.BT_QueDing = new System.Windows.Forms.Button();
this.BT_QuXiao = new System.Windows.Forms.Button();
this.GB_XinXiZu.SuspendLayout();
this.GB_FanKuiZu.SuspendLayout();
this.SuspendLayout();
//
// GB_XinXiZu
//
this.GB_XinXiZu.Controls.Add(this.PT_XinXiZu);
this.GB_XinXiZu.Location = new System.Drawing.Point(0, 0);
this.GB_XinXiZu.Name = "GB_XinXiZu";
this.GB_XinXiZu.Size = new System.Drawing.Size(576, 264);
this.GB_XinXiZu.TabIndex = 0;
this.GB_XinXiZu.TabStop = false;
this.GB_XinXiZu.Text = "信息组";
//
// PT_XinXiZu
//
this.PT_XinXiZu.AutoScroll = true;
this.PT_XinXiZu.Dock = System.Windows.Forms.DockStyle.Fill;
this.PT_XinXiZu.Location = new System.Drawing.Point(3, 17);
this.PT_XinXiZu.Name = "PT_XinXiZu";
this.PT_XinXiZu.Size = new System.Drawing.Size(570, 244);
this.PT_XinXiZu.TabIndex = 0;
//
// GB_FanKuiZu
//
this.GB_FanKuiZu.Controls.Add(this.PT_FanKuiZu);
this.GB_FanKuiZu.Location = new System.Drawing.Point(0, 264);
this.GB_FanKuiZu.Name = "GB_FanKuiZu";
this.GB_FanKuiZu.Size = new System.Drawing.Size(576, 184);
this.GB_FanKuiZu.TabIndex = 1;
this.GB_FanKuiZu.TabStop = false;
this.GB_FanKuiZu.Text = "反馈组";
//
// PT_FanKuiZu
//
this.PT_FanKuiZu.Dock = System.Windows.Forms.DockStyle.Fill;
this.PT_FanKuiZu.Location = new System.Drawing.Point(3, 17);
this.PT_FanKuiZu.Name = "PT_FanKuiZu";
this.PT_FanKuiZu.Size = new System.Drawing.Size(570, 164);
this.PT_FanKuiZu.TabIndex = 0;
//
// BT_QueDing
//
this.BT_QueDing.Location = new System.Drawing.Point(384, 456);
this.BT_QueDing.Name = "BT_QueDing";
this.BT_QueDing.TabIndex = 2;
this.BT_QueDing.Text = "确定";
this.BT_QueDing.Click += new System.EventHandler(this.BT_QueDing_Click);
//
// BT_QuXiao
//
this.BT_QuXiao.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.BT_QuXiao.Location = new System.Drawing.Point(472, 456);
this.BT_QuXiao.Name = "BT_QuXiao";
this.BT_QuXiao.TabIndex = 3;
this.BT_QuXiao.Text = "取消";
this.BT_QuXiao.Click += new System.EventHandler(this.BT_QuXiao_Click);
//
// XuQiuLuRuForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(576, 485);
this.Controls.Add(this.BT_QuXiao);
this.Controls.Add(this.BT_QueDing);
this.Controls.Add(this.GB_FanKuiZu);
this.Controls.Add(this.GB_XinXiZu);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "XuQiuLuRuForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "需求录入";
this.Closed += new System.EventHandler(this.XuQiuLuRuForm_Closed);
this.GB_XinXiZu.ResumeLayout(false);
this.GB_FanKuiZu.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 设置窗体显示尺寸
/// </summary>
private void SheZhiFormSize()
{
int xinXiDianShuLiang = 0;
int fanKuiZuSHuLiang = 0;
int buChang = 30;
int touGao = 30 ;
System.Data.DataRow[] xinXiZu = huoQuShuJu.Tables["PeiZhi"].Select("ShuJuZuKJM = 'XinXiZu'");
System.Data.DataRow[] fanKuiZu = huoQuShuJu.Tables["PeiZhi"].Select("ShuJuZuKJM = 'FanKuiZu'");
xinXiDianShuLiang = xinXiZu.Length ;
fanKuiZuSHuLiang = fanKuiZu.Length ;
if (xinXiDianShuLiang%2==0)
xinXiDianShuLiang = (xinXiDianShuLiang/2) * buChang + touGao;
else
xinXiDianShuLiang = (xinXiDianShuLiang/2+1) * buChang + touGao;
if (this.mzhuangTai==0)
{
if (xinXiDianShuLiang<180)
this.GB_XinXiZu.Height = 180 ;
else if (xinXiDianShuLiang>600)
this.GB_XinXiZu.Height = 600 ;
else
this.GB_XinXiZu.Height = xinXiDianShuLiang ;
}
else
{
if (xinXiDianShuLiang<180)
this.GB_XinXiZu.Height = 180 ;
else if (xinXiDianShuLiang>400)
this.GB_XinXiZu.Height = 400 ;
else
this.GB_XinXiZu.Height = xinXiDianShuLiang ;
}
if (fanKuiZuSHuLiang%2==0)
fanKuiZuSHuLiang = (fanKuiZuSHuLiang/2) * buChang + touGao;
else
fanKuiZuSHuLiang = (fanKuiZuSHuLiang/2+1) * buChang + touGao;
if (fanKuiZuSHuLiang<100)
this.GB_FanKuiZu.Height = 100 ;
else if (fanKuiZuSHuLiang<200)
this.GB_FanKuiZu.Height = 200 ;
else
this.GB_FanKuiZu.Height = fanKuiZuSHuLiang ;
this.GB_FanKuiZu.Top = this.GB_XinXiZu.Top + this.GB_XinXiZu.Height ;
if (this.mzhuangTai==0)
this.Height = this.GB_XinXiZu.Top + this.GB_XinXiZu.Height + 70 ;
else
this.Height = this.GB_FanKuiZu.Top + this.GB_FanKuiZu.Height + 70 ;
this.BT_QueDing.Top = this.Height - 60 ;
this.BT_QuXiao.Top = this.Height - 60 ;
}
/// <summary>
/// 初始化信息组控件
/// </summary>
private void ChuShiHuaXinXiZu (System.Data.DataSet huoQuShuJu)
{
System.Data.DataRow[] xinXiZu = huoQuShuJu.Tables["PeiZhi"].Select("ShuJuZuKJM = 'XinXiZu'");
if (xinXiZu.Length==0) return ;
//排序
System.Collections.ArrayList list = new ArrayList() ;
System.Collections.Hashtable table = new Hashtable() ;
int paixu=0 ;
for (int i=0;i<xinXiZu.Length ;i++)
{
paixu = int.Parse(xinXiZu[i]["XianShiShunXu"].ToString().Trim());
if (!table.ContainsKey(paixu))
{
table.Add(paixu,xinXiZu[i]) ;
list.Add (paixu) ;
}
}
list.Sort();
for (int i=0;i<list.Count ;i++)
{
ChangJianKJ(PT_XinXiZu,(System.Data.DataRow)table[(int)list[i]],i) ;
}
}
/// <summary>
/// 初始化反馈组控件
/// </summary>
private void ChuShiHuaFanKuiZu (System.Data.DataSet huoQuShuJu)
{
System.Data.DataRow[] xinXiZu = huoQuShuJu.Tables["PeiZhi"].Select("ShuJuZuKJM = 'FanKuiZu'");
if (xinXiZu.Length==0) return ;
//排序
System.Collections.ArrayList list = new ArrayList() ;
System.Collections.Hashtable table = new Hashtable() ;
int paixu=0 ;
for (int i=0;i<xinXiZu.Length ;i++)
{
paixu = int.Parse(xinXiZu[i]["XianShiShunXu"].ToString().Trim());
if (!table.ContainsKey(paixu))
{
table.Add(paixu,xinXiZu[i]) ;
list.Add (paixu) ;
}
}
list.Sort();
for (int i=0;i<list.Count ;i++)
{
ChangJianKJ(PT_FanKuiZu,(System.Data.DataRow)table[(int)list[i]],i) ;
}
}
/// <summary>
/// 创建控件
/// </summary>
private void ChangJianKJ(Control fuKongJian ,System.Data.DataRow shujuxiang,int buChang)
{
int hangZuoBiao = 0 ;
int lieZuoBiao = 0 ;
if ((buChang%2)==0)
{
hangZuoBiao = 30 ;
lieZuoBiao = (buChang+1) * 15 ;
}
else
{
hangZuoBiao = 310 ;
lieZuoBiao = buChang * 15 ;
}
//创建标题
Label biaoTi = new Label() ;
biaoTi.Name = "LB_" + shujuxiang["ShuJuXiangKJM"].ToString().Trim() ;
biaoTi.Text = shujuxiang["ShuJuXiangMing"].ToString().Trim() ;
biaoTi.Location = new System.Drawing.Point(hangZuoBiao, lieZuoBiao);
biaoTi.Size = new System.Drawing.Size(90, 25);
fuKongJian.Controls.Add(biaoTi) ;
//创建输入框
string kongJianLX = shujuxiang["ShuJuXiangMing"].ToString().Trim() ;
switch (kongJianLX)
{
case "需求类别" :
ChuangJianXuQiu(fuKongJian,shujuxiang,hangZuoBiao,lieZuoBiao) ;
break;
case "信息点编号" :
ChuangJianXinXiDian(fuKongJian,shujuxiang,hangZuoBiao,lieZuoBiao) ;
break;
default :
ChuangJianText(fuKongJian,shujuxiang,hangZuoBiao,lieZuoBiao) ;
break;
}
}
/// <summary>
/// 创建需求控件
/// </summary>
private void ChuangJianXuQiu(Control fuKongJian ,System.Data.DataRow shujuxiang,int hangZuoBiao,int lieZuoBiao )
{
//创建下拉框
ComboBox shuRuKuang = new ComboBox() ;
shuRuKuang.Name = "TB_" + shujuxiang["ShuJuXiangKJM"].ToString().Trim() ;
shuRuKuang.Location = new System.Drawing.Point((hangZuoBiao+100) , lieZuoBiao);
shuRuKuang.Size = new System.Drawing.Size(130, 25);
shuRuKuang.KeyDown += new System.Windows.Forms.KeyEventHandler(coboBox_KeyDown);
shuRuKuang.KeyPress += new System.Windows.Forms.KeyPressEventHandler(coboBox_KeyPress);
for (int i=0;i<huoQuShuJu.Tables["XuQiuFenLei"].Rows.Count;i++)
{
shuRuKuang.Items.Add (huoQuShuJu.Tables["XuQiuFenLei"].Rows[i]["XuQiuDaMaMingXi"].ToString().Trim()) ;
}
shuRuKuang.SelectedIndex = 0 ;
fuKongJian.Controls.Add(shuRuKuang) ;
}
/// <summary>
/// 创建信息点控件
/// </summary>
private void ChuangJianXinXiDian(Control fuKongJian ,System.Data.DataRow shujuxiang,int hangZuoBiao,int lieZuoBiao )
{
//创建下拉框
ComboBox shuRuKuang = new ComboBox() ;
shuRuKuang.Name = "TB_" + shujuxiang["ShuJuXiangKJM"].ToString().Trim() ;
shuRuKuang.Location = new System.Drawing.Point((hangZuoBiao+100) , lieZuoBiao);
shuRuKuang.Size = new System.Drawing.Size(130, 25);
shuRuKuang.KeyDown += new System.Windows.Forms.KeyEventHandler(coboBox_KeyDown);
shuRuKuang.KeyPress += new System.Windows.Forms.KeyPressEventHandler(coboBox_KeyPress);
for (int i=0;i<huoQuShuJu.Tables["XinXiDian"].Rows.Count;i++)
{
shuRuKuang.Items.Add (huoQuShuJu.Tables["XinXiDian"].Rows[i]["XinXiDianXiJie"].ToString().Trim()) ;
}
shuRuKuang.SelectedIndex = 0 ;
fuKongJian.Controls.Add(shuRuKuang) ;
}
/// <summary>
/// 创建TextBox控件
/// </summary>
private void ChuangJianText(Control fuKongJian ,System.Data.DataRow shujuxiang,int hangZuoBiao,int lieZuoBiao )
{
//创建输入框
TextBox shuRuKuang = new TextBox() ;
shuRuKuang.Name = "TB_" + shujuxiang["ShuJuXiangKJM"].ToString().Trim() ;
shuRuKuang.MaxLength = int.Parse(shujuxiang["ZuiDaShuRuChangDu"].ToString().Trim()) ;
shuRuKuang.Location = new System.Drawing.Point((hangZuoBiao+100) , lieZuoBiao);
shuRuKuang.Size = new System.Drawing.Size(130, 25);
if (shujuxiang["ZhiDu"].ToString().Trim()=="Y")
shuRuKuang.ReadOnly = true ;
if (shujuxiang["MoRenZhi"].ToString().Trim()!="")
shuRuKuang.Text = shujuxiang["MoRenZhi"].ToString().Trim() ;
//处理数据项类型
string leiXing = shujuxiang["ShuJuXiangKJLX"].ToString().Trim() ;
switch (leiXing)
{
case "日期数据类型":
shuRuKuang.ReadOnly = true ;
//创建按钮
Button BT_RiQI = new Button() ;
BT_RiQI.Name = "BT_" + shujuxiang["ShuJuXiangKJM"].ToString().Trim() ;
BT_RiQI.Text = "..." ;
BT_RiQI.Size = new System.Drawing.Size(23, 23) ;
BT_RiQI.Location = new System.Drawing.Point((hangZuoBiao+230), lieZuoBiao);
BT_RiQI.Click += new System.EventHandler(this.BT_RiQi_Click);
fuKongJian.Controls.Add(BT_RiQI) ;
break;
case "浮点数据类型":
shuRuKuang.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtBox_KeyPress);
shuRuKuang.ReadOnly = false ;
break;
}
fuKongJian.Controls.Add(shuRuKuang) ;
}
/// <summary>
/// 取值
/// </summary>
/// <param name="kongjianm"></param>
/// <returns></returns>
private string QuZhi(string kongjianm)
{
string lzhi="";
Control ctl=(HuoQuKJ(kongjianm));
if (ctl!=null)
{
if(ctl.GetType().Equals(typeof(System.Windows.Forms.TextBox)))
lzhi=((TextBox)ctl).Text;
if(ctl.GetType().Equals(typeof(System.Windows.Forms.ComboBox)))
lzhi=((ComboBox)ctl).SelectedIndex.ToString() ;
}
return lzhi ;
}
/// <summary>
/// 赋值
/// </summary>
private void FuZhi(string kongjianm,string zhi)
{
Control ctl=(HuoQuKJ(kongjianm));
if (ctl!=null)
{
if(ctl.GetType().Equals(typeof(System.Windows.Forms.TextBox)))
((TextBox)ctl).Text = zhi ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -