private void GenerateTree()
        {
            //bind data from data table
            //string path = System.AppDomain.CurrentDomain.BaseDirectory;
            //string connStr = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}db\\NorthWind.mdb", path );

            DataSet ds = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, "select * from [Products]");

            ASTreeViewDataTableColumnDescriptor descripter = new ASTreeViewDataTableColumnDescriptor("ProductName"
                                                                                                     , "ProductID"
                                                                                                     , "ParentID");

            this.astvMyTree.DataSourceDescriptor = descripter;
            this.astvMyTree.DataSource           = ds.Tables[0];
            this.astvMyTree.DataBind();


            StringBuilder sb = new StringBuilder();

            foreach (ASTreeViewNode node in this.astvMyTree.RootNode.ChildNodes[0].ChildNodes)
            {
                ASTreeViewNode nextNode     = GetNextNode(node);
                ASTreeViewNode previousNode = GetPreviousNode(node);
                sb.Append(">>[cur Node]:" + node.NodeText
                          + "[previous]" + (previousNode == null ? "%NULL%" : previousNode.NodeText)
                          + "[next]:" + (nextNode == null ? "%NULL%" : nextNode.NodeText) + "<br />");
            }

            //this.divConsole.InnerHtml = sb.ToString();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Run the procedure(Inherited from Base) with required Parameters And Specific Connection String.
        /// </summary>
        /// <param name="connectionstring">Connection string for the Database</param>
        /// <param name="parameters">Parameters that required by the procedure.</param>
        /// <returns> return type is System.Data.DataSet</returns>
        public DataSet Run(string connectionstring, IList <CustomParameter> parameters)
        {
            DataSet ds;

            ds = OleDbHelper.ExecuteDataset(connectionstring, StoredProcedureName, parameters);
            return(ds);
        }
Ejemplo n.º 3
0
        public DataSet Run(string connectionstring, string textOleDb)
        {
            DataSet ds;

            ds = OleDbHelper.ExecuteDataset(connectionstring, CommandType.Text, textOleDb);
            return(ds);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Run the procedure(Inherited from Base) with specified connection string for getting Dataset.
        /// </summary>
        /// <param name="connectionstring">Connection string for the Database.</param>
        /// <returns>return System.Data.DataSet</returns>
        public DataSet Run(string connectionstring)
        {
            DataSet ds;

            ds = OleDbHelper.ExecuteDataset(connectionstring, CommandType.StoredProcedure, StoredProcedureName);
            return(ds);
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String foo = Session["UserName"].ToString();

            lbUsername.Text = Session["UserName"].ToString();

            if (Session["UserName"] == null)
            {
                Response.Redirect("Default.aspx");
            }
            if (Request.QueryString["ID"] != null)
            {
                lblRoot.Text = Request.QueryString["ID"];
            }
            if (!IsPostBack)
            {
                Page.Header.DataBind();
                ddlRoot1.DataSource = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, string.Format("Select ua.productID,pt.ProductName from UserAccess ua inner join ProductsTree pt on pt.ProductID=ua.ProductID where pt.parentID=0 and ua.username='******'", Session["UserName"]));
                ddlRoot1.DataBind();
                ddlRoot2.DataSource = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, string.Format("Select ua.productID,pt.ProductName from UserAccess ua inner join ProductsTree pt on pt.ProductID=ua.ProductID where pt.parentID=0 and ua.username='******'", Session["UserName"]));
                ddlRoot2.DataBind();
                BindData();
                this.astvMyTree1.ClearNodesSelection();
                this.astvMyTree2.ClearNodesSelection();
            }
        }
Ejemplo n.º 6
0
        private void GenerateTree()
        {
            //bind data from data table
            //string path = System.AppDomain.CurrentDomain.BaseDirectory;
            //string connStr = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}db\\NorthWind.mdb", path );

            DataSet ds = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, "select * from [Products]");

            ASTreeViewDataTableColumnDescriptor descripter = new ASTreeViewDataTableColumnDescriptor("ProductName"
                                                                                                     , "ProductID"
                                                                                                     , "ParentID");

            this.astvMyTree.DataSourceDescriptor = descripter;
            this.astvMyTree.DataSource           = ds.Tables[0];
            this.astvMyTree.DataBind();

            if (this.astvMyTree.RootNode.ChildNodes.Count > 0)
            {
                this.astvMyTree.RootNode.ChildNodes[0].EnableDeleteContextMenu = false;

                foreach (ASTreeViewNode node in this.astvMyTree.RootNode.ChildNodes[0].ChildNodes)
                {
                    node.EnableDeleteContextMenu = false;
                }
            }
        }
Ejemplo n.º 7
0
    protected DataTable GetPageNavigationOrder(string pagename)
    {
        object[] Parameters = new object[1];
        Parameters[0] = pagename;

        DataSet DS;

        DS = OleDbHelper.ExecuteDataset(constring, "p_GetBOAPageNavigationOrder", Parameters);

        return(DS.Tables[0]);
    }
Ejemplo n.º 8
0
        private void GenerateTree2()
        {
            DataSet ds = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, "select * from [Products2]");

            ASTreeViewDataTableColumnDescriptor descripter = new ASTreeViewDataTableColumnDescriptor("ProductName"
                                                                                                     , "ProductID"
                                                                                                     , "ParentID");

            this.astvMyTree2.DataSourceDescriptor = descripter;
            this.astvMyTree2.DataSource           = ds.Tables[0];
            this.astvMyTree2.DataBind();
        }
Ejemplo n.º 9
0
    protected DataSet GetNavigationLinks(int level, string ParentOrder)
    {
        object[] Parameters = new object[2];
        Parameters[0] = level;
        Parameters[1] = ParentOrder;

        DataSet DS;

        DS = OleDbHelper.ExecuteDataset(constring, "p_SelectBOANavigationOrder", Parameters);

        return(DS);
    }
Ejemplo n.º 10
0
        private bool IsDeleteValid()
        {
            string  sql = string.Format("Select * FROM [Products] WHERE [ProductID] in ( {0} )", this.DeleteNodeValues);
            DataSet ds  = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString
                                                     , CommandType.Text
                                                     , sql);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (dr["ProductName"].ToString().ToLower().IndexOf("a") >= 0)
                {
                    return(false);
                }
            }

            return(true);
        }
        private void GenerateTree()
        {
            //bind data from data table
            //string path = System.AppDomain.CurrentDomain.BaseDirectory;
            //string connStr = string.Format( "Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}db\\NorthWind.mdb", path );

            DataSet ds = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, "select * from [Products]");

            ASTreeViewDataTableColumnDescriptor descripter = new ASTreeViewDataTableColumnDescriptor("ProductName"
                                                                                                     , "ProductID"
                                                                                                     , "ParentID");

            this.astvMyTree.DataSourceDescriptor = descripter;
            this.astvMyTree.DataSource           = ds.Tables[0];
            this.astvMyTree.DataBind();

            SaveOriginalTreeNodes();
        }
Ejemplo n.º 12
0
        public static DataTable ExecuteQuery(string Query)
        {
            dt = new DataTable();
            switch (strProvider.ToUpper())
            {
            case "SQLSERVER":
                dt = SqlHelper.ExecuteDataset(strConn, CommandType.Text, Query).Tables[0];

                break;

            case "ORACLE":
                dt = OleDbHelper.ExecuteDataset(strConn, CommandType.Text, Query).Tables[0];
                break;

            default:
                dt = OleDbHelper.ExecuteDataset(strConn, CommandType.Text, Query).Tables[0];
                break;
            }
            return(dt);
        }
        private void GenerateTree2()
        {
            string para = "= 1";

            string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p3.childNodesCount as ChildNodesCount, p1.[ParentID] as ParentID
FROM [Products] p1
INNER JOIN 
(
	SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId 
	FROM [Products] p2
	GROUP BY p2.[ParentID]
) p3
ON p1.[ProductID] = p3.pId
WHERE p1.[ParentID] " + para;

            DataTable dt = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, sql).Tables[0];

            ASTreeViewNode root = this.astvMyTree2.RootNode;

            foreach (DataRow dr in dt.Rows)
            {
                string productName     = dr["ProductName"].ToString();
                string productId       = dr["ProductID"].ToString();
                string parentId        = dr["ParentID"].ToString();
                int    childNodesCount = int.Parse(dr["ChildNodesCount"].ToString());

                ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
                node.VirtualNodesCount = childNodesCount;
                node.VirtualParentKey  = productId;
                node.IsVirtualNode     = childNodesCount > 0;
                node.NavigateUrl       = "#";
                //List<KeyValuePair<string, string>> attrs = new List<KeyValuePair<string, string>>();
                node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));
                //node.AdditionalAttributes = attrs;

                root.AppendChild(node);
            }
        }
Ejemplo n.º 14
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "在线用户:";
            toolStripStatusLabel2.Text = User;
            toolStripStatusLabel3.Text = "          登录时间:";
            toolStripStatusLabel4.Text = Logintime;
            toolStripStatusLabel5.Text = "          系统权限:";
            toolStripStatusLabel6.Text = Limit;
            toolStripStatusLabel7.Text = "                                  深圳市查知科技有限公司";

            Object[]        mf4     = new Object[] { };
            string          sql     = "select * from tb_User where UserName='******'";
            OleDbConnection oldbcon = OleDbHelper.GetOleDbConnection();

            oldbcon.Open();
            DataSet tableset = OleDbHelper.ExecuteDataset(sql, mf4);
            string  lim      = tableset.Tables[0].Rows[0][3].ToString();

            oldbcon.Close();

            if (lim == "超级管理员")
            {
                //试用版本功能未开放
                当前数据查询ToolStripMenuItem.Enabled    = false;
                工程管理ToolStripMenuItem.Enabled      = false;
                GPRS告警ToolStripMenuItem2.Enabled   = false;
                主机信息ToolStripMenuItem.Enabled      = false;
                license管理ToolStripMenuItem.Enabled = false;
                系统升级ToolStripMenuItem.Enabled      = false;
                系统管理ToolStripMenuItem1.Enabled     = false;
                参数管理ToolStripMenuItem.Enabled      = false;
            }
            else
            {
                if (lim == "一般用户")
                {
                    修改用户名ToolStripMenuItem.Enabled    = false;
                    参数管理ToolStripMenuItem.Enabled     = false;
                    历史数据查询ToolStripMenuItem.Enabled   = false;
                    系统操作记录查询ToolStripMenuItem.Enabled = false;
                    系统管理ToolStripMenuItem1.Enabled    = false;

                    //试用版本功能未开放
                    当前数据查询ToolStripMenuItem.Enabled    = false;
                    工程管理ToolStripMenuItem.Enabled      = false;
                    GPRS告警ToolStripMenuItem2.Enabled   = false;
                    主机信息ToolStripMenuItem.Enabled      = false;
                    license管理ToolStripMenuItem.Enabled = false;
                    系统升级ToolStripMenuItem.Enabled      = false;
                }
                else
                {
                    if (lim == "管理员")
                    {
                        修改用户名ToolStripMenuItem.Enabled = false;
                        系统管理ToolStripMenuItem1.Enabled = false;

                        //试用版本功能未开放
                        当前数据查询ToolStripMenuItem.Enabled    = false;
                        工程管理ToolStripMenuItem.Enabled      = false;
                        GPRS告警ToolStripMenuItem2.Enabled   = false;
                        主机信息ToolStripMenuItem.Enabled      = false;
                        license管理ToolStripMenuItem.Enabled = false;
                        系统升级ToolStripMenuItem.Enabled      = false;
                        参数管理ToolStripMenuItem.Enabled      = false;
                    }
                }
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (Request.QueryString["t1"] == "ajaxLoad")
            {
                string virtualParentKey = Request.QueryString["virtualParentKey"];

                string para = string.Empty;                // "= 1";
                if (virtualParentKey == null)
                {
                    para = " is NULL";
                }
                else
                {
                    para = "=" + virtualParentKey;
                }

                string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p1.[ParentID] as ParentID, p3.childNodesCount as ChildNodesCount
FROM [Products] p1
LEFT OUTER JOIN 
(
	SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId 
	FROM [Products] p2
	GROUP BY p2.[ParentID]
) p3
ON p1.[ProductID] = p3.pId
WHERE p1.[ParentID] " + para;

                DataTable dt = OleDbHelper.ExecuteDataset(base.NorthWindConnectionString, CommandType.Text, sql).Tables[0];

                ASTreeViewNode root = new ASTreeViewNode("root");

                foreach (DataRow dr in dt.Rows)
                {
                    string productName     = dr["ProductName"].ToString();
                    string productId       = dr["ProductID"].ToString();
                    string parentId        = dr["ParentID"].ToString();
                    int    childNodesCount = 0;
                    if (!string.IsNullOrEmpty(dr["ChildNodesCount"].ToString()))
                    {
                        childNodesCount = int.Parse(dr["ChildNodesCount"].ToString());
                    }

                    ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
                    node.VirtualNodesCount = childNodesCount;
                    node.VirtualParentKey  = productId;
                    node.IsVirtualNode     = childNodesCount > 0;
                    node.NavigateUrl       = "#";
                    node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                    root.AppendChild(node);
                }



                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree2.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }
            }
            else if (Request.QueryString["t2"] == "ajaxAdd")
            {
                string addNodeText     = Request.QueryString["addNodeText"];
                int    parentNodeValue = int.Parse(Request.QueryString["parentNodeValue"]);

                string maxSql = "select max( productId ) from products";
                int    max    = (int)OleDbHelper.ExecuteScalar(base.NorthWindConnectionString, CommandType.Text, maxSql);
                int    newId  = max + 1;

                string sql = string.Format(@"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
                                           , max + 1, addNodeText.Replace("'", "''"), parentNodeValue);

                int i = OleDbHelper.ExecuteNonQuery(base.NorthWindConnectionString, CommandType.Text, sql);

                ASTreeViewNode root = new ASTreeViewNode("root");

                ASTreeViewLinkNode node = new ASTreeViewLinkNode(addNodeText, newId.ToString());
                node.NavigateUrl = "#";
                node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                root.AppendChild(node);

                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree2.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }
            }
            else
            {
                base.Render(writer);
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (this.Page.Request.QueryString["t1"] == "ajaxLoad")
            {
                #region ajaxLoad

                string virtualParentKey = this.Page.Request.QueryString["virtualParentKey"];

                string para = string.Empty;                // "= 1";
                if (virtualParentKey == null)
                {
                    para = " is NULL";
                }
                else
                {
                    para = "=" + virtualParentKey;
                }

                string sql = @"SELECT p1.[ProductID] as ProductID, p1.[ProductName] as ProductName, p1.[ParentID] as ParentID, p3.childNodesCount as ChildNodesCount
FROM [Products] p1
LEFT OUTER JOIN 
(
	SELECT COUNT(*) AS childNodesCount , p2.[ParentID] AS pId 
	FROM [Products] p2
	GROUP BY p2.[ParentID]
) p3
ON p1.[ProductID] = p3.pId
WHERE p1.[ParentID] " + para;

                DataTable dt = OleDbHelper.ExecuteDataset(this.NorthWindConnectionString, CommandType.Text, sql).Tables[0];

                ASTreeViewNode root = new ASTreeViewNode("root");

                foreach (DataRow dr in dt.Rows)
                {
                    string productName     = dr["ProductName"].ToString();
                    string productId       = dr["ProductID"].ToString();
                    string parentId        = dr["ParentID"].ToString();
                    int    childNodesCount = 0;
                    if (!string.IsNullOrEmpty(dr["ChildNodesCount"].ToString()))
                    {
                        childNodesCount = int.Parse(dr["ChildNodesCount"].ToString());
                    }

                    ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
                    node.VirtualNodesCount = childNodesCount;
                    node.VirtualParentKey  = productId;
                    node.IsVirtualNode     = childNodesCount > 0;
                    node.NavigateUrl       = "#";
                    node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                    root.AppendChild(node);
                }


                writer.Write(astvMyTree.AjaxResponseStartTag);

                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }


                writer.Write(astvMyTree.AjaxResponseEndTag);

                #endregion
            }
            else if (this.Page.Request.QueryString["t2"] == "ajaxAdd")
            {
                #region ajaxAdd

                string addNodeText     = this.Page.Request.QueryString["addNodeText"];
                int    parentNodeValue = int.Parse(this.Page.Request.QueryString["parentNodeValue"]);

                string maxSql = "select max( productId ) from products";
                int    max    = (int)OleDbHelper.ExecuteScalar(this.NorthWindConnectionString, CommandType.Text, maxSql);
                int    newId  = max + 1;

                string sql = string.Format(@"INSERT INTO products( productid, Discontinued, productname, parentid ) values( {0} ,0, '{1}', {2})"
                                           , max + 1, addNodeText.Replace("'", "''"), parentNodeValue);

                int i = OleDbHelper.ExecuteNonQuery(this.NorthWindConnectionString, CommandType.Text, sql);

                ASTreeViewNode root = new ASTreeViewNode("root");

                ASTreeViewLinkNode node = new ASTreeViewLinkNode(addNodeText, newId.ToString());
                node.NavigateUrl = "#";
                node.AdditionalAttributes.Add(new KeyValuePair <string, string>("onclick", "return false;"));

                root.AppendChild(node);


                writer.Write(astvMyTree.AjaxResponseStartTag);

                HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
                astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
                foreach (Control c in ulRoot.Controls)
                {
                    c.RenderControl(writer);
                }

                writer.Write(astvMyTree.AjaxResponseEndTag);

                #endregion
            }
            else
            {
                base.Render(writer);

                #region render click script

                string clickScript = string.Format(@"
<script type='text/javascript'>
function nodeSelectHandler{0}(elem){{
	document.getElementById('{1}').value = encodeURIComponent(elem.innerHTML);
	document.getElementById('{2}').value = elem.parentNode.getAttribute(""treeNodeValue"");
	document.getElementById('{3}').click();
}}
</script>"
                                                   , this.ClientID                     /*0*/
                                                   , this.hfSelectedNodeText.ClientID  /*1*/
                                                   , this.hfSelectedNodeValue.ClientID /*2*/
                                                   , this.btnPostBackTrigger.ClientID /*3*/);

                writer.Write(clickScript);

                #endregion
            }
        }