using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace Pub_Control
|
{
|
public partial class frmHlpTree : Form
|
{
|
public frmHlpTree()
|
{
|
InitializeComponent();
|
}
|
public string WherePart;
|
public string sTitle;
|
public string sBill;
|
public string sView;
|
TreeNode CurNode=new TreeNode();
|
public Pub_Class.ClsPub.Enum_OKTag OKTag;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
private void frmHlpTree_Load(object sender, EventArgs e)
|
{
|
initGrid();
|
LoadTree();
|
}
|
//初始化GRID
|
private void initGrid()
|
{
|
//grdMain.Rows = 1;
|
grdMain.FixedCols = 0;
|
//grdMain.FixedRows = 1;
|
grdMain.RowHeightMin = 250;
|
grdMain.set_RowHeight(0, 450);
|
grdMain.ExplorerBar = VSFlex7.ExplorerBarSettings.flexExSort;
|
grdMain.AllowBigSelection = false;
|
grdMain.AllowSelection = true;
|
grdMain.SelectionMode = VSFlex7.SelModeSettings.flexSelectionListBox;
|
grdMain.AllowUserResizing = VSFlex7.AllowUserResizeSettings.flexResizeColumns;
|
grdMain.set_ColAlignment(-1, VSFlex7.AlignmentSettings.flexAlignLeftCenter);
|
//
|
Pub_Class.ClsPub.GetGrid(grdMain, sTitle, Pub_Class.ClsPub.AppPath);
|
//
|
lblCaption.Text = sTitle;
|
this.Text = sTitle;
|
//
|
grdMain.set_ColWidth(grdMain.Cols - 1, 10);
|
grdMain.ExtendLastCol = true;
|
grdMain.Col = 1;
|
}
|
//选中项目验证
|
private bool AllowRow()
|
{
|
if (grdMain.Row >= grdMain.FixedRows && grdMain.Row <= grdMain.Rows - 1)
|
return true;
|
else
|
return false;
|
}
|
//双击 GRID
|
private void grdMain_DblClick(object sender, EventArgs e)
|
{
|
if (AllowRow())
|
BackData();
|
}
|
//时间TIMER
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
this.Text = sTitle;
|
}
|
//返回
|
private void BackData()
|
{
|
OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_OK;
|
this.Visible = false;
|
}
|
//退出
|
private void tc_Click(object sender, EventArgs e)
|
{
|
OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_Cancel;
|
this.Visible = false;
|
}
|
//返回按钮
|
private void fh_Click(object sender, EventArgs e)
|
{
|
BackData();
|
}
|
//单击树形
|
private void tvProcess_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
{
|
CurNode = e.Node;
|
if (CurNode != null)
|
{
|
if (CurNode.Nodes.Count == 0)
|
{
|
LoadAllNodes(CurNode);
|
}
|
QueryItem();
|
}
|
}
|
//加载树型
|
private void LoadTree()
|
{
|
try
|
{
|
tvTree.Nodes.Clear();
|
tvTree.ImageList = imageList1;
|
TreeNode sNode = tvTree.Nodes.Add("T0", this.Text, 0, 1);
|
LoadAllNodes(sNode);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(this,"加载树型失败!" + e.Message,"提示");
|
}
|
}
|
//加载子项目
|
private void LoadAllNodes(TreeNode sNode)
|
{
|
if (sNode != null)
|
{
|
try
|
{
|
long sName = Convert.ToInt64(sNode.Name.Substring(1, sNode.Name.Length - 1));
|
sNode.Nodes.Clear();
|
DataSet Ds = oCn.RunProcReturn("select HItemID,HNumber,HName from " + sBill + " where HEndFlag=0 and HParentID='" + sName + "'", sBill);
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
TreeNode oNode = sNode.Nodes.Add("T" + Ds.Tables[0].Rows[i]["HItemID"].ToString(), Ds.Tables[0].Rows[i]["HNumber"].ToString() + "-" + Ds.Tables[0].Rows[i]["HName"].ToString(), 0, 1);
|
}
|
sNode.Expand();
|
}
|
catch (Exception e)
|
{
|
//MessageBox.Show("加载子项目失败!" + e.Message);
|
}
|
}
|
}
|
//合理的选中列
|
private bool AllowCol()
|
{
|
if (grdMain.Col >= grdMain.FixedCols && grdMain.Col <= grdMain.Cols - 1)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
//保存列宽
|
private void frmHlpTree_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
Pub_Class.ClsPub.SaveGrid(grdMain, sTitle, Pub_Class.ClsPub.AppPath);
|
}
|
//过滤项目
|
private void QueryItem()
|
{
|
string sTreeCode;
|
//得到树型 代码
|
try
|
{
|
//
|
int Col;
|
if (AllowCol())
|
Col = grdMain.Col;
|
else
|
Col = 1;
|
//
|
if (CurNode != null)
|
{
|
char c = Convert.ToChar("-");
|
string[] s = CurNode.Text.Split(c);
|
if (s.Length > 1)
|
{
|
sTreeCode = s[0].Trim().ToUpper();
|
}
|
else
|
{
|
sTreeCode = "";//选中 最大结点的时候
|
}
|
}
|
else
|
{
|
sTreeCode = "";
|
}
|
int j = sTreeCode.Length;
|
//显示全部
|
grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone;
|
for (int i = grdMain.FixedRows; i < grdMain.Rows; i++)
|
{
|
|
if (grdMain.get_TextMatrix(i, 1).Length <= j )
|
{
|
grdMain.set_RowHidden(i, true);
|
}
|
else
|
{
|
if (sTreeCode != "")
|
{
|
if (Pub_Class.ClsPub.isStrNull(grdMain.get_TextMatrix(i, 1)) != "")
|
{
|
if (grdMain.get_TextMatrix(i, 1).ToUpper().Trim() != sTreeCode)
|
{
|
if (grdMain.get_TextMatrix(i, 1).ToUpper().Trim().Substring(0, j + 1) == sTreeCode + ".")
|
{
|
grdMain.set_RowHidden(i, false);
|
}
|
else
|
{
|
grdMain.set_RowHidden(i, true);
|
}
|
}
|
else
|
{
|
grdMain.set_RowHidden(i, false);
|
}
|
}
|
}
|
else
|
{
|
grdMain.set_RowHidden(i, false);
|
}
|
//txt
|
if (txtFindInfo.Text.Trim() != "")
|
{
|
string txtCode = txtFindInfo.Text.Trim().ToUpper();
|
if (chkMH.Checked == true)
|
{
|
if (Pub_Class.ClsPub.isStrNull(grdMain.get_TextMatrix(i, Col)) != "")
|
{
|
if (grdMain.get_TextMatrix(i, Col).ToUpper().Trim().Contains(txtCode))
|
{
|
grdMain.set_RowHidden(i, false);
|
}
|
else
|
{
|
grdMain.set_RowHidden(i, true);
|
}
|
}
|
}
|
else
|
{
|
if (Pub_Class.ClsPub.isStrNull(grdMain.get_TextMatrix(i, Col)) != "")
|
{
|
if (grdMain.get_TextMatrix(i, Col).ToUpper().Trim() == txtCode)
|
{
|
grdMain.set_RowHidden(i, false);
|
}
|
else
|
{
|
grdMain.set_RowHidden(i, true);
|
}
|
}
|
}
|
}
|
}
|
|
}
|
grdMain.Redraw = VSFlex7.RedrawSettings.flexRDBuffered;
|
}
|
catch (Exception e)
|
{
|
return;
|
}
|
}
|
|
private void txtFindInfo_TextChanged(object sender, EventArgs e)
|
{
|
if(this.Visible==true)
|
QueryItem();
|
}
|
|
private void chkMH_CheckedChanged(object sender, EventArgs e)
|
{
|
QueryItem();
|
}
|
|
private void cx_Click(object sender, EventArgs e)
|
{
|
QueryItem();
|
}
|
|
private void grdMain_RowColChange(object sender, EventArgs e)
|
{
|
if (grdMain.Col >= grdMain.FixedCols)
|
lblFindCol.Text =Pub_Class.ClsPub.isStrNull(grdMain.get_TextMatrix(0, grdMain.Col));
|
else
|
lblFindCol.Text = Pub_Class.ClsPub.isStrNull(grdMain.get_TextMatrix(0, 1));
|
}
|
|
private void grdMain_SelChange(object sender, EventArgs e)
|
{
|
|
}
|
|
}
|
}
|