コード例 #1
0
        private void InitForModify()
        {
            UserFieldInfo dataById = SinGooCMS.BLL.UserField.GetDataById(base.OpID);

            if (dataById != null)
            {
                this.TextBox2.Text    = dataById.FieldName;
                this.TextBox2.Enabled = false;
                this.TextBox3.Text    = dataById.Alias;
                this.TextBox4.Text    = dataById.Tip;
                ListItem listItem = this.DropDownList5.Items.FindByValue(((FieldType)dataById.FieldType).ToString());
                if (listItem != null)
                {
                    listItem.Selected = true;
                }
                if (dataById.IsSystem)
                {
                    this.DropDownList5.Enabled = false;
                }
                switch (dataById.FieldType)
                {
                case 0:
                    this.ShowGroup = "group1";
                    break;

                case 1:
                    this.ShowGroup = "group2";
                    break;

                case 2:
                    this.ShowGroup = "group7";
                    break;

                case 4:
                case 5:
                case 6:
                    this.ShowGroup = "group3";
                    break;

                case 7:
                    this.ShowGroup = "group6";
                    break;

                case 8:
                case 10:
                    this.ShowGroup = "group4";
                    break;

                case 9:
                case 11:
                    this.ShowGroup = "group5";
                    break;
                }
                this.TextBox6.Text     = dataById.DefaultValue;
                this.CheckBox9.Checked = dataById.EnableNull;
                this.ExtTextBox5.Text  = dataById.DataLength.ToString();
                if (dataById.IsSystem)
                {
                    this.ExtTextBox5.Enabled = false;
                }
                SinGooCMS.Control.FieldSetting fieldSetting = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(dataById.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";
                        }
                    }
                }
            }
        }
コード例 #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";
                        }
                    }
                }
            }
        }
コード例 #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
            {
                UserFieldInfo userFieldInfo = new UserFieldInfo();
                if (base.IsEdit)
                {
                    userFieldInfo = SinGooCMS.BLL.UserField.GetDataById(base.OpID);
                }
                userFieldInfo.UserGroupID = this.modelParent.AutoID;
                userFieldInfo.FieldName   = WebUtils.GetString(this.TextBox2.Text);
                userFieldInfo.Alias       = WebUtils.GetString(this.TextBox3.Text);
                userFieldInfo.Tip         = WebUtils.GetString(this.TextBox4.Text);
                userFieldInfo.FieldType   = (int)((FieldType)System.Enum.Parse(typeof(FieldType), this.DropDownList5.SelectedValue));
                userFieldInfo.DataLength  = 50;
                if (string.IsNullOrEmpty(userFieldInfo.FieldName) || string.IsNullOrEmpty(userFieldInfo.Alias))
                {
                    base.ShowMsg("字段名称/Tên hiển thị không thể để trống");
                }
                else
                {
                    userFieldInfo.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    = userFieldInfo.FieldType.Equals(FieldType.DateTimeType);
                    fieldSetting.DataFormat    = WebUtils.GetString(this.ExtTextBox4.Text);
                    FieldType fieldType = (FieldType)userFieldInfo.FieldType;
                    if (fieldType != FieldType.MultipleHtmlType)
                    {
                        if (fieldType != FieldType.DateTimeType)
                        {
                            userFieldInfo.DataType   = "nvarchar";
                            userFieldInfo.DataLength = WebUtils.GetInt(this.ExtTextBox5.Text, 50);
                        }
                        else
                        {
                            userFieldInfo.DataType = "datetime";
                        }
                    }
                    else
                    {
                        userFieldInfo.DataType = "ntext";
                    }
                    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;
                        }
                    }
                    userFieldInfo.Setting    = XmlSerializerUtils.Serialize <SinGooCMS.Control.FieldSetting>(fieldSetting);
                    userFieldInfo.IsUsing    = this.CheckBox7.Checked;
                    userFieldInfo.EnableNull = this.CheckBox9.Checked;
                    if (base.Action.Equals(ActionType.Add.ToString()))
                    {
                        userFieldInfo.AutoTimeStamp = System.DateTime.Now;
                        userFieldInfo.IsSystem      = false;
                        userFieldInfo.Sort          = SinGooCMS.BLL.UserField.MaxSort + 1;
                        FieldAddState fieldAddState  = SinGooCMS.BLL.UserField.Add(userFieldInfo);
                        FieldAddState fieldAddState2 = fieldAddState;
                        switch (fieldAddState2)
                        {
                        case FieldAddState.Error:
                            base.ShowMsg("Tạo trường thất bại");
                            break;

                        case FieldAddState.FieldNameIsUsing:
                            base.ShowMsg("Tên trường đã được sử dụng");
                            break;

                        case FieldAddState.FieldNameExists:
                            base.ShowMsg("Tên trường đã tồn tại");
                            break;

                        case FieldAddState.ModelNotExists:
                            base.ShowMsg("没有找到会员组");
                            break;

                        case FieldAddState.CreateColumnError:
                            base.ShowMsg("Tạo cột dữ liệu thất bại");
                            break;

                        default:
                            if (fieldAddState2 != FieldAddState.Success)
                            {
                                base.ShowMsg("Lỗi Unknown");
                            }
                            else
                            {
                                PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加会员组字段[" + userFieldInfo.FieldName + "] thành công");
                                base.Response.Redirect(string.Concat(new object[]
                                {
                                    "UserField.aspx?CatalogID=",
                                    base.CurrentCatalogID,
                                    "&Module=",
                                    base.CurrentModuleCode,
                                    "&GroupID=",
                                    this.intModelID,
                                    "&action=View"
                                }));
                            }
                            break;
                        }
                    }
                    if (base.Action.Equals(ActionType.Modify.ToString()))
                    {
                        if (SinGooCMS.BLL.UserField.Update(userFieldInfo))
                        {
                            PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改会员组字段[" + userFieldInfo.FieldName + "] thành công");
                            base.Response.Redirect(string.Concat(new object[]
                            {
                                "UserField.aspx?CatalogID=",
                                base.CurrentCatalogID,
                                "&Module=",
                                base.CurrentModuleCode,
                                "&GroupID=",
                                this.intModelID,
                                "&action=View"
                            }));
                        }
                        else
                        {
                            base.ShowMsg("修改会员组字段失败");
                        }
                    }
                }
            }
        }
コード例 #4
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");
                        }
                    }
                }
            }
        }