Example #1
0
 protected void lnk_Delete_Click(object sender, System.EventArgs e)
 {
     if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
     {
         base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
     }
     else
     {
         int       @int     = WebUtils.GetInt((sender as LinkButton).CommandArgument);
         DictsInfo dataById = Dicts.GetDataById(@int);
         if (dataById == null)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Những thông tin này không được tìm thấy, các dữ liệu không tồn tại hoặc đã bị xóa");
         }
         else if (dataById.IsSystem)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Từ điển hệ thống không thể bị xóa");
         }
         else if (Dicts.Delete(@int))
         {
             this.BindData();
             PageBase.log.AddEvent(base.LoginAccount.AccountName, "xóa từ điển[" + dataById.DictName + "] thành công");
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công");
         }
         else
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại");
         }
     }
 }
Example #2
0
        private void BindData()
        {
            DictsInfo dataById = Dicts.GetDataById(base.OpID);

            if (dataById != null)
            {
                this.Repeater1.DataSource = dataById.Items;
                this.Repeater1.DataBind();
            }
        }
Example #3
0
        private void InitForModify()
        {
            DictsInfo dataById = Dicts.GetDataById(base.OpID);

            this.TextBox1.Text = dataById.DictName;
            if (dataById.IsSystem)
            {
                this.TextBox1.Enabled = false;
            }
            this.TextBox2.Text = dataById.DisplayName;
        }
Example #4
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.dictCurrent = Dicts.GetDataById(WebUtils.GetQueryInt("dictid"));
     if (this.dictCurrent == null)
     {
         base.ShowMsgAndRdirect("Chúng tôi không tìm thấy thông tin từ điển, lỗi thông số", base.Request.UrlReferrer.ToString());
     }
     else if (base.IsEdit && !base.IsPostBack)
     {
         this.InitForModify();
     }
 }
Example #5
0
        private void GetDictItemsByName()
        {
            DictsInfo cacheDictsByName = Dicts.GetCacheDictsByName(WebUtils.GetQueryString("dictname"));

            if (cacheDictsByName != null && cacheDictsByName.Items.Count > 0)
            {
                base.Response.Write(JsonUtils.ObjectToJson <System.Collections.Generic.IList <DictItemInfo> >(cacheDictsByName.Items));
            }
            else
            {
                base.Response.Write(string.Empty);
            }
        }
Example #6
0
        public static int Add(DictsInfo entity)
        {
            int result;

            if (entity == null)
            {
                result = 0;
            }
            else
            {
                result = BizBase.dbo.InsertModel <DictsInfo>(entity);
            }
            return(result);
        }
Example #7
0
 protected void lnk_Delete_Click(object sender, System.EventArgs e)
 {
     if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
     {
         base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
     }
     else
     {
         DictsInfo dataById = Dicts.GetDataById(base.OpID);
         if (dataById == null)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Thông tin từ điển không được tìm thấy, từ điển không tồn tại hoặc đã bị xóa");
         }
         else
         {
             string commandArgument = ((LinkButton)sender).CommandArgument;
             System.Collections.Generic.List <DictItemInfo> list = new System.Collections.Generic.List <DictItemInfo>();
             foreach (DictItemInfo current in dataById.Items)
             {
                 if (!(current.KeyName == commandArgument.Split(new char[]
                 {
                     '|'
                 })[0]) || !(current.KeyValue == commandArgument.Split(new char[]
                 {
                     '|'
                 })[1]))
                 {
                     list.Add(current);
                 }
             }
             dataById.DictValue = JsonUtils.ObjectToJson <System.Collections.Generic.List <DictItemInfo> >(list);
             if (Dicts.Update(dataById))
             {
                 CacheUtils.Del("JsonLeeCMS_CacheForGetDicts");
                 this.BindData();
                 PageBase.log.AddEvent(base.LoginAccount.AccountName, "xóa từ điển[" + commandArgument + "] thành công");
                 base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công");
             }
             else
             {
                 base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại");
             }
         }
     }
 }
Example #8
0
        protected void btn_SaveSort_Click(object sender, System.EventArgs e)
        {
            DictsInfo dataById = Dicts.GetDataById(base.OpID);

            System.Collections.Generic.List <DictItemInfo> list = new System.Collections.Generic.List <DictItemInfo>();
            string[] array = WebUtils.GetFormString("key").Split(new char[]
            {
                ','
            });
            string[] array2 = WebUtils.GetFormString("value").Split(new char[]
            {
                ','
            });
            string[] array3 = WebUtils.GetFormString("sort").Split(new char[]
            {
                ','
            });
            if (array.Length > 0)
            {
                for (int i = 0; i < array.Length; i++)
                {
                    list.Add(new DictItemInfo
                    {
                        KeyName  = array[i],
                        KeyValue = array2[i],
                        Sort     = WebUtils.GetInt(array3[i])
                    });
                }
                list = (from p in list
                        orderby p.Sort
                        select p).ToList <DictItemInfo>();
                dataById.DictValue = JsonUtils.ObjectToJson <System.Collections.Generic.List <DictItemInfo> >(list);
                if (Dicts.Update(dataById))
                {
                    this.BindData();
                    PageBase.log.AddEvent(base.LoginAccount.AccountName, "Đặt từ điển [" + dataById.DictName + "] sắp xếp thành công");
                    base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công");
                }
                else
                {
                    base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại");
                }
            }
        }
Example #9
0
 protected void btnok_Click(object sender, System.EventArgs e)
 {
     if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else
     {
         DictsInfo dictsInfo = new DictsInfo();
         if (base.IsEdit)
         {
             dictsInfo = Dicts.GetDataById(base.OpID);
         }
         dictsInfo.DictName    = WebUtils.GetString(this.TextBox1.Text);
         dictsInfo.DisplayName = WebUtils.GetString(this.TextBox2.Text);
         if (string.IsNullOrEmpty(dictsInfo.DictName))
         {
             base.ShowMsg("Tên từ điển không thể để trống");
         }
         else if (string.IsNullOrEmpty(dictsInfo.DisplayName))
         {
             base.ShowMsg("Tên hiển thị không thể để trống");
         }
         else
         {
             if (base.Action.Equals(ActionType.Add.ToString()))
             {
                 if (Dicts.ExistsForName(dictsInfo.DictName))
                 {
                     base.ShowMsg("Khóa từ điển đã tồn tại!");
                 }
                 else
                 {
                     dictsInfo.IsSystem = false;
                     if (Dicts.Add(dictsInfo) > 0)
                     {
                         CacheUtils.Del("JsonLeeCMS_CacheForGetDicts");
                         PageBase.log.AddEvent(base.LoginAccount.AccountName, "Thêm từ điển [" + dictsInfo.DictName + "] thành công");
                         MessageUtils.DialogCloseAndParentReload(this);
                     }
                     else
                     {
                         base.ShowMsg("Thao tác thất bại");
                     }
                 }
             }
             if (base.Action.Equals(ActionType.Modify.ToString()))
             {
                 if (Dicts.Update(dictsInfo))
                 {
                     CacheUtils.Del("JsonLeeCMS_CacheForGetDicts");
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "Sửa đổi từ điển [" + dictsInfo.DictName + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("Thao tác thất bại");
                 }
             }
         }
     }
 }
Example #10
0
 public static bool Update(DictsInfo entity)
 {
     return(entity != null && BizBase.dbo.UpdateModel <DictsInfo>(entity));
 }
Example #11
0
 protected void btnok_Click(object sender, System.EventArgs e)
 {
     if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else
     {
         DictsInfo dataById   = Dicts.GetDataById(WebUtils.GetQueryInt("dictid"));
         string    strKeyName = WebUtils.GetString(this.TextBox1.Text);
         string    @string    = WebUtils.GetString(this.TextBox2.Text);
         int       @int       = WebUtils.GetInt(this.TextBox3.Text);
         if (string.IsNullOrEmpty(strKeyName))
         {
             base.ShowMsg("Nội dung Từ điển quan trọng không thể để trống");
         }
         else if (string.IsNullOrEmpty(@string))
         {
             base.ShowMsg("Giá trị từ điền không thể để trống");
         }
         else if (base.Action.Equals(ActionType.Add.ToString()) && dataById.Items.Exists((DictItemInfo p) => p.KeyName.Equals(strKeyName)))
         {
             base.ShowMsg("Nội dung từ điển đã tồn tại");
         }
         else
         {
             if (base.Action.Equals(ActionType.Add.ToString()))
             {
                 string text = string.Empty;
                 if (dataById.DictValue.IndexOf("[") == -1)
                 {
                     text = string.Concat(new object[]
                     {
                         "{\"KeyName\":\"",
                         strKeyName,
                         "\",\"KeyValue\":\"",
                         @string,
                         "\",\"Sort\":",
                         @int,
                         "}"
                     });
                 }
                 else
                 {
                     text = string.Concat(new object[]
                     {
                         dataById.DictValue.TrimStart(new char[]
                         {
                             '['
                         }).TrimEnd(new char[]
                         {
                             ']'
                         }),
                         ",{\"KeyName\":\"",
                         strKeyName,
                         "\",\"KeyValue\":\"",
                         @string,
                         "\",\"Sort\":",
                         @int,
                         "}"
                     });
                 }
                 dataById.DictValue = "[" + text.TrimStart(new char[]
                 {
                     ','
                 }) + "]";
                 if (Dicts.Update(dataById))
                 {
                     CacheUtils.Del("JsonLeeCMS_CacheForGetDicts");
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "Thêm nội dung từ điển [" + strKeyName + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("Thao tác thất bại");
                 }
             }
             if (base.Action.Equals(ActionType.Modify.ToString()))
             {
                 DictItemInfo dictItemInfo = (from p in Dicts.GetDataById(WebUtils.GetQueryInt("dictid")).Items
                                              where p.KeyName.Equals(WebUtils.GetQueryString("key"))
                                              select p).FirstOrDefault <DictItemInfo>();
                 string oldValue = string.Concat(new object[]
                 {
                     "{\"KeyName\":\"",
                     dictItemInfo.KeyName,
                     "\",\"KeyValue\":\"",
                     dictItemInfo.KeyValue,
                     "\",\"Sort\":",
                     dictItemInfo.Sort,
                     "}"
                 });
                 string newValue = string.Concat(new object[]
                 {
                     "{\"KeyName\":\"",
                     strKeyName,
                     "\",\"KeyValue\":\"",
                     @string,
                     "\",\"Sort\":",
                     @int,
                     "}"
                 });
                 dataById.DictValue = dataById.DictValue.Replace(oldValue, newValue);
                 if (Dicts.Update(dataById))
                 {
                     CacheUtils.Del("JsonLeeCMS_CacheForGetDicts");
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "Sửa đổi nội dung từ điển [" + strKeyName + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("Thao tác thất bại");
                 }
             }
         }
     }
 }