wfrm_Alias.cs
上传用户:horngjaan
上传日期:2009-12-12
资源大小:2882k
文件大小:17k
- using System;
- using System.IO;
- 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 Alias_Frm.
- /// </summary>
- public class wfrm_Alias : System.Windows.Forms.Form
- {
- private LumiSoft.UI.Controls.WButton m_pOk;
- private LumiSoft.UI.Controls.WButton m_pRemove;
- private LumiSoft.UI.Controls.WButton m_pAdd;
- private LumiSoft.UI.Controls.WComboBox m_pDomains;
- private LumiSoft.UI.Controls.WLabel mt_symbolAT;
- private LumiSoft.UI.Controls.WEditBox m_pDescription;
- private LumiSoft.UI.Controls.WLabel mt_description;
- private LumiSoft.UI.Controls.WEditBox m_pName;
- private LumiSoft.UI.Controls.WLabel mt_name;
- private LumiSoft.UI.Controls.WEditBox m_pMember;
- private LumiSoft.UI.Controls.WLabel mt_member;
- private System.Windows.Forms.ListBox m_pMembers;
- private LumiSoft.UI.Controls.WButton m_pCancel;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- private ServerAPI m_ServerAPI = null;
- private string m_AliasName = "";
- private string m_Descriprion = "";
- private string m_Members = "";
- private string m_DomainID = "";
- /// <summary>
- /// Add new constructor.
- /// </summary>
- /// <param name="serverAPI"></param>
- /// <param name="domainID"></param>
- public wfrm_Alias(ServerAPI serverAPI,string domainID)
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- try
- {
- m_ServerAPI = serverAPI;
- DataView dvDomains = m_ServerAPI.GetDomainList();
- foreach(DataRowView vDr in dvDomains){
- m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
- }
- if(m_pDomains.Items.Count > 0){
- m_pDomains.SelectedIndex = 0;
- }
- if(domainID != "ALL"){
- m_pDomains.SelectItemByTag(domainID);
- }
- }
- catch(Exception x)
- {
- wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
- frm.ShowDialog(this);
- }
- }
- /// <summary>
- /// Edit constructor.
- /// </summary>
- /// <param name="serverAPI"></param>
- /// <param name="dr"></param>
- public wfrm_Alias(ServerAPI serverAPI,DataRow dr)
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
-
- try
- {
- m_ServerAPI = serverAPI;
- m_pName.Text = dr["AliasName"].ToString().Split(new char[]{'@'})[0];
- m_pDescription.Text = dr["Description"].ToString();
-
- string[] member = dr["AliasMembers"].ToString().Split(new char[]{';'});
- foreach(string adr in member){
- m_pMembers.Items.Add(adr);
- }
-
- DataView dvDomains = m_ServerAPI.GetDomainList();
- foreach(DataRowView vDr in dvDomains){
- m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
- }
- if(m_pMembers.Items.Count > 0){
- m_pDomains.SelectItemByTag(dr["DomainID"].ToString());
- m_pDomains.Enabled = false;
- }
- }
- catch(Exception x)
- {
- wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
- frm.ShowDialog(this);
- }
- }
- #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()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(wfrm_Alias));
- this.m_pOk = new LumiSoft.UI.Controls.WButton();
- this.m_pRemove = new LumiSoft.UI.Controls.WButton();
- this.m_pAdd = new LumiSoft.UI.Controls.WButton();
- this.m_pDomains = new LumiSoft.UI.Controls.WComboBox();
- this.mt_symbolAT = new LumiSoft.UI.Controls.WLabel();
- this.m_pName = new LumiSoft.UI.Controls.WEditBox();
- this.m_pDescription = new LumiSoft.UI.Controls.WEditBox();
- this.mt_name = new LumiSoft.UI.Controls.WLabel();
- this.mt_description = new LumiSoft.UI.Controls.WLabel();
- this.m_pMembers = new System.Windows.Forms.ListBox();
- this.m_pMember = new LumiSoft.UI.Controls.WEditBox();
- this.mt_member = new LumiSoft.UI.Controls.WLabel();
- this.m_pCancel = new LumiSoft.UI.Controls.WButton();
- ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pRemove)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pName)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pMember)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).BeginInit();
- this.SuspendLayout();
- //
- // m_pOk
- //
- this.m_pOk.Location = new System.Drawing.Point(280, 288);
- this.m_pOk.Name = "m_pOk";
- this.m_pOk.Size = new System.Drawing.Size(80, 24);
- this.m_pOk.TabIndex = 7;
- this.m_pOk.Text = "OK";
- this.m_pOk.UseStaticViewStyle = true;
- this.m_pOk.Click += new System.EventHandler(this.m_pOk_Click);
- //
- // m_pRemove
- //
- this.m_pRemove.Location = new System.Drawing.Point(280, 168);
- this.m_pRemove.Name = "m_pRemove";
- this.m_pRemove.Size = new System.Drawing.Size(80, 24);
- this.m_pRemove.TabIndex = 6;
- this.m_pRemove.Text = "Remove";
- this.m_pRemove.UseStaticViewStyle = true;
- this.m_pRemove.Click += new System.EventHandler(this.m_pRemove_Click);
- //
- // m_pAdd
- //
- this.m_pAdd.Location = new System.Drawing.Point(280, 136);
- this.m_pAdd.Name = "m_pAdd";
- this.m_pAdd.Size = new System.Drawing.Size(80, 24);
- this.m_pAdd.TabIndex = 5;
- this.m_pAdd.Text = "Add";
- this.m_pAdd.UseStaticViewStyle = true;
- this.m_pAdd.Click += new System.EventHandler(this.m_pAdd_Click);
- //
- // m_pDomains
- //
- this.m_pDomains.AcceptsPlussKey = true;
- this.m_pDomains.BackColor = System.Drawing.Color.White;
- this.m_pDomains.ButtonIcon = ((System.Drawing.Icon)(resources.GetObject("m_pDomains.ButtonIcon")));
- this.m_pDomains.ButtonWidth = 18;
- this.m_pDomains.DropDownWidth = 144;
- this.m_pDomains.Location = new System.Drawing.Point(216, 24);
- this.m_pDomains.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
- this.m_pDomains.MaxLength = 32767;
- this.m_pDomains.Name = "m_pDomains";
- this.m_pDomains.ReadOnly = false;
- this.m_pDomains.SelectedIndex = -1;
- this.m_pDomains.Size = new System.Drawing.Size(144, 20);
- this.m_pDomains.TabIndex = 2;
- this.m_pDomains.UseStaticViewStyle = true;
- this.m_pDomains.VisibleItems = 5;
- //
- // mt_symbolAT
- //
- this.mt_symbolAT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
- this.mt_symbolAT.Location = new System.Drawing.Point(200, 24);
- this.mt_symbolAT.Name = "mt_symbolAT";
- this.mt_symbolAT.Size = new System.Drawing.Size(16, 24);
- this.mt_symbolAT.TabIndex = 10;
- this.mt_symbolAT.Text = "@";
- this.mt_symbolAT.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- this.mt_symbolAT.UseStaticViewStyle = true;
- //
- // m_pName
- //
- this.m_pName.DecimalPlaces = 2;
- this.m_pName.DecMaxValue = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.m_pName.DecMinValue = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- -2147483648});
- this.m_pName.Lines = new string[0];
- this.m_pName.Location = new System.Drawing.Point(8, 24);
- this.m_pName.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
- this.m_pName.MaxLength = 32767;
- this.m_pName.Multiline = false;
- this.m_pName.Name = "m_pName";
- this.m_pName.PasswordChar = ' ';
- this.m_pName.ReadOnly = false;
- this.m_pName.ScrollBars = System.Windows.Forms.ScrollBars.None;
- this.m_pName.Size = new System.Drawing.Size(192, 20);
- this.m_pName.TabIndex = 1;
- this.m_pName.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.m_pName.UseStaticViewStyle = true;
- //
- // m_pDescription
- //
- this.m_pDescription.DecimalPlaces = 2;
- this.m_pDescription.DecMaxValue = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.m_pDescription.DecMinValue = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- -2147483648});
- this.m_pDescription.Lines = new string[0];
- this.m_pDescription.Location = new System.Drawing.Point(8, 64);
- this.m_pDescription.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
- this.m_pDescription.MaxLength = 32767;
- this.m_pDescription.Multiline = false;
- this.m_pDescription.Name = "m_pDescription";
- this.m_pDescription.PasswordChar = ' ';
- this.m_pDescription.ReadOnly = false;
- this.m_pDescription.ScrollBars = System.Windows.Forms.ScrollBars.None;
- this.m_pDescription.Size = new System.Drawing.Size(352, 20);
- this.m_pDescription.TabIndex = 3;
- this.m_pDescription.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.m_pDescription.UseStaticViewStyle = true;
- //
- // mt_name
- //
- this.mt_name.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
- this.mt_name.Location = new System.Drawing.Point(8, 8);
- this.mt_name.Name = "mt_name";
- this.mt_name.Size = new System.Drawing.Size(104, 16);
- this.mt_name.TabIndex = 9;
- this.mt_name.Text = "AliasName Name";
- this.mt_name.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.mt_name.UseStaticViewStyle = true;
- //
- // mt_description
- //
- this.mt_description.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
- this.mt_description.Location = new System.Drawing.Point(8, 48);
- this.mt_description.Name = "mt_description";
- this.mt_description.Size = new System.Drawing.Size(104, 16);
- this.mt_description.TabIndex = 11;
- this.mt_description.Text = "Description";
- this.mt_description.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.mt_description.UseStaticViewStyle = true;
- //
- // m_pMembers
- //
- this.m_pMembers.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.m_pMembers.Location = new System.Drawing.Point(8, 136);
- this.m_pMembers.Name = "m_pMembers";
- this.m_pMembers.Size = new System.Drawing.Size(264, 210);
- this.m_pMembers.TabIndex = 8;
- //
- // m_pMember
- //
- this.m_pMember.DecimalPlaces = 2;
- this.m_pMember.DecMaxValue = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.m_pMember.DecMinValue = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- -2147483648});
- this.m_pMember.Lines = new string[0];
- this.m_pMember.Location = new System.Drawing.Point(8, 104);
- this.m_pMember.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
- this.m_pMember.MaxLength = 32767;
- this.m_pMember.Multiline = false;
- this.m_pMember.Name = "m_pMember";
- this.m_pMember.PasswordChar = ' ';
- this.m_pMember.ReadOnly = false;
- this.m_pMember.ScrollBars = System.Windows.Forms.ScrollBars.None;
- this.m_pMember.Size = new System.Drawing.Size(192, 20);
- this.m_pMember.TabIndex = 4;
- this.m_pMember.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.m_pMember.UseStaticViewStyle = true;
- //
- // mt_member
- //
- this.mt_member.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
- this.mt_member.Location = new System.Drawing.Point(8, 88);
- this.mt_member.Name = "mt_member";
- this.mt_member.Size = new System.Drawing.Size(144, 16);
- this.mt_member.TabIndex = 12;
- this.mt_member.Text = "Member email address";
- this.mt_member.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.mt_member.UseStaticViewStyle = true;
- //
- // m_pCancel
- //
- this.m_pCancel.Location = new System.Drawing.Point(280, 320);
- this.m_pCancel.Name = "m_pCancel";
- this.m_pCancel.Size = new System.Drawing.Size(80, 24);
- this.m_pCancel.TabIndex = 0;
- this.m_pCancel.Text = "Cancel";
- this.m_pCancel.UseStaticViewStyle = true;
- this.m_pCancel.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pCancel_ButtonPressed);
- //
- // wfrm_Alias
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(370, 351);
- this.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.m_pCancel,
- this.mt_member,
- this.m_pMember,
- this.m_pOk,
- this.m_pRemove,
- this.m_pAdd,
- this.m_pDomains,
- this.mt_symbolAT,
- this.m_pName,
- this.m_pDescription,
- this.mt_name,
- this.mt_description,
- this.m_pMembers});
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "wfrm_Alias";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "AliasName Properties";
- ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pRemove)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pName)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pMember)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- #region Events handling
- #region function m_pAdd_Click
- private void m_pAdd_Click(object sender, System.EventArgs e)
- {
- string member = m_pMember.Text;
- if(member.Length == 0){
- MessageBox.Show("Member Name Cannot be Empty !!!");
- m_pMember.FlashControl();
- return;
- }
- if(member.IndexOf("<") == -1){
- member = "<" + member;
- }
- if(member.IndexOf(">") == -1){
- member += ">";
- }
- m_pMembers.Items.Add(member);
- m_pMember.Text = "";
- m_pMember.Focus();
- m_pDomains.Enabled = false;
- }
- #endregion
- #region function m_pRemove_Click
- private void m_pRemove_Click(object sender, System.EventArgs e)
- {
- if(m_pMembers.SelectedIndex > -1){
- m_pMembers.Items.RemoveAt(m_pMembers.SelectedIndex);
-
- if(m_pMembers.Items.Count == 0){
- m_pDomains.Enabled = true;
- }
- }
- }
- #endregion
- #region function m_pOk_Click
- private void m_pOk_Click(object sender, System.EventArgs e)
- {
- if(m_pName.Text.Length <= 0){
- MessageBox.Show("AliasName Name Cannot be Empty !!!");
- m_pName.FlashControl();
- return;
- }
- if(m_pMembers.Items.Count == 0){
- MessageBox.Show("Please add at least one member !!!");
- return;
- }
- try
- {
- string member = "";
- foreach(string str in m_pMembers.Items){
- member += str + ";";
- }
- // remove ";" from end
- member = member.Substring(0,member.Length-1);
-
- m_AliasName = m_pName.Text + "@" + m_pDomains.Text;
- m_Descriprion = m_pDescription.Text;
- m_Members = member;
- m_DomainID = m_pDomains.SelectedItem.Tag.ToString();
- }
- catch(Exception x)
- {
- wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
- frm.ShowDialog(this);
- }
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- #endregion
- #region function m_pCancel_ButtonPressed
- private void m_pCancel_ButtonPressed(object sender, System.EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- #endregion
- #endregion
- #region Properties Implementation
- public string AliasName
- {
- get{ return m_AliasName; }
- }
- public string Descriprion
- {
- get{ return m_Descriprion; }
- }
- public string Members
- {
- get{ return m_Members; }
- }
- public string DomainID
- {
- get{ return m_DomainID; }
- }
- #endregion
- }
- }