示例#1
0
        /// <summary>
        /// Method to get one record by primary key
        /// </summary>
        public Johnny.CMS.OM.Access.AdminRole GetModel(int adminroleid)
        {
            //Set up a return value
            Johnny.CMS.OM.Access.AdminRole model = null;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT [AdminRoleId], [AdminId], [RoleId], [Sequence] ");
            strSql.Append(" FROM [cms_adminrole] ");
            strSql.Append(" WHERE [AdminRoleId]=@adminroleid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminroleid", SqlDbType.Int, 4)
            };
            parameters[0].Value = adminroleid;
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sdr.Read())
                {
                    model = new Johnny.CMS.OM.Access.AdminRole(sdr.GetInt32(0), sdr.GetInt32(1), sdr.GetInt32(2), sdr.GetInt32(3));
                }
                else
                {
                    model = new Johnny.CMS.OM.Access.AdminRole();
                }
            }
            return(model);
        }
示例#2
0
        /// <summary>
        /// Add one record
        /// </summary>
        public int Add(Johnny.CMS.OM.Access.AdminRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("DECLARE @Sequence int");
            strSql.Append(" SELECT @Sequence=(max(Sequence)+1) FROM [cms_adminrole]");
            strSql.Append(" if @Sequence is NULL");
            strSql.Append(" Set @Sequence=1");
            strSql.Append("INSERT INTO [cms_adminrole](");
            strSql.Append("[AdminId],[RoleId],[Sequence]");
            strSql.Append(")");
            strSql.Append(" VALUES (");
            strSql.Append("@adminid,@roleid,@Sequence");
            strSql.Append(")");
            strSql.Append(";SELECT @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminid", SqlDbType.Int, 4),
                new SqlParameter("@roleid",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AdminId;
            parameters[1].Value = model.RoleId;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
        /// <summary>
        /// Method to get records with condition
        /// </summary>    	 
        public IList<Johnny.CMS.OM.Access.AdminRole> GetList()
        {
            IList<Johnny.CMS.OM.Access.AdminRole> list = new List<Johnny.CMS.OM.Access.AdminRole>();

            StringBuilder strSql = new StringBuilder();
            //strSql.Append("SELECT [AdminRoleId], [AdminId], [RoleId], [Sequence] ");
            //strSql.Append(" FROM [cms_adminrole] ");
            //strSql.Append(" ORDER BY [Sequence]");
            strSql.Append("SELECT mtb.[AdminRoleId],mtb.[AdminId],admins.[AdminName],mtb.[RoleId],roles.[RoleName],mtb.[Sequence]");
            strSql.Append(" FROM [cms_adminrole] mtb");
            strSql.Append(" LEFT OUTER JOIN [cms_administrator] admins");
            strSql.Append(" ON mtb.[AdminId] = admins.[AdminId]");
            strSql.Append(" LEFT OUTER JOIN [cms_role] roles");
            strSql.Append(" ON mtb.[RoleId] = roles.[RoleId]");
            strSql.Append(" ORDER BY mtb.[Sequence]");

            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                while (sdr.Read())
                {
                    Johnny.CMS.OM.Access.AdminRole item = new Johnny.CMS.OM.Access.AdminRole(sdr.GetInt32(0), sdr.GetInt32(1), sdr.GetString(2), sdr.GetInt32(3), sdr.GetString(4), sdr.GetInt32(5));
                    list.Add(item);
                }
            }
            return list;
        }
示例#4
0
        /// <summary>
        /// Method to get records with condition
        /// </summary>
        public IList <Johnny.CMS.OM.Access.AdminRole> GetList()
        {
            IList <Johnny.CMS.OM.Access.AdminRole> list = new List <Johnny.CMS.OM.Access.AdminRole>();

            StringBuilder strSql = new StringBuilder();

            //strSql.Append("SELECT [AdminRoleId], [AdminId], [RoleId], [Sequence] ");
            //strSql.Append(" FROM [cms_adminrole] ");
            //strSql.Append(" ORDER BY [Sequence]");
            strSql.Append("SELECT mtb.[AdminRoleId],mtb.[AdminId],admins.[AdminName],mtb.[RoleId],roles.[RoleName],mtb.[Sequence]");
            strSql.Append(" FROM [cms_adminrole] mtb");
            strSql.Append(" LEFT OUTER JOIN [cms_administrator] admins");
            strSql.Append(" ON mtb.[AdminId] = admins.[AdminId]");
            strSql.Append(" LEFT OUTER JOIN [cms_role] roles");
            strSql.Append(" ON mtb.[RoleId] = roles.[RoleId]");
            strSql.Append(" ORDER BY mtb.[Sequence]");

            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                while (sdr.Read())
                {
                    Johnny.CMS.OM.Access.AdminRole item = new Johnny.CMS.OM.Access.AdminRole(sdr.GetInt32(0), sdr.GetInt32(1), sdr.GetString(2), sdr.GetInt32(3), sdr.GetString(4), sdr.GetInt32(5));
                    list.Add(item);
                }
            }
            return(list);
        }
示例#5
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!this.IsPostBack)
            {
                litPageTitle.Text = GetLabelText("AdminRole_Title");
                litAdministrator.Text = GetLabelText("Adminrole_AdminId");
                ddlAdministrators.ToolTip = GetLabelText("Adminrole_AdminId");
                litRole.Text = GetLabelText("Adminrole_RoleId");
                ddlRoles.ToolTip = GetLabelText("Adminrole_RoleId");

                if (Request.QueryString["action"] == "modify")
                {
                    //get AdminRoleId
                    int AdminRoleId = Convert.ToInt32(Request.QueryString["id"]);

                    //UserRole entity
                    Johnny.CMS.BLL.Access.AdminRole bll = new Johnny.CMS.BLL.Access.AdminRole();
                    Johnny.CMS.OM.Access.AdminRole model = new Johnny.CMS.OM.Access.AdminRole();
                    model = bll.GetModel(AdminRoleId);

                    CreateddlAdministrators();
                    foreach (ListItem item in ddlAdministrators.Items)
                    {
                        if (DataConvert.GetInt32(item.Value) == model.AdminId)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                    CreateddlRole();
                    foreach (ListItem item in ddlRoles.Items)
                    {
                        if (DataConvert.GetInt32(item.Value) == model.RoleId)
                        {
                            item.Selected = true;
                            break;
                        }
                    }

                    btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save;
                    //btnAdd.Text = CONST_BUTTONTEXT_SAVE;
                }
                else
                {
                    CreateddlAdministrators();
                    CreateddlRole();
                }
            }
        }
示例#6
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!this.IsPostBack)
            {
                litPageTitle.Text         = GetLabelText("AdminRole_Title");
                litAdministrator.Text     = GetLabelText("Adminrole_AdminId");
                ddlAdministrators.ToolTip = GetLabelText("Adminrole_AdminId");
                litRole.Text     = GetLabelText("Adminrole_RoleId");
                ddlRoles.ToolTip = GetLabelText("Adminrole_RoleId");

                if (Request.QueryString["action"] == "modify")
                {
                    //get AdminRoleId
                    int AdminRoleId = Convert.ToInt32(Request.QueryString["id"]);

                    //UserRole entity
                    Johnny.CMS.BLL.Access.AdminRole bll   = new Johnny.CMS.BLL.Access.AdminRole();
                    Johnny.CMS.OM.Access.AdminRole  model = new Johnny.CMS.OM.Access.AdminRole();
                    model = bll.GetModel(AdminRoleId);

                    CreateddlAdministrators();
                    foreach (ListItem item in ddlAdministrators.Items)
                    {
                        if (DataConvert.GetInt32(item.Value) == model.AdminId)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                    CreateddlRole();
                    foreach (ListItem item in ddlRoles.Items)
                    {
                        if (DataConvert.GetInt32(item.Value) == model.RoleId)
                        {
                            item.Selected = true;
                            break;
                        }
                    }

                    btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save;
                    //btnAdd.Text = CONST_BUTTONTEXT_SAVE;
                }
                else
                {
                    CreateddlAdministrators();
                    CreateddlRole();
                }
            }
        }
示例#7
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            Johnny.CMS.OM.Access.AdminRole model = new Johnny.CMS.OM.Access.AdminRole();
            base.ManageTable = model.TableName;
            base.ManageKey = model.PrimaryKey;
            base.IsDesc = model.IsDesc;

            if (!IsPostBack)
            {
                myManageGridView.Columns[2].HeaderText = GetLabelText("Adminrole_AdminId");
                myManageGridView.Columns[3].HeaderText = GetLabelText("Adminrole_RoleId");
                getData();
            }
        }
示例#8
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            Johnny.CMS.OM.Access.AdminRole model = new Johnny.CMS.OM.Access.AdminRole();
            base.ManageTable = model.TableName;
            base.ManageKey   = model.PrimaryKey;
            base.IsDesc      = model.IsDesc;

            if (!IsPostBack)
            {
                myManageGridView.Columns[2].HeaderText = GetLabelText("Adminrole_AdminId");
                myManageGridView.Columns[3].HeaderText = GetLabelText("Adminrole_RoleId");
                getData();
            }
        }
示例#9
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (ddlAdministrators.Items.Count < 0 || ddlAdministrators.SelectedIndex < 0)
            {
                SetMessage(GetMessage("E01401"));
                ddlAdministrators.Focus();
                return;
            }
            if (ddlRoles.Items.Count < 0 || ddlRoles.SelectedIndex < 0)
            {
                SetMessage(GetMessage("E01402"));
                ddlRoles.Focus();
                return;
            }


            Johnny.CMS.BLL.Access.AdminRole bll   = new Johnny.CMS.BLL.Access.AdminRole();
            Johnny.CMS.OM.Access.AdminRole  model = new Johnny.CMS.OM.Access.AdminRole();

            if (Request.QueryString["action"] == "modify")
            {
                //update
                model.AdminRoleId = Convert.ToInt32(Request.QueryString["id"]);
                model.AdminId     = DataConvert.GetInt32(ddlAdministrators.SelectedValue);
                model.RoleId      = DataConvert.GetInt32(ddlRoles.SelectedValue);

                bll.Update(model);
                SetMessage(GetMessage("C00003"));
            }
            else
            {
                //insert
                model.AdminId = DataConvert.GetInt32(ddlAdministrators.SelectedValue);
                model.RoleId  = DataConvert.GetInt32(ddlRoles.SelectedValue);

                if (bll.Add(model) > 0)
                {
                    SetMessage(GetMessage("C00001"));
                    ddlAdministrators.SelectedIndex = 0;
                    ddlRoles.SelectedIndex          = 0;
                }
                else
                {
                    SetMessage(GetMessage("C00002"));
                }
            }
        }
示例#10
0
        /// <summary>
        /// Update one record
        /// </summary>
        public void Update(Johnny.CMS.OM.Access.AdminRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE [cms_adminrole] SET ");
            strSql.Append("[AdminId]=@adminid,");
            strSql.Append("[RoleId]=@roleid");
            strSql.Append(" WHERE [AdminRoleId]=@adminroleid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminroleid", SqlDbType.Int, 4),
                new SqlParameter("@adminid",     SqlDbType.Int, 4),
                new SqlParameter("@roleid",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AdminRoleId;
            parameters[1].Value = model.AdminId;
            parameters[2].Value = model.RoleId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#11
0
        /// <summary>
        /// Method to get one record by primary key
        /// </summary>    	 
        public Johnny.CMS.OM.Access.AdminRole GetModel(int adminroleid)
        {
            //Set up a return value
            Johnny.CMS.OM.Access.AdminRole model = null;

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [AdminRoleId], [AdminId], [RoleId], [Sequence] ");
            strSql.Append(" FROM [cms_adminrole] ");
            strSql.Append(" WHERE [AdminRoleId]=@adminroleid");
            SqlParameter[] parameters = {
					new SqlParameter("@adminroleid", SqlDbType.Int,4)};
            parameters[0].Value = adminroleid;
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sdr.Read())
                    model = new Johnny.CMS.OM.Access.AdminRole(sdr.GetInt32(0), sdr.GetInt32(1), sdr.GetInt32(2), sdr.GetInt32(3));
                else
                    model = new Johnny.CMS.OM.Access.AdminRole();
            }
            return model;
        }
示例#12
0
 /// <summary>
 /// Update one record
 /// </summary>
 public void Update(Johnny.CMS.OM.Access.AdminRole model)
 {
     dal.Update(model);
 }
示例#13
0
 /// <summary>
 /// Add one record
 /// </summary>
 public int Add(Johnny.CMS.OM.Access.AdminRole model)
 {
     return(dal.Add(model));
 }
示例#14
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (ddlAdministrators.Items.Count < 0 || ddlAdministrators.SelectedIndex < 0)
            {
                SetMessage(GetMessage("E01401"));
                ddlAdministrators.Focus();
                return;
            }
            if (ddlRoles.Items.Count < 0 || ddlRoles.SelectedIndex < 0)
            {
                SetMessage(GetMessage("E01402"));
                ddlRoles.Focus();
                return;
            }


            Johnny.CMS.BLL.Access.AdminRole bll = new Johnny.CMS.BLL.Access.AdminRole();
            Johnny.CMS.OM.Access.AdminRole model = new Johnny.CMS.OM.Access.AdminRole();

            if (Request.QueryString["action"] == "modify")
            {
                //update
                model.AdminRoleId = Convert.ToInt32(Request.QueryString["id"]);
                model.AdminId = DataConvert.GetInt32(ddlAdministrators.SelectedValue);
                model.RoleId = DataConvert.GetInt32(ddlRoles.SelectedValue);

                bll.Update(model);
                SetMessage(GetMessage("C00003"));
            }
            else
            {
                //insert
                model.AdminId = DataConvert.GetInt32(ddlAdministrators.SelectedValue);
                model.RoleId = DataConvert.GetInt32(ddlRoles.SelectedValue);

                if (bll.Add(model) > 0)
                {
                    SetMessage(GetMessage("C00001"));
                    ddlAdministrators.SelectedIndex = 0;
                    ddlRoles.SelectedIndex = 0;

                }
                else
                    SetMessage(GetMessage("C00002"));
            }
        }