wfrm_Main.cs
上传用户:horngjaan
上传日期:2009-12-12
资源大小:2882k
文件大小:6k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.SqlClient;
- namespace LumiSoft.MailServer
- {
- /// <summary>
- /// Summary description for Form1.
- /// </summary>
- public class wfrm_Main : System.Windows.Forms.Form
- {
- private LumiSoft.UI.Controls.WTabs.WTab wTab1;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- private ServerAPI m_ServerAPI = null;
- private DataSet dsSettings = null;
- private string m_connStr = "";
- private DB_Type m_DB_Type = DB_Type.XML;
- private wfrm_Domains m_pDomains_Frm = null;
- private wfrm_Users m_pUsers_Frm = null;
- private wfrm_Aliases m_pAliases_Frm = null;
- private wfrm_Routing m_pRouting_Frm = null;
- private wfrm_Setup m_pSetup_Frm = null;
- private wfrm_Delivery m_pDelivery_Frm = null;
- private wfrm_Security m_pSecurity_Frm = null;
- private wfrm_BackUp m_pBackUP_Frm = null;
- private wfrm_Logging m_pLogging = null;
- /// <summary>
- /// Default constructor.
- /// </summary>
- public wfrm_Main()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- try
- {
- dsSettings = new DataSet();
- LoadData();
-
- m_pSetup_Frm = new wfrm_Setup(dsSettings,this);
- wTab1.AddTab(m_pSetup_Frm,"Server Settings");
- if(!ServerAPI.IsConnection(Application.StartupPath + "\Settings\",m_connStr,m_DB_Type)){
- MessageBox.Show(this,"Database connection is invalid,nplease configure database settings !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
- return;
- }
- m_ServerAPI = new ServerAPI(Application.StartupPath + "\Settings\","",m_connStr,m_DB_Type);
- m_pDomains_Frm = new wfrm_Domains(m_ServerAPI,this);
- m_pUsers_Frm = new wfrm_Users(m_ServerAPI);
- m_pAliases_Frm = new wfrm_Aliases(m_ServerAPI);
- m_pRouting_Frm = new wfrm_Routing(m_ServerAPI);
- m_pDelivery_Frm = new wfrm_Delivery(dsSettings);
- m_pSecurity_Frm = new wfrm_Security(m_ServerAPI);
- m_pBackUP_Frm = new wfrm_BackUp(m_ServerAPI,this,dsSettings);
- m_pLogging = new wfrm_Logging(dsSettings);
- wTab1.AddTab(m_pDomains_Frm , "Domains");
- wTab1.AddTab(m_pUsers_Frm , "Users");
- wTab1.AddTab(m_pAliases_Frm , "Aliases");
- wTab1.AddTab(m_pRouting_Frm , "Routing");
- wTab1.AddTab(m_pDelivery_Frm , "Delivery");
- wTab1.AddTab(m_pSecurity_Frm , "Security");
- wTab1.AddTab(m_pBackUP_Frm , "BackUp");
- wTab1.AddTab(m_pLogging , "Logging");
- }
- catch(Exception x)
- {
- wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
- frm.ShowDialog(this);
- }
- finally{
- wTab1.SelectFirstTab();
- }
- }
- #region function Dispose
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #endregion
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.wTab1 = new LumiSoft.UI.Controls.WTabs.WTab();
- this.SuspendLayout();
- //
- // wTab1
- //
- this.wTab1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.wTab1.Name = "wTab1";
- this.wTab1.SelectedTab = null;
- this.wTab1.Size = new System.Drawing.Size(634, 423);
- this.wTab1.TabIndex = 0;
- //
- // wfrm_Main
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(634, 423);
- this.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.wTab1});
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.MaximizeBox = false;
- this.Name = "wfrm_Main";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "LumiSoft Mail Server Manager";
- this.ResumeLayout(false);
- }
- #endregion
- #region function LoadData
-
- private void LoadData()
- {
- try
- {
- dsSettings.Tables.Clear();
- dsSettings.ReadXml(Application.StartupPath + "\Settings\Settings.xml");
-
- m_connStr = dsSettings.Tables["Settings"].Rows[0]["ConnectionString"].ToString();
- m_DB_Type = (DB_Type)Enum.Parse(typeof(DB_Type),dsSettings.Tables["Settings"].Rows[0]["DataBaseType"].ToString());
- }
- catch(Exception x)
- {
- wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
- frm.ShowDialog(this);
- }
- }
- #endregion
- #region function EnableTabs
- /// <summary>
- /// Disables all tabs.
- /// </summary>
- public void EnableTabs()
- {
- foreach(LumiSoft.UI.Controls.WTabs.Tab t in wTab1.WTabBar.Tabs){
- t.Enabled = true;
- }
- }
- #endregion
- #region function DisableTabs
- /// <summary>
- /// Disables all tabs.
- /// </summary>
- public void DisableTabs()
- {
- foreach(LumiSoft.UI.Controls.WTabs.Tab t in wTab1.WTabBar.Tabs){
- t.Enabled = false;
- }
- }
- #endregion
- #region function RefreshForms
- public void RefreshForms()
- {
- // m_pDomains_Frm.RefreshForm();
- m_pUsers_Frm.RefreshForm();
- m_pAliases_Frm.RefreshForm();
- m_pRouting_Frm.RefreshForm();
- m_pSetup_Frm.RefreshForm();
- m_pDelivery_Frm.RefreshForm();
- // m_pSecurity_Frm
- m_pLogging.RefreshFrom();
- }
- #endregion
- }
- }