YL
2022-02-21 a905b3df0d0c9ae045b51d1299fbb2f2dcbc2e2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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)
        {
 
        }
        
    }
}