Пример #1
0
        private void SetDataBind_treeView1()
        {
            treeView1.Nodes.Clear();

            M_WsCodeTMainDB.WsCodeTMainDB wSvc = null;
            string reCode = "";
            string reMsg  = "";

            M_WsCodeTMainDB.DataSysCode[]  getData1 = null;
            M_WsCodeTMainDB.DataCodeT[]    getData2 = null;
            M_WsCodeTMainDB.DataCodeTSub[] getData3 = null;
            try
            {
                wSvc         = new M_WsCodeTMainDB.WsCodeTMainDB();
                wSvc.Url     = "http://" + AppInfo.SsWsvcServer2 + "/WebSvc/Sys/CodeT/WsCodeTMainDB.svc";
                wSvc.Timeout = 1000;

                ImageList myimageList = new ImageList();
                myimageList.Images.Add(Image.FromFile(@"Image\treeicon1.png"));

                treeView1.ImageList  = myimageList;
                treeView1.ImageIndex = 0;

                reCode = wSvc.sSysCode(out getData1, out reMsg);
                if (reCode == "Y")
                {
                    if (getData1 != null && getData1.Length > 0)
                    {
                        for (int j = 0; j < getData1.Length; j++)
                        {
                            string sCode_val   = getData1[j].SCODE.ToString();
                            string sCodeNm_val = getData1[j].SCODE_NM.ToString();

                            TreeNode root = new TreeNode();
                            root.Tag  = "1-" + sCode_val;
                            root.Text = sCodeNm_val;

                            reCode = wSvc.sCodeTTreeView(sCode_val, out getData2, out reMsg);
                            if (reCode == "Y")
                            {
                                if (getData2 != null && getData2.Length > 0)
                                {
                                    for (int k = 0; k < getData2.Length; k++)
                                    {
                                        string   tcode_val   = getData2[k].TCODE.ToString();
                                        string   tcodeNm_val = getData2[k].TCODE_NM.ToString();
                                        TreeNode node2       = new TreeNode();
                                        node2.Tag  = "2-" + tcode_val;
                                        node2.Text = tcodeNm_val;

                                        root.Nodes.Add(node2);

                                        reCode = wSvc.sCodeTSubTreeView(tcode_val, out getData3, out reMsg);
                                        if (reCode == "Y")
                                        {
                                            if (getData3 != null && getData3.Length > 0)
                                            {
                                                for (int i = 0; i < getData3.Length; i++)
                                                {
                                                    string   tscode_val   = getData3[i].TSCODE.ToString();
                                                    string   tscodeNm_val = getData3[i].TSCODE_NM.ToString();
                                                    TreeNode node3        = new TreeNode();
                                                    node3.Tag  = "3-" + tscode_val;
                                                    node3.Text = tscodeNm_val;

                                                    node2.Nodes.Add(node3);
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            treeView1.Nodes.Add(root);

                            if (treeView1.Nodes.Count > 0)
                            {
                                treeView1.SelectedNode = treeView1.GetNodeAt(0, 0);
                            }
                        }

                        treeView1.ExpandAll();
                    }
                }
            }

            catch (Exception ex)
            {
                logs.SaveLog("[error]  (page)::FrmCodeTMainDB.cs  (Function)::SetDataBind_treeView1  (Detail):: " + "\r\n" + ex.ToString(), "Error");
            }
            finally
            {
                if (wSvc != null)
                {
                    wSvc.Dispose();
                }
            }
        }