Esempio n. 1
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;
        }
Esempio n. 2
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();
                }
            }
        }
Esempio n. 3
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();
            }
        }
Esempio n. 4
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][email protected]");
            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;
        }
Esempio n. 5
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"));
            }
        }