| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using CB.Framework;
- using CB.Data;
- using CB.Entity;
- using CB.Common;
- namespace CB.Admin.Plugins.TrendTool
- {
- public partial class TrendToolListItemConfig : AdminPage
- {
- protected int ConfigId = 0;
- protected int PageID = 0;
-
- protected void Page_Load(object sender, EventArgs e)
- {
- ConfigId = WRequest.GetInt("ConfigID", 0);
- PageID = WRequest.GetInt("PageID", 0);
- if (!IsPostBack)
- { LoadData(); }
- }
- /// <summary>
- /// 加载初始数据
- /// </summary>
- private void LoadData()
- {
- TrendToolItemConfigInfo entity = new TrendToolItemConfigInfo();
- entity.ConfigID = ConfigId;
- IList<TrendToolItemConfigInfo> lists = new List<TrendToolItemConfigInfo>();
- lists = TrendToolItemConfigService.GetToolItemConfig(entity);
- repeaterList.DataSource = lists;
- repeaterList.DataBind();
- }
- protected void btnUpdate_Click(object sender, EventArgs e)
- {
- if (ConfigId < 1)
- { ShowMessageBox("获取Config失败!无法保存"); }
- TrendToolItemConfigInfo entity = new TrendToolItemConfigInfo();
- entity.ConfigID = ConfigId;
- entity.ItemID = TypeConverter.StrToInt(this.labItemID.Text.Trim());
- entity.FilterRemark = this.txtFilterRemark.Text.Trim();
- entity.LineCount = TypeConverter.StrToInt(this.txtLineCount.Text.Trim());
- entity.SpecialCode = this.txtSpecialCode.Text.Trim();
- entity.ControlArea = this.txtControlArea.Text.Trim();
- entity.ElementName = this.ddlElementName.SelectedValue.Trim();
- if (entity.ElementName == "input")
- { entity.ElementType = this.ddlElementType.SelectedValue.Trim(); }
- entity.ElementValue = this.txtElementValue.Text.Trim();
- entity.ElementCount = TypeConverter.StrToInt(this.txtElementCount.Text.Trim());
- entity.IsCheckeds = this.txtIsCheckeds.Text.Trim();
- entity.AttrOther = this.txtAttrOther.Text.Trim();
- entity.LabelValue = this.txtLabelValue.Text.Trim();
- entity.ItemOrder = TypeConverter.StrToInt(this.txtItemOrder.Text.Trim());
- entity.FilterCode = this.ddlFilterCode.SelectedValue;
- entity.FilterCodeGroup = this.txtFilterCodeGroup.Text.Trim();
- entity.NameControl = TypeConverter.StrToBool(this.ddlNameControl.SelectedValue, false);
- entity.IsControlArea = TypeConverter.StrToBool(this.ddlIsControlArea.SelectedValue, false);
- entity.HasLabel = TypeConverter.StrToBool(this.ddlHasLabel.SelectedValue, false);
- entity.Status = TypeConverter.StrToBool(this.ddlStatus.SelectedValue, false);
- TrendToolItemConfigService.Save(entity);
- TrendToolItemCssConfigInfo css = new TrendToolItemCssConfigInfo();
- css.ElementClass = this.txtElementClass.Text.Trim();
- css.ControlNameID = this.txtControlNameID.Text.Trim();
- css.OtherHTML = this.txtOtherHTML.Text.Trim();
- css.ItemID = TypeConverter.StrToInt(this.labItemID.Text.Trim());
- css.FilterCssID = TypeConverter.StrToInt(this.txtFilterCssID.Value.Trim());
- if (!(string.IsNullOrEmpty(css.ElementClass) || string.IsNullOrEmpty(css.OtherHTML)))
- { TrendToolItemCssConfigService.Save(css); }
- LoadData();
- ClearControls();
- }
- protected void repeaterList_ItemCommand(object source, RepeaterCommandEventArgs e)
- {
- int itemID = TypeConverter.ObjectToInt(e.CommandArgument);
- if (e.CommandName == "dnedit")
- {
- BindItemInfo(itemID);
- BindCssInfo(itemID);
- }
- if (e.CommandName == "dndel")
- {
- TrendToolItemConfigService.Delete(itemID);
- TrendToolItemCssConfigService.Delete(new TrendToolItemCssConfigInfo() { ItemID = itemID });
- LoadData();
- }
- }
- /// <summary>
- /// 绑定编辑数据
- /// </summary>
- /// <param name="itemID"></param>
- private void BindItemInfo(int itemID)
- {
- TrendToolItemConfigInfo entity = TrendToolItemConfigService.Get(itemID);
- if (entity == null || entity.ItemID < 1)
- { return; }
- this.txtConfigID.Value = entity.ConfigID.ToString();
- this.labItemID.Text = entity.ItemID.ToString();
- this.txtFilterRemark.Text = entity.FilterRemark;
- this.txtLineCount.Text = entity.LineCount.ToString();
- txtSpecialCode.Text = entity.SpecialCode;
- this.txtControlArea.Text = entity.ControlArea;
- this.txtElementValue.Text = entity.ElementValue;
- this.txtElementCount.Text = entity.ElementCount.ToString();
- this.txtIsCheckeds.Text = entity.IsCheckeds;
- this.txtAttrOther.Text = entity.AttrOther;
- this.txtLabelValue.Text = entity.LabelValue;
- this.txtItemOrder.Text = entity.ItemOrder.ToString();
- this.txtFilterCodeGroup.Text = entity.FilterCodeGroup;
- ListItem li1 = this.ddlFilterCode.Items.FindByValue(entity.FilterCode);
- if (li1 != null)
- {
- this.ddlFilterCode.ClearSelection();
- li1.Selected = true;
- }
- ListItem li2 = this.ddlElementName.Items.FindByValue(entity.ElementName);
- if (li2 != null)
- {
- this.ddlElementName.ClearSelection();
- li2.Selected = true;
- }
- ListItem li = this.ddlElementType.Items.FindByValue(entity.ElementType);
- if (li != null)
- {
- this.ddlElementType.ClearSelection();
- li.Selected = true;
- }
- string NameControl = entity.NameControl.ToString().ToLower();
- ListItem li3 = this.ddlNameControl.Items.FindByValue(NameControl);
- if (li3 != null)
- {
- this.ddlNameControl.ClearSelection();
- li3.Selected = true;
- }
- string IsControlArea = entity.IsControlArea.ToString().ToLower();
- ListItem li4 = this.ddlIsControlArea.Items.FindByValue(IsControlArea);
- if (li4 != null)
- {
- this.ddlIsControlArea.ClearSelection();
- li4.Selected = true;
- }
- string HasLabel = entity.HasLabel.ToString().ToLower();
- ListItem li5 = this.ddlHasLabel.Items.FindByValue(HasLabel);
- if (li5 != null)
- {
- this.ddlHasLabel.ClearSelection();
- li5.Selected = true;
- }
- string Status = entity.Status.ToString().ToLower();
- ListItem li6 = this.ddlStatus.Items.FindByValue(Status);
- if (li6 != null)
- {
- this.ddlStatus.ClearSelection();
- li6.Selected = true;
- }
- }
- /// <summary>
- /// 绑定CSS
- /// </summary>
- /// <param name="itemID"></param>
- private void BindCssInfo(int itemID)
- {
- TrendToolItemCssConfigInfo entity = TrendToolItemCssConfigService.Get(new TrendToolItemCssConfigInfo() { ItemID = itemID });
- this.txtElementClass.Text = entity.ElementClass;
- this.txtControlNameID.Text = entity.ControlNameID;
- this.txtOtherHTML.Text = entity.OtherHTML;
- this.txtFilterCssID.Value = entity.FilterCssID.ToString();
- }
- protected void btnClear_Click(object sender, EventArgs e)
- {
- ClearControls();
- }
- private void ClearControls()
- {
- this.form1.Controls.OfType<TextBox>().ToList().ForEach(t => t.Text = "");
- this.form1.Controls.OfType<DropDownList>().ToList().ForEach(t => { t.ClearSelection(); t.SelectedIndex = 0; });
- this.form1.Controls.OfType<HiddenField>().ToList().ForEach(t => t.Value = "");
- this.form1.Controls.OfType<Label>().ToList().ForEach(t => t.Text = "");
- }
- }
- }
|