Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Sys_FunctionRepository repository = new Sys_FunctionRepository();

            if (Attributes["param"] != null)
            {
                string URL = Attributes["param"];
                id = Util.GetParam(URL, "id");

                if (string.IsNullOrEmpty(id))
                {
                    id = "0";
                }

                if (id != "0")
                {
                    Sys_Function entity = repository.GetById(int.Parse(id));
                    txtName.Text  = entity.TenChucNang;
                    txtMa.Text    = entity.Ma;
                    txtIcon.Text  = entity.Icon;
                    txtHref.Text  = entity.Href;
                    txtOrder.Text = entity.ThuTu != null?entity.ThuTu.ToString() : "0";

                    try
                    {
                        txtParent.Text = new xRPDataContext().Sys_Functions.FirstOrDefault(x => x.ID == entity.ParentID).TenChucNang;
                    }
                    catch
                    {
                        txtParent.Text = "";
                    }
                    hdfParentID.Value = entity.ParentID != null?entity.ParentID.Value.ToString() : "0";
                }
            }
        }
Exemplo n.º 2
0
        public static string AddOrUpdateFunctionItem(string id, string ma, string name, string parentID, string href, string icon, string thutu)
        {
            AjaxResponse   response = new AjaxResponse();
            xRPDataContext dts      = new xRPDataContext();
            var            user     = (from u in dts.aspnet_Users where u.UserName == HttpContext.Current.User.Identity.Name select u).FirstOrDefault();

            try
            {
                string message = string.Empty;

                int    groupdID    = 0;
                string role        = string.Empty;
                bool   isExistName = false;//
                Sys_FunctionRepository repository = new Sys_FunctionRepository();

                //response.IsSuccess = true;
                //response.Message = "Cập nhật thành công";

                Sys_Function entity = new Sys_Function();

                if (id != "")
                {
                    entity = repository.GetById(int.Parse(id));
                }
                else
                {
                    entity.NgayTao    = DateTime.Now;
                    entity.MaNguoiTao = user.UserId;
                }
                entity.NgayThayDoi    = DateTime.Now;
                entity.MaNguoiThayDoi = user.UserId;
                entity.Ma             = ma;
                entity.TenChucNang    = name;
                entity.ParentID       = int.Parse(parentID);
                entity.Href           = href;
                entity.Icon           = icon;
                entity.Position       = 1;
                entity.PhanHeID       = 1;
                entity.ThuTu          = int.Parse(thutu);
                if (id == "0")
                {
                    repository.InsertOnSubmit(entity);
                }
                repository.SubmitChanges();
                response.IsSuccess = true;
                response.Message   = "Cập nhật thành công";
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = (ex.Message + ex.StackTrace).EncodeJsString();
            }
            return(JsonConvert.SerializeObject(response));
        }
Exemplo n.º 3
0
        public static string AddOrUpdateFunctionRole(string roleId, string lsFunction)
        {
            AjaxResponse response    = new AjaxResponse();
            var          strresponse = "";

            if (!string.IsNullOrEmpty(lsFunction))
            {
                xRPDataContext         dts = new xRPDataContext();
                Sys_FunctionRepository functionRepository = new Sys_FunctionRepository();
                var user = (from u in dts.aspnet_Users where u.UserName == HttpContext.Current.User.Identity.Name select u).FirstOrDefault();

                var dataQuyenTheoChucNangs = new JavaScriptSerializer().Deserialize <List <Sys_QuyenTheoChucNang> >(lsFunction);
                response.IsSuccess = functionRepository.AddOrUpdateFunctionRole(new Guid(roleId), dataQuyenTheoChucNangs, user.UserId, ref strresponse);
                response.Message   = strresponse.EncodeJsString();
            }
            else
            {
                response.IsSuccess = false;
                response.Message   = "Quá trình thực hiện không thành công".EncodeJsString();
            }
            return(JsonConvert.SerializeObject(response));
        }