• 大小: 45KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: C#
  • 标签:

资源简介

Treeview在winform中的运用(从数据库动态添加节点,增加节点、删除节点、复制节点)

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace Treeview
{
    public class Add_Nodes
    {
        public void add(string FromNodestring ToName)
        {
            try
            {
                SqlConnection conn = new SqlConnection(“server=INSIGMA112\\SQLEXPRESS;uid=smxzk32145745;pwd=smxzk471848347;database=train“);
                conn.Open();
                SqlCommand cmm = new SqlCommand(“add_Nodes“ conn);
                cmm.CommandType = CommandType.StoredProcedure;
                SqlParameter str1 = new SqlParameter(“@name“ SqlDbType.VarChar 4);
                SqlParameter str2 = new SqlParameter(“@Tonode“ SqlDbType.Int);
                str1.Value = FromNode.ToString();
                str2.Value = int.Parse(ID(ToName).ToString());
                cmm.Parameters.Add(str1);
                cmm.Parameters.Add(str2);
                cmm.ExecuteNonQuery();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
         }                   
        public static string ID(string ToName)
        {           
                SqlConnection conn = new SqlConnection(“server=INSIGMA112\\SQLEXPRESS;uid=smxzk32145745;pwd=smxzk471848347;database=train“);
                conn.Open();
                SqlCommand cmd = new SqlCommand(“select ID from Nodes where NodeName=‘“ + ToName + “‘“ conn);
                SqlDataReader read = cmd.ExecuteReader();
                if (read.Read())
                {
                    return read[“ID“].ToString();
                }
                else
                {
                    return “0“;
                }
         }      
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1854  2009-08-05 18:47  Treeview\Treeview\Add_Nodes.cs

     文件      28672  2009-08-05 20:22  Treeview\Treeview\bin\Debug\Treeview.exe

     文件      40448  2009-08-05 20:22  Treeview\Treeview\bin\Debug\Treeview.pdb

     文件       5632  2005-12-08 14:51  Treeview\Treeview\bin\Debug\Treeview.vshost.exe

     目录          0  2009-08-06 09:05  Treeview\Treeview\bin\Debug

     目录          0  2009-08-06 09:05  Treeview\Treeview\bin

     文件       1224  2009-08-05 18:38  Treeview\Treeview\CopyNode.cs

     文件       2125  2009-08-05 19:58  Treeview\Treeview\Display.cs

     文件       1026  2009-08-05 18:47  Treeview\Treeview\DropNodes.cs

     文件       1766  2009-08-05 20:22  Treeview\Treeview\Form1.cs

     文件      15431  2009-08-05 20:22  Treeview\Treeview\Form1.Designer.cs

     文件       6019  2009-08-05 20:22  Treeview\Treeview\Form1.resx

     目录          0  2009-08-06 09:05  Treeview\Treeview\obj\Debug\Refactor

     目录          0  2009-08-06 09:05  Treeview\Treeview\obj\Debug\TempPE

     文件        842  2009-08-05 20:22  Treeview\Treeview\obj\Debug\Treeview.csproj.GenerateResource.Cache

     文件      28672  2009-08-05 20:22  Treeview\Treeview\obj\Debug\Treeview.exe

     文件        180  2009-08-05 20:22  Treeview\Treeview\obj\Debug\Treeview.Form1.resources

     文件      40448  2009-08-05 20:22  Treeview\Treeview\obj\Debug\Treeview.pdb

     文件        180  2009-08-05 16:47  Treeview\Treeview\obj\Debug\Treeview.Properties.Resources.resources

     目录          0  2009-08-06 09:05  Treeview\Treeview\obj\Debug

     文件        275  2009-08-06 09:07  Treeview\Treeview\obj\Treeview.csproj.FileList.txt

     目录          0  2009-08-06 09:05  Treeview\Treeview\obj

     文件        467  2009-08-05 13:50  Treeview\Treeview\Program.cs

     文件       1164  2009-08-05 13:50  Treeview\Treeview\Properties\AssemblyInfo.cs

     文件       2871  2009-08-05 13:50  Treeview\Treeview\Properties\Resources.Designer.cs

     文件       5612  2009-08-05 13:50  Treeview\Treeview\Properties\Resources.resx

     文件       1092  2009-08-05 13:50  Treeview\Treeview\Properties\Settings.Designer.cs

     文件        249  2009-08-05 13:50  Treeview\Treeview\Properties\Settings.settings

     目录          0  2009-08-06 09:05  Treeview\Treeview\Properties

     文件       3380  2009-08-05 19:23  Treeview\Treeview\Treeview.csproj

............此处省略7个文件信息

评论

共有 条评论

相关资源