PageRenderTime 25ms CodeModel.GetById 10ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/pigeoncms/Modules/PigeonCms.OfflineAdmin/views/Default.ascx.cs

http://pigeoncms.googlecode.com/
C# | 98 lines | 82 code | 12 blank | 4 comment | 1 complexity | 6eaf9840736f56fe6602c8d4e70a2b86 MD5 | raw file
 1using System;
 2using System.Data;
 3using System.Configuration;
 4using System.Collections;
 5using System.Web;
 6using System.Web.Security;
 7using System.Web.UI;
 8using System.Web.UI.WebControls;
 9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Web.Caching;
12using System.Collections.Generic;
13using PigeonCms;
14using PigeonCms.Core.Offline;
15
16public partial class Controls_Default : PigeonCms.BaseModuleControl
17{
18    protected void Page_Load(object sender, EventArgs e)
19    {
20        LblOk.Text = "";
21        LblErr.Text = "";
22
23        if (!Page.IsPostBack)
24        {
25            ChkOffline.Attributes.Add("onchange", "offlineWarning();");
26            loadDropTemplates();
27            loadData();
28        }
29        else
30        {
31
32        }
33
34    }
35
36    protected void BtnSave_Click(object sender, EventArgs e)
37    {
38        LblErr.Text = "";
39        LblOk.Text = "";
40
41        try
42        {
43            var o1 = new OfflineManager();
44            form2obj(o1);
45            o1.SaveData();
46            loadData();
47            OfflineProvider.ResetOfflineStatus();
48            LblOk.Text = Utility.GetLabel("RECORD_SAVED_MSG");
49        }
50        catch (Exception e1)
51        {
52            LblErr.Text = Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString();
53        }
54        finally
55        {
56        }
57    }
58
59
60    #region private methods
61    private void form2obj(OfflineManager obj)
62    {
63        obj.Title = TxtTitle.Text;
64        obj.Message = TxtMessage.Text;
65        obj.Offline = ChkOffline.Checked;
66        obj.Template = DropTemplates.SelectedValue;
67        //obj.OfflineFileName = 
68        //obj.OnlineFileName = 
69        //obj.OfflineDateTime =
70        //obj.OnlineDateTime =
71    }
72
73    private void obj2form(OfflineManager obj)
74    {
75        TxtTitle.Text = obj.Title;
76        TxtMessage.Text = obj.Message;
77        ChkOffline.Checked = obj.Offline;
78        Utility.SetDropByValue(DropTemplates, obj.Template);
79    }
80
81    private void loadData()
82    {
83        var o1 = new OfflineManager();
84        o1.GetData();
85        obj2form(o1);
86    }
87
88    private void loadDropTemplates()
89    {
90        DropTemplates.Items.Clear();
91        foreach (var item in OfflineProvider.GetTemplatesList())
92        {
93            DropTemplates.Items.Add(new ListItem(item, item));
94        }
95    }
96
97    #endregion
98}