Exemplo n.º 1
0
        /// <summary>
        /// 增加一个用户分组
        /// </summary>
        /// <param name="model">用户分组实体类</param>
        /// <returns></returns>
        public int CreateUserGroup(Entity.BASE_USERGROUP model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Base_UserGroup(");
            strSql.Append("UG_Name,UG_Order,UG_SuperiorID,UG_Depth,UG_Description)");
            strSql.Append(" values (");
            strSql.Append("@UG_Name,@UG_Order,@UG_SuperiorID,@UG_Depth,@UG_Description)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@UG_Name",        SqlDbType.NVarChar, 30),
                new SqlParameter("@UG_Order",       SqlDbType.Int,       4),
                new SqlParameter("@UG_SuperiorID",  SqlDbType.Int,       4),
                new SqlParameter("@UG_Depth",       SqlDbType.Int,       4),
                new SqlParameter("@UG_Description", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.UG_Name;
            parameters[1].Value = model.UG_Order;
            parameters[2].Value = model.UG_SuperiorID;
            parameters[3].Value = GetUserGroupDepth(model.UG_SuperiorID) + 1;//更新级别深度
            parameters[4].Value = model.UG_Description;

            if (SqlServerHelper.ExecuteSql(strSql.ToString(), parameters) >= 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加数据
        /// </summary>
        protected void btn_add_Click(object sender, EventArgs e)
        {
            if (txt_Name.Text.Trim() != "" || txt_order.Text.Trim() != "" || Smart.Utility.TypeParse.IsUnsign(txt_order.Text.Trim()))
            {
                Entity.BASE_USERGROUP model = new Entity.BASE_USERGROUP();

                model.UG_Name        = txt_Name.Text.Trim();
                model.UG_Description = txt_Description.Text.Trim();
                model.UG_Order       = int.Parse(txt_order.Text.Trim());
                model.UG_SuperiorID  = int.Parse(gtList.SelectedValue);

                switch (bll.CreateUserGroup(model))
                {
                case 0:
                    strinfo.InnerHtml = Smart.Utility.JScript.errinfo("新增操作失败!");
                    strinfo.Visible   = true;
                    break;

                case 1:
                    txt_Name.Text        = "";
                    txt_Description.Text = "";
                    txt_order.Text       = "";
                    BindOrder();
                    break;

                case 2:
                    strinfo.InnerHtml = Smart.Utility.JScript.errinfo("分组已经存在,请更换后重试!");
                    strinfo.Visible   = true;
                    break;
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一个用户分组
 /// </summary>
 /// <param name="model">用户分组实体类</param>
 /// <returns></returns>
 public int CreateUserGroup(Entity.BASE_USERGROUP model)
 {
     if (!UserGroupExists(model.UG_Name))
     {
         return(dal.CreateUserGroup(model));
     }
     else
     {
         return(2);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Entity.BASE_USERGROUP GetEntity(int UG_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select UG_ID, UG_Name, UG_Order, UG_Description, UG_Depth, UG_SuperiorID, UG_Count  ");
            strSql.Append("  from Base_UserGroup ");
            strSql.Append(" where UG_ID=@UG_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UG_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = UG_ID;


            Entity.BASE_USERGROUP entity = new Entity.BASE_USERGROUP();
            DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["UG_ID"].ToString() != "")
                {
                    entity.UG_ID = int.Parse(ds.Tables[0].Rows[0]["UG_ID"].ToString());
                }
                entity.UG_Name = ds.Tables[0].Rows[0]["UG_Name"].ToString();
                if (ds.Tables[0].Rows[0]["UG_Order"].ToString() != "")
                {
                    entity.UG_Order = int.Parse(ds.Tables[0].Rows[0]["UG_Order"].ToString());
                }
                entity.UG_Description = ds.Tables[0].Rows[0]["UG_Description"].ToString();
                if (ds.Tables[0].Rows[0]["UG_Depth"].ToString() != "")
                {
                    entity.UG_Depth = int.Parse(ds.Tables[0].Rows[0]["UG_Depth"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UG_SuperiorID"].ToString() != "")
                {
                    entity.UG_SuperiorID = int.Parse(ds.Tables[0].Rows[0]["UG_SuperiorID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UG_Count"].ToString() != "")
                {
                    entity.UG_Count = int.Parse(ds.Tables[0].Rows[0]["UG_Count"].ToString());
                }

                return(entity);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新数据
        /// </summary>
        protected void GroupsLists_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Entity.BASE_USERGROUP model = new Entity.BASE_USERGROUP();
            model.UG_ID          = int.Parse(GroupsLists.DataKeys[e.RowIndex].Values[0].ToString());
            model.UG_Name        = ((TextBox)GroupsLists.Rows[e.RowIndex].FindControl("txt_name")).Text.Trim();
            model.UG_Description = ((TextBox)GroupsLists.Rows[e.RowIndex].FindControl("txt_Description")).Text.Trim();
            model.UG_Order       = int.Parse(((TextBox)GroupsLists.Rows[e.RowIndex].FindControl("txt_order")).Text);

            if (!bll.UpdateUserGroup(model))
            {
                strinfo.InnerHtml = Smart.Utility.JScript.errinfo("记录更新失败!");
                strinfo.Visible   = true;
            }
            //返回浏览狀態
            GroupsLists.EditIndex = -1;
            BindOrder();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Entity.BASE_USERGROUP entity)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Base_UserGroup set ");

            strSql.Append(" UG_Name = @UG_Name , ");
            strSql.Append(" UG_Order = @UG_Order , ");
            strSql.Append(" UG_Description = @UG_Description , ");
            strSql.Append(" UG_Depth = @UG_Depth , ");
            strSql.Append(" UG_SuperiorID = @UG_SuperiorID , ");
            strSql.Append(" UG_Count = @UG_Count  ");
            strSql.Append(" where UG_ID=@UG_ID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@UG_ID",          SqlDbType.Int,       4),
                new SqlParameter("@UG_Name",        SqlDbType.NVarChar, 30),
                new SqlParameter("@UG_Order",       SqlDbType.Int,       4),
                new SqlParameter("@UG_Description", SqlDbType.NVarChar, 50),
                new SqlParameter("@UG_Depth",       SqlDbType.Int,       4),
                new SqlParameter("@UG_SuperiorID",  SqlDbType.Int,       4),
                new SqlParameter("@UG_Count",       SqlDbType.Int, 4)
            };

            parameters[6].Value  = entity.UG_ID;
            parameters[7].Value  = entity.UG_Name;
            parameters[8].Value  = entity.UG_Order;
            parameters[9].Value  = entity.UG_Description;
            parameters[10].Value = entity.UG_Depth;
            parameters[11].Value = entity.UG_SuperiorID;
            parameters[12].Value = entity.UG_Count;
            int rows = SqlServerHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Entity.BASE_USERGROUP entity)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Base_UserGroup(");
            strSql.Append("UG_Name,UG_Order,UG_Description,UG_Depth,UG_SuperiorID,UG_Count");
            strSql.Append(") values (");
            strSql.Append("@UG_Name,@UG_Order,@UG_Description,@UG_Depth,@UG_SuperiorID,@UG_Count");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UG_Name",        SqlDbType.NVarChar, 30),
                new SqlParameter("@UG_Order",       SqlDbType.Int,       4),
                new SqlParameter("@UG_Description", SqlDbType.NVarChar, 50),
                new SqlParameter("@UG_Depth",       SqlDbType.Int,       4),
                new SqlParameter("@UG_SuperiorID",  SqlDbType.Int,       4),
                new SqlParameter("@UG_Count",       SqlDbType.Int, 4)
            };

            parameters[0].Value = entity.UG_Name;
            parameters[1].Value = entity.UG_Order;
            parameters[2].Value = entity.UG_Description;
            parameters[3].Value = entity.UG_Depth;
            parameters[4].Value = entity.UG_SuperiorID;
            parameters[5].Value = entity.UG_Count;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">用户分组实体类</param>
        /// <returns></returns>
        public bool UpdateUserGroup(Entity.BASE_USERGROUP model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Base_UserGroup set ");
            strSql.Append("UG_Name=@UG_Name,");
            strSql.Append("UG_Order=@UG_Order,");
            strSql.Append("UG_SuperiorID=@UG_SuperiorID,");
            strSql.Append("UG_Depth=@UG_Depth,");
            strSql.Append("UG_Description=@UG_Description");
            strSql.Append(" where UG_ID=@UG_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UG_ID",          SqlDbType.Int,       4),
                new SqlParameter("@UG_Name",        SqlDbType.NVarChar, 30),
                new SqlParameter("@UG_Order",       SqlDbType.Int,       4),
                new SqlParameter("@UG_SuperiorID",  SqlDbType.Int,       4),
                new SqlParameter("@UG_Depth",       SqlDbType.Int,       4),
                new SqlParameter("@UG_Description", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.UG_ID;
            parameters[1].Value = model.UG_Name;
            parameters[2].Value = model.UG_Order;
            parameters[3].Value = model.UG_SuperiorID;
            parameters[4].Value = GetUserGroupDepth(model.UG_SuperiorID) + 1;//更新级别深度
            parameters[5].Value = model.UG_Description;

            if (SqlServerHelper.ExecuteSql(strSql.ToString(), parameters) >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">用户分组实体类</param>
 /// <returns></returns>
 public bool UpdateUserGroup(Entity.BASE_USERGROUP model)
 {
     return(dal.UpdateUserGroup(model));
 }