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 frmHlpInfo_View : Form
|
{
|
public frmHlpInfo_View()
|
{
|
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 frmHlpInfo_View_Load(object sender, EventArgs e)
|
{
|
initGrid();
|
LoadTree();
|
}
|
//初始化GRID
|
private void initGrid()
|
{
|
grdShow.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //选中模式--行选中
|
grdShow.ColumnHeadersVisible = true; //标题列显示--是
|
grdShow.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //标题列尺寸模式--(自动调整,可调整)
|
grdShow.RowTemplate.Height = 18;
|
grdShow.RowTemplate.MinimumHeight = 18;
|
grdShow.ColumnHeadersHeight = 35; //标题行高
|
grdShow.RowHeadersVisible = false; //标题行可见--否
|
grdShow.AllowUserToAddRows = false; //是否允许自增--否
|
grdShow.AllowUserToDeleteRows = false; //是否允许删除--否
|
//grdShow.ColumnCount = 0; //总列数--5
|
//grdShow.RowCount = 0;
|
grdShow.AllowUserToResizeColumns = true; //允许调整列宽--是
|
grdShow.AllowUserToResizeRows = false; //允许调整行高--否
|
grdShow.ReadOnly = true; //只读--是
|
grdShow.BackgroundColor = Color.White;
|
grdShow.GridColor = Color.LightGray;
|
grdShow.DefaultCellStyle.SelectionBackColor = Color.Black;
|
grdShow.EnableHeadersVisualStyles = false; //网格标题 样式
|
grdShow.ColumnHeadersDefaultCellStyle.BackColor = Color.LightGray;
|
grdShow.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;//网格内容 对齐方式
|
Pub_Class.ClsPub.GetGridView(grdShow, this.Name + this.sTitle, Pub_Class.ClsPub.AppPath);
|
}
|
|
//双击 GRID
|
private void grdShow_DblClick(object sender, EventArgs e)
|
{
|
if (grdShow.CurrentCell == null)
|
{
|
return;
|
}
|
//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 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 void frmHlpInfo_View_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
//Pub_Class.ClsPub.SaveGridView(grdShow, sTitle, Pub_Class.ClsPub.AppPath);
|
}
|
|
public Int32 Fun_GetCol(string sCol, DataGridView grdMain)
|
{
|
for (int c = 0; c < grdMain.ColumnCount; c++)
|
{
|
if (Pub_Class.ClsPub.isStrNull(grdMain.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper())
|
{
|
return c;
|
}
|
}
|
return 0;
|
}
|
|
//过滤项目
|
private void QueryItem()
|
{
|
|
|
string sTreeCode;
|
//得到树型 代码
|
try
|
{
|
CurrencyManager cm = (CurrencyManager)BindingContext[grdShow.DataSource];
|
cm.SuspendBinding();
|
//
|
int Col;
|
if (lblFindCol.Text.Trim()!="")
|
Col = Fun_GetCol(lblFindCol.Text.Trim(),grdShow);
|
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;
|
//显示全部
|
for (int i = 0; i < grdShow.Rows.Count; i++)
|
{
|
grdShow.Rows[i].Visible = true;
|
if (grdShow.Rows[i].Cells[Col].Value.ToString().Length < j) //如果长度比 匹配项 小 就先隐藏
|
{
|
grdShow.Rows[i].Visible = false;
|
}
|
else
|
{
|
if (sTreeCode != "")
|
{
|
if (Pub_Class.ClsPub.isStrNull(grdShow.Rows[i].Cells[1].Value.ToString()) != "")
|
{
|
if (grdShow.Rows[i].Cells[1].Value.ToString().ToUpper().Trim() != sTreeCode.ToUpper().Trim())
|
{
|
if (grdShow.Rows[i].Cells[1].Value.ToString().ToUpper().Trim().Contains(sTreeCode+"."))
|
{
|
grdShow.Rows[i].Visible = true;
|
}
|
else
|
{
|
grdShow.Rows[i].Visible = false;
|
}
|
}
|
else
|
{
|
grdShow.Rows[i].Visible = true;
|
}
|
}
|
}
|
else
|
{
|
grdShow.Rows[i].Visible = true;
|
}
|
//txt
|
if (txtFindInfo.Text.Trim() != "")
|
{
|
string txtCode = txtFindInfo.Text.Trim().ToUpper();
|
|
if (Pub_Class.ClsPub.isStrNull(grdShow.Rows[i].Cells[Col].Value.ToString()) != "")
|
{
|
if (grdShow.Rows[i].Cells[Col].Value.ToString().ToUpper().Trim().Contains(txtCode))
|
{
|
grdShow.Rows[i].Visible = true;
|
}
|
else
|
{
|
grdShow.Rows[i].Visible = false;
|
}
|
}
|
else
|
{
|
grdShow.Rows[i].Visible = false;
|
}
|
}
|
//else
|
//{
|
// grdShow.Rows[i].Visible = true;
|
//}
|
}
|
|
}
|
cm.ResumeBinding();
|
Pub_Class.ClsPub.GetGridView(grdShow, this.Name + this.sTitle, Pub_Class.ClsPub.AppPath);
|
}
|
catch (Exception e)
|
{
|
return;
|
}
|
}
|
|
|
private void txtFindInfo_TextChanged(object sender, EventArgs e)
|
{
|
QueryItem();
|
}
|
|
private void chkMH_CheckedChanged(object sender, EventArgs e)
|
{
|
QueryItem();
|
}
|
|
private void cx_Click(object sender, EventArgs e)
|
{
|
QueryItem();
|
}
|
|
private void grdShow_DoubleClick(object sender, EventArgs e)
|
{
|
if (grdShow.CurrentCell == null)
|
{
|
return;
|
}
|
BackData();
|
}
|
|
private void grdShow_Click(object sender, EventArgs e)
|
{
|
if (grdShow.CurrentCell == null)
|
{
|
return;
|
}
|
if (grdShow.CurrentCell!=null)
|
{
|
lblFindCol.Text = grdShow.Columns[grdShow.CurrentCell.ColumnIndex].HeaderText;
|
}
|
else
|
{
|
lblFindCol.Text = grdShow.Columns[1].HeaderText;
|
}
|
}
|
|
|
|
private void txtFindInfo_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode ==Keys.Enter)
|
{
|
QueryItem();
|
}
|
}
|
|
private void yc_Click(object sender, EventArgs e)
|
{
|
Gy_GridView_Hide oHide = new Gy_GridView_Hide();
|
oHide.KeyItem = this.Name + sBill;
|
oHide.oGrd = grdShow;
|
oHide.ShowDialog();
|
//
|
Pub_Class.ClsPub.HideGridView(grdShow, Name + sBill, Pub_Class.ClsPub.AppPath);//设置隐藏列
|
}
|
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
Pub_Class.ClsPub.SaveGridView(grdShow, this.Name + this.sTitle, Pub_Class.ClsPub.AppPath);
|
}
|
|
|
|
}
|
}
|