/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JSoft.Model.SA.Tree model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SA_Tree(");
            strSql.Append("TreeText,ParentID,ParentPath,Location,OrderID,Comment,Url,PermissionID,ImageUrl,ModuleID,KeShiDM,KeshiPublic,TreeType,Enabled)");
            strSql.Append(" values (");
            strSql.Append("@TreeText,@ParentID,@ParentPath,@Location,@OrderID,@Comment,@Url,@PermissionID,@ImageUrl,@ModuleID,@KeShiDM,@KeshiPublic,@TreeType,@Enabled)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TreeText",     SqlDbType.NVarChar, 100),
                new SqlParameter("@ParentID",     SqlDbType.Int,        4),
                new SqlParameter("@ParentPath",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Location",     SqlDbType.NVarChar,  50),
                new SqlParameter("@OrderID",      SqlDbType.Int,        4),
                new SqlParameter("@Comment",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Url",          SqlDbType.NVarChar, 100),
                new SqlParameter("@PermissionID", SqlDbType.Int,        4),
                new SqlParameter("@ImageUrl",     SqlDbType.NVarChar, 100),
                new SqlParameter("@ModuleID",     SqlDbType.Int,        4),
                new SqlParameter("@KeShiDM",      SqlDbType.Int,        4),
                new SqlParameter("@KeshiPublic",  SqlDbType.NVarChar,  50),
                new SqlParameter("@TreeType",     SqlDbType.SmallInt,   2),
                new SqlParameter("@Enabled",      SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.TreeText;
            parameters[1].Value  = model.ParentID;
            parameters[2].Value  = model.ParentPath;
            parameters[3].Value  = model.Location;
            parameters[4].Value  = model.OrderID;
            parameters[5].Value  = model.Comment;
            parameters[6].Value  = model.Url;
            parameters[7].Value  = model.PermissionID;
            parameters[8].Value  = model.ImageUrl;
            parameters[9].Value  = model.ModuleID;
            parameters[10].Value = model.KeShiDM;
            parameters[11].Value = model.KeshiPublic;
            parameters[12].Value = model.TreeType;
            parameters[13].Value = model.Enabled;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
 private void ShowInfo(int NodeID)
 {
     JSoft.BLL.SA.Tree   bll   = new JSoft.BLL.SA.Tree();
     JSoft.Model.SA.Tree model = bll.GetModel(NodeID);
     this.lblNodeID.Text       = model.NodeID.ToString();
     this.lblTreeText.Text     = model.TreeText;
     this.lblParentID.Text     = model.ParentID.ToString();
     this.lblParentPath.Text   = model.ParentPath;
     this.lblLocation.Text     = model.Location;
     this.lblOrderID.Text      = model.OrderID.ToString();
     this.lblComment.Text      = model.Comment;
     this.lblUrl.Text          = model.Url;
     this.lblPermissionID.Text = model.PermissionID.ToString();
     this.lblImageUrl.Text     = model.ImageUrl;
     this.lblModuleID.Text     = model.ModuleID.ToString();
     this.lblKeShiDM.Text      = model.KeShiDM.ToString();
     this.lblKeshiPublic.Text  = model.KeshiPublic;
     this.lblTreeType.Text     = model.TreeType.ToString();
     this.lblEnabled.Text      = model.Enabled?"是":"否";
 }
Beispiel #3
0
 private void ShowInfo(int NodeID)
 {
     JSoft.BLL.SA.Tree   bll   = new JSoft.BLL.SA.Tree();
     JSoft.Model.SA.Tree model = bll.GetModel(NodeID);
     this.lblNodeID.Text       = model.NodeID.ToString();
     this.txtTreeText.Text     = model.TreeText;
     this.txtParentID.Text     = model.ParentID.ToString();
     this.txtParentPath.Text   = model.ParentPath;
     this.txtLocation.Text     = model.Location;
     this.txtOrderID.Text      = model.OrderID.ToString();
     this.txtComment.Text      = model.Comment;
     this.txtUrl.Text          = model.Url;
     this.txtPermissionID.Text = model.PermissionID.ToString();
     this.txtImageUrl.Text     = model.ImageUrl;
     this.txtModuleID.Text     = model.ModuleID.ToString();
     this.txtKeShiDM.Text      = model.KeShiDM.ToString();
     this.txtKeshiPublic.Text  = model.KeshiPublic;
     this.txtTreeType.Text     = model.TreeType.ToString();
     this.chkEnabled.Checked   = model.Enabled;
 }
        /// <summary>
        /// 得到一个对象实体
        /// 注意:参数要使用防SQL注入过滤
        /// </summary>
        public JSoft.Model.SA.Tree GetModelWhere(string strWhere)
        {
            if (string.IsNullOrEmpty(strWhere))
            {
                return(null);
            }
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 NodeID,TreeText,ParentID,ParentPath,Location,OrderID,Comment,Url,PermissionID,ImageUrl,ModuleID,KeShiDM,KeshiPublic,TreeType,Enabled from SA_Tree ");
            strSql.Append(" where " + strWhere);
            JSoft.Model.SA.Tree model = new JSoft.Model.SA.Tree();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JSoft.Model.SA.Tree GetModel(int NodeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 NodeID,TreeText,ParentID,ParentPath,Location,OrderID,Comment,Url,PermissionID,ImageUrl,ModuleID,KeShiDM,KeshiPublic,TreeType,Enabled from SA_Tree ");
            strSql.Append(" where NodeID=@NodeID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NodeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = NodeID;

            JSoft.Model.SA.Tree model = new JSoft.Model.SA.Tree();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public JSoft.Model.SA.Tree DataRowToModel(DataRow row)
 {
     JSoft.Model.SA.Tree model = new JSoft.Model.SA.Tree();
     if (row != null && row.Table != null)
     {
         if (row.Table.Columns.Contains("NodeID") == true && row["NodeID"] != null && row["NodeID"].ToString() != "")
         {
             model.NodeID = int.Parse(row["NodeID"].ToString());
         }
         if (row.Table.Columns.Contains("TreeText") == true && row["TreeText"] != null)
         {
             model.TreeText = row["TreeText"].ToString();
         }
         if (row.Table.Columns.Contains("ParentID") == true && row["ParentID"] != null && row["ParentID"].ToString() != "")
         {
             model.ParentID = int.Parse(row["ParentID"].ToString());
         }
         if (row.Table.Columns.Contains("ParentPath") == true && row["ParentPath"] != null)
         {
             model.ParentPath = row["ParentPath"].ToString();
         }
         if (row.Table.Columns.Contains("Location") == true && row["Location"] != null)
         {
             model.Location = row["Location"].ToString();
         }
         if (row.Table.Columns.Contains("OrderID") == true && row["OrderID"] != null && row["OrderID"].ToString() != "")
         {
             model.OrderID = int.Parse(row["OrderID"].ToString());
         }
         if (row.Table.Columns.Contains("Comment") == true && row["Comment"] != null)
         {
             model.Comment = row["Comment"].ToString();
         }
         if (row.Table.Columns.Contains("Url") == true && row["Url"] != null)
         {
             model.Url = row["Url"].ToString();
         }
         if (row.Table.Columns.Contains("PermissionID") == true && row["PermissionID"] != null && row["PermissionID"].ToString() != "")
         {
             model.PermissionID = int.Parse(row["PermissionID"].ToString());
         }
         if (row.Table.Columns.Contains("ImageUrl") == true && row["ImageUrl"] != null)
         {
             model.ImageUrl = row["ImageUrl"].ToString();
         }
         if (row.Table.Columns.Contains("ModuleID") == true && row["ModuleID"] != null && row["ModuleID"].ToString() != "")
         {
             model.ModuleID = int.Parse(row["ModuleID"].ToString());
         }
         if (row.Table.Columns.Contains("KeShiDM") == true && row["KeShiDM"] != null && row["KeShiDM"].ToString() != "")
         {
             model.KeShiDM = int.Parse(row["KeShiDM"].ToString());
         }
         if (row.Table.Columns.Contains("KeshiPublic") == true && row["KeshiPublic"] != null)
         {
             model.KeshiPublic = row["KeshiPublic"].ToString();
         }
         if (row.Table.Columns.Contains("TreeType") == true && row["TreeType"] != null && row["TreeType"].ToString() != "")
         {
             model.TreeType = int.Parse(row["TreeType"].ToString());
         }
         if (row.Table.Columns.Contains("Enabled") == true && row["Enabled"] != null && row["Enabled"].ToString() != "")
         {
             if ((row["Enabled"].ToString() == "1") || (row["Enabled"].ToString().ToLower() == "true"))
             {
                 model.Enabled = true;
             }
             else
             {
                 model.Enabled = false;
             }
         }
     }
     return(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JSoft.Model.SA.Tree model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SA_Tree set ");
            strSql.Append("TreeText=@TreeText,");
            strSql.Append("ParentID=@ParentID,");
            strSql.Append("ParentPath=@ParentPath,");
            strSql.Append("Location=@Location,");
            strSql.Append("OrderID=@OrderID,");
            strSql.Append("Comment=@Comment,");
            strSql.Append("Url=@Url,");
            strSql.Append("PermissionID=@PermissionID,");
            strSql.Append("ImageUrl=@ImageUrl,");
            strSql.Append("ModuleID=@ModuleID,");
            strSql.Append("KeShiDM=@KeShiDM,");
            strSql.Append("KeshiPublic=@KeshiPublic,");
            strSql.Append("TreeType=@TreeType,");
            strSql.Append("Enabled=@Enabled");
            strSql.Append(" where NodeID=@NodeID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TreeText",     SqlDbType.NVarChar, 100),
                new SqlParameter("@ParentID",     SqlDbType.Int,        4),
                new SqlParameter("@ParentPath",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Location",     SqlDbType.NVarChar,  50),
                new SqlParameter("@OrderID",      SqlDbType.Int,        4),
                new SqlParameter("@Comment",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Url",          SqlDbType.NVarChar, 100),
                new SqlParameter("@PermissionID", SqlDbType.Int,        4),
                new SqlParameter("@ImageUrl",     SqlDbType.NVarChar, 100),
                new SqlParameter("@ModuleID",     SqlDbType.Int,        4),
                new SqlParameter("@KeShiDM",      SqlDbType.Int,        4),
                new SqlParameter("@KeshiPublic",  SqlDbType.NVarChar,  50),
                new SqlParameter("@TreeType",     SqlDbType.SmallInt,   2),
                new SqlParameter("@Enabled",      SqlDbType.Bit,        1),
                new SqlParameter("@NodeID",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.TreeText;
            parameters[1].Value  = model.ParentID;
            parameters[2].Value  = model.ParentPath;
            parameters[3].Value  = model.Location;
            parameters[4].Value  = model.OrderID;
            parameters[5].Value  = model.Comment;
            parameters[6].Value  = model.Url;
            parameters[7].Value  = model.PermissionID;
            parameters[8].Value  = model.ImageUrl;
            parameters[9].Value  = model.ModuleID;
            parameters[10].Value = model.KeShiDM;
            parameters[11].Value = model.KeshiPublic;
            parameters[12].Value = model.TreeType;
            parameters[13].Value = model.Enabled;
            parameters[14].Value = model.NodeID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtTreeText.Text.Trim().Length == 0)
            {
                strErr += "TreeText不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtParentID.Text))
            {
                strErr += "ParentID格式错误!\\n";
            }
            if (this.txtParentPath.Text.Trim().Length == 0)
            {
                strErr += "ParentPath不能为空!\\n";
            }
            if (this.txtLocation.Text.Trim().Length == 0)
            {
                strErr += "Location不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtOrderID.Text))
            {
                strErr += "OrderID格式错误!\\n";
            }
            if (this.txtComment.Text.Trim().Length == 0)
            {
                strErr += "Comment不能为空!\\n";
            }
            if (this.txtUrl.Text.Trim().Length == 0)
            {
                strErr += "Url不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtPermissionID.Text))
            {
                strErr += "PermissionID格式错误!\\n";
            }
            if (this.txtImageUrl.Text.Trim().Length == 0)
            {
                strErr += "ImageUrl不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtModuleID.Text))
            {
                strErr += "ModuleID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtKeShiDM.Text))
            {
                strErr += "KeShiDM格式错误!\\n";
            }
            if (this.txtKeshiPublic.Text.Trim().Length == 0)
            {
                strErr += "KeshiPublic不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtTreeType.Text))
            {
                strErr += "TreeType格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.ShowFailTip(this, strErr);
                return;
            }
            string TreeText     = this.txtTreeText.Text;
            int    ParentID     = int.Parse(this.txtParentID.Text);
            string ParentPath   = this.txtParentPath.Text;
            string Location     = this.txtLocation.Text;
            int    OrderID      = int.Parse(this.txtOrderID.Text);
            string Comment      = this.txtComment.Text;
            string Url          = this.txtUrl.Text;
            int    PermissionID = int.Parse(this.txtPermissionID.Text);
            string ImageUrl     = this.txtImageUrl.Text;
            int    ModuleID     = int.Parse(this.txtModuleID.Text);
            int    KeShiDM      = int.Parse(this.txtKeShiDM.Text);
            string KeshiPublic  = this.txtKeshiPublic.Text;
            int    TreeType     = int.Parse(this.txtTreeType.Text);
            bool   Enabled      = this.chkEnabled.Checked;

            JSoft.Model.SA.Tree model = new JSoft.Model.SA.Tree();
            model.TreeText     = TreeText;
            model.ParentID     = ParentID;
            model.ParentPath   = ParentPath;
            model.Location     = Location;
            model.OrderID      = OrderID;
            model.Comment      = Comment;
            model.Url          = Url;
            model.PermissionID = PermissionID;
            model.ImageUrl     = ImageUrl;
            model.ModuleID     = ModuleID;
            model.KeShiDM      = KeShiDM;
            model.KeshiPublic  = KeshiPublic;
            model.TreeType     = TreeType;
            model.Enabled      = Enabled;

            JSoft.BLL.SA.Tree bll = new JSoft.BLL.SA.Tree();
            bll.Add(model);
            JSoft.Common.MessageBox.ShowSuccessTip(this, "保存成功!", "add.aspx");
            /*增加日志*/ LogHelp.AddUserLog(CurrentUser.UserName, CurrentUser.UserType, string.Format("Add:【{0}】", new JavaScriptSerializer().Serialize(model)), this);
        }