|
本帖最后由 szjazz 于 2013-3-7 04:21 编辑
通过代码生成对象,过程放在Page_Init,但初始化完毕后,每次点击生成对象的事件时均会重新调用Page_Init,这样,就无法保存初始化后有修改的对象(变量)值,请问各位大师们,有什么方法?或者应该如何设计?- <x:TabStrip ID="tabStripForm" runat="server" ActiveTabIndex="0" ShowBorder="True"
- BoxFlex="1" OnTabIndexChanged="TabIndex_Change" AutoPostBack="True">
- <Tabs>
- </Tabs>
复制代码- namespace WebJazz.ES
- {
- public partial class ShowFormGrp : PageBase
- {
- Jazz.BLL.ES.Form.FormInfo bllForm = new Jazz.BLL.ES.Form.FormInfo();
- Jazz.Model.ES.Form.FormInfo modelFormInfo = new Jazz.Model.ES.Form.FormInfo();
- Jazz.Model.ES.Form.FormAcl modelFormAcl = new Jazz.Model.ES.Form.FormAcl();
- List<Jazz.Model.ES.Form.FormInfo> modelFormInfoLst = new List<Jazz.Model.ES.Form.FormInfo>();
- List<Jazz.Model.ES.Form.FormAcl> modelFormAclLst = new List<Jazz.Model.ES.Form.FormAcl>();
- public class TabInfo
- {
- public string Id { get; set; }
- public bool ChangeRefresh { get; set; }
- public bool RefreshState { get; set; }
- }
- public List<TabInfo> tabInfoLst = new List<TabInfo>();
- protected void Page_Init(object sender, EventArgs e)
- {
- Init_Page();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- ...... Load_Data();
- }
- }
- protected void Init_Page()
- {
- dsFormGrp = FormGroup(2);
- FormGrpKeyField = dsFormGrp.Tables[0].Rows[0]["FormGrpKeyField"].ToString().Split(',');
- FormGrpKeyValue = new string[FormGrpKeyField.Length];
- Init_Tab();
- }
- protected void Init_Tab()
- {
- foreach (DataRow dr in dsFormGrp.Tables[1].Rows)
- {
- string FormId = dr["FormId"].ToString();
- //由表单在组表中的类别与表单的ID组成,类别有:M=主表单、S=从表单,例子:M-88.1
- modelFormInfo = bllForm.GetFormInfoById(FormId);
- modelFormAcl = bllForm.GetFormUserAuthById(FormId, UserId);
- modelFormAclLst.Add(modelFormAcl);
- modelFormInfoLst.Add(modelFormInfo);
- if (modelFormAcl != null)
- {
- if (modelFormAcl.oper > 0)
- {
- Tab tab = new Tab();
- //由表单在组表中的类别与表单的ID组成,类别有:M=主表单、S=从表单,例子:M-88.1
- tab.ID = dr["FormType"].ToString() + "-" + FormId;
- tab.Title = dr["FormShowName"].ToString();
- tab.Layout = FineUI.Layout.Fit;
- tabStripForm.Tabs.Add(tab);
- TabInfo tabInfo = new TabInfo();
- Init_ToolBar(tab, FormId, modelFormAcl, modelFormInfo.FormType);
- switch (dr["FormType"].ToString())
- {
- case "M":
- Init_Frame(tab, FormId);
- tabInfo.ChangeRefresh = true;
- break;
- case "S":
- //非主表单,从属表单,以表格形式显示记录
- Init_Grid(tab, FormId);
- tabInfo.ChangeRefresh = false;
- break;
- case "X":
- tabInfo.ChangeRefresh = false;
- break;
- }
- tabInfo.Id = tab.ID;
- tabInfo.RefreshState = false;
- tabInfoLst.Add(tabInfo);
- }
- }
- }
- }
- protected void Init_ToolBar(Tab tab, string FormId, Jazz.Model.ES.Form.FormAcl modelFormAcl, int FormType)
- {
- //
- Toolbar tf = new Toolbar();
- tf.Items.Add(new ToolbarFill());
- Init_Button("Re-" + FormId, "刷新", "~\\res\\images\\icon\\refresh.png", tf);
- ......
- tab.Toolbars.Add(tf);
- }
- protected void Init_Button(string btn_ID, string btn_Name, string btn_iconUrl, Toolbar tf)
- {
- FineUI.Button btn = new FineUI.Button();
- btn.ID = btn_ID;
- btn.Text = btn_Name;
- btn.IconUrl = btn_iconUrl;
- btn.Click += new EventHandler(btn_Click);
- btn.Size = FineUI.ButtonSize.Medium;
- tf.Items.Add(btn);
- }
- protected FineUI.Panel Init_Frame(Tab tab, string FormId)
- {
- FineUI.Panel pFrame = new FineUI.Panel();
- pFrame.ID = "Frame-" + FormId;
- pFrame.IFrameName = "Frame-" + FormId;
- pFrame.EnableIFrame = true;
- pFrame.AutoScroll = true;
- pFrame.ShowHeader = false;
- tab.Items.Add(pFrame);
- return pFrame;
- }
- protected void Init_Grid(Tab tab, string FormId)
- {
- //
- Grid grid = new Grid();
- grid.ID = "Grid-" + FormId;
- .....
- grid.Columns.Add(bf); }
- tab.Items.Add(grid);
- }
- protected void btn_Click(object sender, EventArgs e)
- {
- FineUI.Button btn = (FineUI.Button)sender;
- string target;
- if (btn.ID.Substring(0,3) == "Re-")
- {
- //手动刷新
- target = "Frame-" + tabStripForm.ActiveTab.ID.Substring(2);
- FineUI.Panel panel = (FineUI.Panel)tabStripForm.ActiveTab.FindControl(target);
- panel.RefreshIFrame();
- }
- }
- protected void Load_Data()
- {
- foreach (Tab tab in tabStripForm.Tabs)
- {
- //由表单在组表中的类别与表单的ID组成,类别有:M=主表单、S=从表单,例子:M-88.1
- string FormId = tab.ID.ToString().Substring(2);
- string FormType = tab.ID.ToString().Substring(0, 1);
- if (FormType == "M")
- {
- //显示主表单内容
- Load_Form_Data(tab, FormId, FormGrpKeyField, FormGrpKeyValue);
- }
- else
- {
- //显示表格记录
- Load_Grid_Data(tab, FormId, FormGrpKeyField, FormGrpKeyValue);
- }
- }
- }
- protected void Load_Form_Data(FineUI.Tab tab, string FormId, string[] FormGrpKeyField, string[] FormGrpKeyValue)
- {
- FineUI.Panel pFrame = new FineUI.Panel();
- pFrame = (FineUI.Panel)tab.FindControl("Frame-" + FormId);
- modelFormInfo = modelFormInfoLst.Find(delegate(Jazz.Model.ES.Form.FormInfo model) { return model.FormId == FormId; });
- modelFormAcl = modelFormAclLst.Find(delegate(Jazz.Model.ES.Form.FormAcl model) { return model.RtId == FormId; });
- //"ExcelServerRcId","WiId","ExcelServerRN","ExcelServerCN" ="_rcId", "_wiId", "_rn", "_cn"
- FormSysKeyValue[0] = bllForm.GetFormSysKeyByFormKey(FormId, FormSysKeyFieldAlias[0], FormGrpKeyField, FormGrpKeyValue);
- if (modelFormInfo.FormType == 1)
- //工作流表单
- FormSysKeyValue[1] = bllForm.GetFormSysKeyByFormKey(FormId, FormSysKeyFieldAlias[1], FormGrpKeyField, FormGrpKeyValue);
- else
- FormSysKeyValue[1] = string.Empty;
- string AuthStr = modelFormInfo.itemType;
- string Url = null;
- if (FormSysKeyValue[0] != null)
- Url = string.Format("http://localhost/esweb/Appfunc/main.aspx?repref={0}&rcId={1}&openWiId={2}&flag={3}&isReadOnly=1", FormId, FormSysKeyValue[0], FormSysKeyValue[1], AuthStr);
- pFrame.IFrameUrl = Url;
- }
- protected void Load_Grid_Data(FineUI.Tab tab, string FormId, string[] FormGrpKeyField, string[] FormGrpKeyValue)
- {
- FineUI.Grid grid = new FineUI.Grid();
- grid = (FineUI.Grid)tab.FindControl("Grid-" + FormId);
- DataSet ds = bllForm.GetFormMgrLstById(FormId, FormGrpKeyField, FormGrpKeyValue);
- grid.DataSource = ds.Tables[0];
- grid.DataBind();
- }
- protected void TabIndex_Change(object sender, EventArgs e)
- {
- //希望切换Tab时,能刷新IFrame,但只刷新一次,所以需要保留状态
- FineUI.TabStrip tabStrip = (FineUI.TabStrip)sender;
- string tabId = tabStripForm.ActiveTab.ID;
- TabInfo tabInfo = new TabInfo();
- tabInfo = tabInfoLst.Find(delegate(TabInfo info) { return info.Id == tabId; });
- if (tabInfo.ChangeRefresh && tabInfo.RefreshState == false)
- {
- tabInfo.RefreshState = true;
- FineUI.Panel panel = (FineUI.Panel)tabStripForm.ActiveTab.FindControl("Frame-" + tabId.Substring(2));
- panel.RefreshIFrame();
- }
- }
- }
- }
复制代码
|
|