using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KstCMS.KstCMS_Manager.SystemSet.Users.role
{
    public partial class RoleEdit : KstCmsBase.WebPage.FrmControl
    {
        protected string RoleId = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RoleId = Request.QueryString.Get("RoleId");

                if (!string.IsNullOrEmpty(RoleId))
                {
                    LitTitle.Text = "<img src=\"" + SysRootUrl + "/KstCMS_Manager/images/sms_type13.gif\" align=\"absmiddle\" />   修改角色";
                    ROLE_NAME.Text = Server.UrlDecode(Request.QueryString.Get("RoleName"));

                }
                else
                    LitTitle.Text = "<img src=\"" + SysRootUrl + "/KstCMS_Manager/images/notify_new.gif\" align=\"absmiddle\" />  增加角色";

                String[] ClsTitle = new String[1];
                ClsTitle[0] = "角色名称~!";
                base.Set_Control(ClsTitle, ROLE_NAME);

            }
            Button1.Click += new EventHandler(Button1_Click);

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(500);
            string Id = Request.Form.Get("ROLE_ID");
            string[] RoleFieldValues = new string[]{
                ROLE_NAME.Text.Trim()
            };
            if (!string.IsNullOrEmpty(Id))
            {
                KstCmsBase.DAL.Role.Role_Update(RoleFieldValues, Convert.ToInt32(Id), "RoleName");   

            }
            else
            {
                KstCmsBase.DAL.Role.Role_Insert(RoleFieldValues, "RoleName");
               
            }
            ShowMsgModle("操作成功！", "parent.frames['leftFrame'].location.reload();");

        }
    }
}