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);
         SettingInfo entityById = SettingProvider.GetEntityById(@int);
         if (entityById == null)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Không tìm thấy cấu hình này, cấu hình không tồn tại hoặc đã bị xóa");
         }
         else if (SettingProvider.Delete(entityById.AutoID))
         {
             CacheUtils.Del("JsonLeeCMS_CacheForGetSetting");
             CacheUtils.Del("JsonLeeCMS_CacheForSETTINGDIRECTORY");
             this.BindData();
             PageBase.log.AddEvent(base.LoginAccount.AccountName, "Delete custom settings[" + entityById.KeyName + "]success");
             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 InitForModify()
        {
            SettingInfo entityById = SettingProvider.GetEntityById(base.OpID);

            if (entityById != null)
            {
                this.TextBox1.Text = entityById.KeyName;
                this.TextBox3.Text = entityById.KeyDesc;
                ListItem listItem = this.DropDownList5.Items.FindByValue(entityById.ControlType);
                if (listItem != null)
                {
                    listItem.Selected = true;
                }
                switch ((FieldType)System.Enum.Parse(typeof(FieldType), entityById.ControlType))
                {
                case FieldType.SingleTextType:
                    this.ShowGroup = "group1";
                    break;

                case FieldType.MultipleTextType:
                    this.ShowGroup = "group2";
                    break;

                case FieldType.MultipleHtmlType:
                    this.ShowGroup = "group7";
                    break;

                case FieldType.RadioButtonType:
                case FieldType.CheckBoxType:
                case FieldType.DropDownListType:
                    this.ShowGroup = "group3";
                    break;

                case FieldType.DateTimeType:
                    this.ShowGroup = "group6";
                    break;

                case FieldType.PictureType:
                case FieldType.FileType:
                    this.ShowGroup = "group4";
                    break;

                case FieldType.MultiPictureType:
                case FieldType.MultiFileType:
                    this.ShowGroup = "group5";
                    break;
                }
                this.TextBox6.Text     = entityById.DefaultValue;
                this.CheckBox7.Checked = entityById.IsUsing;
                this.ExtTextBox5.Text  = entityById.DataLength.ToString();
                SinGooCMS.Control.FieldSetting fieldSetting = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(entityById.Setting);
                if (fieldSetting != null)
                {
                    this.ExtTextBox1.Text = fieldSetting.ControlWidth.ToString();
                    this.ExtTextBox2.Text = fieldSetting.ControlHeight.ToString();
                    ListItem listItem2 = this.ExtRadioButtonList3.Items.FindByValue(fieldSetting.TextMode);
                    if (listItem2 != null)
                    {
                        listItem2.Selected = true;
                    }
                    this.ExtTextBox4.Text = fieldSetting.DataFormat;
                    ListItem listItem3 = this.ExtDropDownList6.Items.FindByValue(fieldSetting.DataFrom);
                    if (listItem3 != null)
                    {
                        listItem3.Selected = true;
                    }
                    string dataFrom = fieldSetting.DataFrom;
                    if (dataFrom != null)
                    {
                        if (!(dataFrom == "Text"))
                        {
                            if (!(dataFrom == "DataDictionary"))
                            {
                                if (!(dataFrom == "SQLQuery"))
                                {
                                    if (dataFrom == "AjaxData")
                                    {
                                        this.ExtTextBox11.Text = fieldSetting.DataSource;
                                        this.DataSource        = "AjaxData";
                                    }
                                }
                                else
                                {
                                    this.ExtTextBox9.Text = fieldSetting.DataSource;
                                    this.DataSource       = "SQLQuery";
                                }
                            }
                            else
                            {
                                this.ExtTextBox8.Text = fieldSetting.DataSource;
                                this.DataSource       = "DataDictionary";
                            }
                        }
                        else
                        {
                            this.ExtTextBox7.Text = fieldSetting.DataSource;
                            this.DataSource       = "Text";
                        }
                    }
                }
            }
        }
Example #3
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
            {
                SettingInfo settingInfo = new SettingInfo();
                if (base.IsEdit)
                {
                    settingInfo = SettingProvider.GetEntityById(base.OpID);
                }
                settingInfo.KeyName = WebUtils.GetString(this.TextBox1.Text);
                settingInfo.CateID  = ((this.cate == null) ? 0 : this.cate.AutoID);
                settingInfo.KeyDesc = WebUtils.GetString(this.TextBox3.Text);
                if (settingInfo.CateID == 0)
                {
                    base.ShowMsg("Chọn phân loại Cấu hình");
                }
                else if (string.IsNullOrEmpty(settingInfo.KeyName))
                {
                    base.ShowMsg("Cấu hình tên chủ chốt không thể để trống");
                }
                else if (string.IsNullOrEmpty(settingInfo.KeyDesc))
                {
                    base.ShowMsg("Tên hiển thị không thể để trống");
                }
                else
                {
                    settingInfo.DataLength   = WebUtils.GetInt(this.ExtTextBox5.Text, 50);
                    settingInfo.ControlType  = this.DropDownList5.SelectedValue;
                    settingInfo.DefaultValue = WebUtils.GetString(this.TextBox6.Text);
                    SinGooCMS.Control.FieldSetting fieldSetting = new SinGooCMS.Control.FieldSetting();
                    fieldSetting.ControlWidth  = WebUtils.GetInt(this.ExtTextBox1.Text);
                    fieldSetting.ControlHeight = WebUtils.GetInt(this.ExtTextBox2.Text);
                    fieldSetting.TextMode      = this.ExtRadioButtonList3.SelectedValue;
                    fieldSetting.IsDataType    = settingInfo.ControlType.Equals(FieldType.DateTimeType);
                    fieldSetting.DataFormat    = WebUtils.GetString(this.ExtTextBox4.Text);
                    FieldType fieldType = (FieldType)System.Enum.Parse(typeof(FieldType), settingInfo.ControlType);
                    switch (fieldType)
                    {
                    case FieldType.MultipleTextType:
                    case FieldType.MultipleHtmlType:
                        settingInfo.DataType = "ntext";
                        break;

                    default:
                        if (fieldType != FieldType.DateTimeType)
                        {
                            settingInfo.DataType   = "nvarchar";
                            settingInfo.DataLength = WebUtils.GetInt(this.ExtTextBox5.Text, 50);
                        }
                        else
                        {
                            settingInfo.DataType = "datetime";
                        }
                        break;
                    }
                    fieldSetting.DataFrom = this.ExtDropDownList6.SelectedValue;
                    string dataFrom = fieldSetting.DataFrom;
                    if (dataFrom != null)
                    {
                        if (!(dataFrom == "Text"))
                        {
                            if (!(dataFrom == "DataDictionary"))
                            {
                                if (!(dataFrom == "SQLQuery"))
                                {
                                    if (dataFrom == "AjaxData")
                                    {
                                        fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox11.Text);
                                    }
                                }
                                else
                                {
                                    fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox9.Text);
                                }
                            }
                            else
                            {
                                fieldSetting.DataSource = WebUtils.GetString(this.ExtTextBox8.Text);
                            }
                        }
                        else
                        {
                            fieldSetting.DataSource = this.ExtTextBox7.Text;
                        }
                    }
                    settingInfo.Setting  = XmlSerializerUtils.Serialize <SinGooCMS.Control.FieldSetting>(fieldSetting);
                    settingInfo.IsUsing  = this.CheckBox7.Checked;
                    settingInfo.IsSystem = false;
                    settingInfo.Sort     = 9999;
                    if (base.Action.Equals(ActionType.Add.ToString()))
                    {
                        if (SettingProvider.ExistsByName(settingInfo.KeyName))
                        {
                            base.ShowMsg("Cấu hình tùy chỉnh cùng tên đã tồn tại");
                            return;
                        }
                        settingInfo.AutoTimeStamp = System.DateTime.Now;
                        if (SettingProvider.Add(settingInfo) > 0)
                        {
                            CacheUtils.Del("JsonLeeCMS_CacheForGetSetting");
                            CacheUtils.Del("JsonLeeCMS_CacheForSETTINGDIRECTORY");
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "Thêm cấu hình tùy chỉnh [" + settingInfo.KeyDesc + "] thành công");
                            base.Response.Redirect(string.Concat(new object[]
                            {
                                "CustomSetting.aspx?CatalogID=",
                                base.CurrentCatalogID,
                                "&Module=",
                                base.CurrentModuleCode,
                                "&cateid=",
                                this.cate.AutoID,
                                "&action=View"
                            }));
                        }
                        else
                        {
                            base.ShowMsg("Thêm cấu hình tùy chỉnh thất bại");
                        }
                    }
                    if (base.Action.Equals(ActionType.Modify.ToString()))
                    {
                        if (SettingProvider.Update(settingInfo))
                        {
                            CacheUtils.Del("JsonLeeCMS_CacheForGetSetting");
                            CacheUtils.Del("JsonLeeCMS_CacheForSETTINGDIRECTORY");
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "Sửa đổi các cấu hình tùy chỉnh [" + settingInfo.KeyDesc + "] thành công");
                            base.Response.Redirect(string.Concat(new object[]
                            {
                                "CustomSetting.aspx?CatalogID=",
                                base.CurrentCatalogID,
                                "&Module=",
                                base.CurrentModuleCode,
                                "&cateid=",
                                this.cate.AutoID,
                                "&action=View"
                            }));
                        }
                        else
                        {
                            base.ShowMsg("Sửa đổi các cấu hình tùy chỉnh thất bại");
                        }
                    }
                }
            }
        }