wfrm_Alias.cs
上传用户:horngjaan
上传日期:2009-12-12
资源大小:2882k
文件大小:17k
源码类别:

Email服务器

开发平台:

C#

  1. using System;
  2. using System.IO;
  3. using System.Drawing;
  4. using System.Collections;
  5. using System.ComponentModel;
  6. using System.Windows.Forms;
  7. using System.Data;
  8. using System.Data.SqlClient;
  9. namespace LumiSoft.MailServer
  10. {
  11. /// <summary>
  12. /// Summary description for Alias_Frm.
  13. /// </summary>
  14. public class wfrm_Alias : System.Windows.Forms.Form
  15. {
  16. private LumiSoft.UI.Controls.WButton m_pOk;
  17. private LumiSoft.UI.Controls.WButton m_pRemove;
  18. private LumiSoft.UI.Controls.WButton m_pAdd;
  19. private LumiSoft.UI.Controls.WComboBox m_pDomains;
  20. private LumiSoft.UI.Controls.WLabel mt_symbolAT;
  21. private LumiSoft.UI.Controls.WEditBox m_pDescription;
  22. private LumiSoft.UI.Controls.WLabel mt_description;
  23. private LumiSoft.UI.Controls.WEditBox m_pName;
  24. private LumiSoft.UI.Controls.WLabel mt_name;
  25. private LumiSoft.UI.Controls.WEditBox m_pMember;
  26. private LumiSoft.UI.Controls.WLabel mt_member;
  27. private System.Windows.Forms.ListBox m_pMembers;
  28. private LumiSoft.UI.Controls.WButton m_pCancel;
  29. /// <summary>
  30. /// Required designer variable.
  31. /// </summary>
  32. private System.ComponentModel.Container components = null;
  33. private ServerAPI m_ServerAPI   = null;
  34. private string    m_AliasName   = "";
  35. private string    m_Descriprion = "";
  36. private string    m_Members     = "";
  37. private string    m_DomainID    = "";
  38. /// <summary>
  39. /// Add new constructor.
  40. /// </summary>
  41. /// <param name="serverAPI"></param>
  42. /// <param name="domainID"></param>
  43. public wfrm_Alias(ServerAPI serverAPI,string domainID)
  44. {
  45. //
  46. // Required for Windows Form Designer support
  47. //
  48. InitializeComponent();
  49. //
  50. // TODO: Add any constructor code after InitializeComponent call
  51. //
  52. try
  53. {
  54. m_ServerAPI = serverAPI;
  55. DataView dvDomains = m_ServerAPI.GetDomainList();
  56. foreach(DataRowView vDr in dvDomains){
  57. m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
  58. }
  59. if(m_pDomains.Items.Count > 0){
  60. m_pDomains.SelectedIndex = 0;
  61. }
  62. if(domainID != "ALL"){
  63. m_pDomains.SelectItemByTag(domainID);
  64. }
  65. }
  66. catch(Exception x)
  67. {
  68. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  69. frm.ShowDialog(this);
  70. }
  71. }
  72. /// <summary>
  73. /// Edit constructor.
  74. /// </summary>
  75. /// <param name="serverAPI"></param>
  76. /// <param name="dr"></param>
  77. public wfrm_Alias(ServerAPI serverAPI,DataRow dr)
  78. {
  79. //
  80. // Required for Windows Form Designer support
  81. //
  82. InitializeComponent();
  83. //
  84. // TODO: Add any constructor code after InitializeComponent call
  85. //
  86. try
  87. {
  88. m_ServerAPI = serverAPI;
  89. m_pName.Text        = dr["AliasName"].ToString().Split(new char[]{'@'})[0];
  90. m_pDescription.Text = dr["Description"].ToString();
  91. string[] member = dr["AliasMembers"].ToString().Split(new char[]{';'});
  92. foreach(string adr in member){
  93. m_pMembers.Items.Add(adr);
  94. }
  95. DataView dvDomains = m_ServerAPI.GetDomainList();
  96. foreach(DataRowView vDr in dvDomains){
  97. m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
  98. }
  99. if(m_pMembers.Items.Count > 0){
  100. m_pDomains.SelectItemByTag(dr["DomainID"].ToString());
  101. m_pDomains.Enabled = false;
  102. }
  103. }
  104. catch(Exception x)
  105. {
  106. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  107. frm.ShowDialog(this);
  108. }
  109. }
  110. #region function Dispose
  111. /// <summary>
  112. /// Clean up any resources being used.
  113. /// </summary>
  114. protected override void Dispose( bool disposing )
  115. {
  116. if( disposing )
  117. {
  118. if(components != null)
  119. {
  120. components.Dispose();
  121. }
  122. }
  123. base.Dispose( disposing );
  124. }
  125. #endregion
  126. #region Windows Form Designer generated code
  127. /// <summary>
  128. /// Required method for Designer support - do not modify
  129. /// the contents of this method with the code editor.
  130. /// </summary>
  131. private void InitializeComponent()
  132. {
  133. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(wfrm_Alias));
  134. this.m_pOk = new LumiSoft.UI.Controls.WButton();
  135. this.m_pRemove = new LumiSoft.UI.Controls.WButton();
  136. this.m_pAdd = new LumiSoft.UI.Controls.WButton();
  137. this.m_pDomains = new LumiSoft.UI.Controls.WComboBox();
  138. this.mt_symbolAT = new LumiSoft.UI.Controls.WLabel();
  139. this.m_pName = new LumiSoft.UI.Controls.WEditBox();
  140. this.m_pDescription = new LumiSoft.UI.Controls.WEditBox();
  141. this.mt_name = new LumiSoft.UI.Controls.WLabel();
  142. this.mt_description = new LumiSoft.UI.Controls.WLabel();
  143. this.m_pMembers = new System.Windows.Forms.ListBox();
  144. this.m_pMember = new LumiSoft.UI.Controls.WEditBox();
  145. this.mt_member = new LumiSoft.UI.Controls.WLabel();
  146. this.m_pCancel = new LumiSoft.UI.Controls.WButton();
  147. ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).BeginInit();
  148. ((System.ComponentModel.ISupportInitialize)(this.m_pRemove)).BeginInit();
  149. ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).BeginInit();
  150. ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).BeginInit();
  151. ((System.ComponentModel.ISupportInitialize)(this.m_pName)).BeginInit();
  152. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).BeginInit();
  153. ((System.ComponentModel.ISupportInitialize)(this.m_pMember)).BeginInit();
  154. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).BeginInit();
  155. this.SuspendLayout();
  156. // 
  157. // m_pOk
  158. // 
  159. this.m_pOk.Location = new System.Drawing.Point(280, 288);
  160. this.m_pOk.Name = "m_pOk";
  161. this.m_pOk.Size = new System.Drawing.Size(80, 24);
  162. this.m_pOk.TabIndex = 7;
  163. this.m_pOk.Text = "OK";
  164. this.m_pOk.UseStaticViewStyle = true;
  165. this.m_pOk.Click += new System.EventHandler(this.m_pOk_Click);
  166. // 
  167. // m_pRemove
  168. // 
  169. this.m_pRemove.Location = new System.Drawing.Point(280, 168);
  170. this.m_pRemove.Name = "m_pRemove";
  171. this.m_pRemove.Size = new System.Drawing.Size(80, 24);
  172. this.m_pRemove.TabIndex = 6;
  173. this.m_pRemove.Text = "Remove";
  174. this.m_pRemove.UseStaticViewStyle = true;
  175. this.m_pRemove.Click += new System.EventHandler(this.m_pRemove_Click);
  176. // 
  177. // m_pAdd
  178. // 
  179. this.m_pAdd.Location = new System.Drawing.Point(280, 136);
  180. this.m_pAdd.Name = "m_pAdd";
  181. this.m_pAdd.Size = new System.Drawing.Size(80, 24);
  182. this.m_pAdd.TabIndex = 5;
  183. this.m_pAdd.Text = "Add";
  184. this.m_pAdd.UseStaticViewStyle = true;
  185. this.m_pAdd.Click += new System.EventHandler(this.m_pAdd_Click);
  186. // 
  187. // m_pDomains
  188. // 
  189. this.m_pDomains.AcceptsPlussKey = true;
  190. this.m_pDomains.BackColor = System.Drawing.Color.White;
  191. this.m_pDomains.ButtonIcon = ((System.Drawing.Icon)(resources.GetObject("m_pDomains.ButtonIcon")));
  192. this.m_pDomains.ButtonWidth = 18;
  193. this.m_pDomains.DropDownWidth = 144;
  194. this.m_pDomains.Location = new System.Drawing.Point(216, 24);
  195. this.m_pDomains.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  196. this.m_pDomains.MaxLength = 32767;
  197. this.m_pDomains.Name = "m_pDomains";
  198. this.m_pDomains.ReadOnly = false;
  199. this.m_pDomains.SelectedIndex = -1;
  200. this.m_pDomains.Size = new System.Drawing.Size(144, 20);
  201. this.m_pDomains.TabIndex = 2;
  202. this.m_pDomains.UseStaticViewStyle = true;
  203. this.m_pDomains.VisibleItems = 5;
  204. // 
  205. // mt_symbolAT
  206. // 
  207. this.mt_symbolAT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  208. this.mt_symbolAT.Location = new System.Drawing.Point(200, 24);
  209. this.mt_symbolAT.Name = "mt_symbolAT";
  210. this.mt_symbolAT.Size = new System.Drawing.Size(16, 24);
  211. this.mt_symbolAT.TabIndex = 10;
  212. this.mt_symbolAT.Text = "@";
  213. this.mt_symbolAT.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
  214. this.mt_symbolAT.UseStaticViewStyle = true;
  215. // 
  216. // m_pName
  217. // 
  218. this.m_pName.DecimalPlaces = 2;
  219. this.m_pName.DecMaxValue = new System.Decimal(new int[] {
  220. 999999999,
  221. 0,
  222. 0,
  223. 0});
  224. this.m_pName.DecMinValue = new System.Decimal(new int[] {
  225. 999999999,
  226. 0,
  227. 0,
  228. -2147483648});
  229. this.m_pName.Lines = new string[0];
  230. this.m_pName.Location = new System.Drawing.Point(8, 24);
  231. this.m_pName.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  232. this.m_pName.MaxLength = 32767;
  233. this.m_pName.Multiline = false;
  234. this.m_pName.Name = "m_pName";
  235. this.m_pName.PasswordChar = '';
  236. this.m_pName.ReadOnly = false;
  237. this.m_pName.ScrollBars = System.Windows.Forms.ScrollBars.None;
  238. this.m_pName.Size = new System.Drawing.Size(192, 20);
  239. this.m_pName.TabIndex = 1;
  240. this.m_pName.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  241. this.m_pName.UseStaticViewStyle = true;
  242. // 
  243. // m_pDescription
  244. // 
  245. this.m_pDescription.DecimalPlaces = 2;
  246. this.m_pDescription.DecMaxValue = new System.Decimal(new int[] {
  247.    999999999,
  248.    0,
  249.    0,
  250.    0});
  251. this.m_pDescription.DecMinValue = new System.Decimal(new int[] {
  252.    999999999,
  253.    0,
  254.    0,
  255.    -2147483648});
  256. this.m_pDescription.Lines = new string[0];
  257. this.m_pDescription.Location = new System.Drawing.Point(8, 64);
  258. this.m_pDescription.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  259. this.m_pDescription.MaxLength = 32767;
  260. this.m_pDescription.Multiline = false;
  261. this.m_pDescription.Name = "m_pDescription";
  262. this.m_pDescription.PasswordChar = '';
  263. this.m_pDescription.ReadOnly = false;
  264. this.m_pDescription.ScrollBars = System.Windows.Forms.ScrollBars.None;
  265. this.m_pDescription.Size = new System.Drawing.Size(352, 20);
  266. this.m_pDescription.TabIndex = 3;
  267. this.m_pDescription.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  268. this.m_pDescription.UseStaticViewStyle = true;
  269. // 
  270. // mt_name
  271. // 
  272. this.mt_name.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  273. this.mt_name.Location = new System.Drawing.Point(8, 8);
  274. this.mt_name.Name = "mt_name";
  275. this.mt_name.Size = new System.Drawing.Size(104, 16);
  276. this.mt_name.TabIndex = 9;
  277. this.mt_name.Text = "AliasName Name";
  278. this.mt_name.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  279. this.mt_name.UseStaticViewStyle = true;
  280. // 
  281. // mt_description
  282. // 
  283. this.mt_description.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  284. this.mt_description.Location = new System.Drawing.Point(8, 48);
  285. this.mt_description.Name = "mt_description";
  286. this.mt_description.Size = new System.Drawing.Size(104, 16);
  287. this.mt_description.TabIndex = 11;
  288. this.mt_description.Text = "Description";
  289. this.mt_description.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  290. this.mt_description.UseStaticViewStyle = true;
  291. // 
  292. // m_pMembers
  293. // 
  294. this.m_pMembers.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  295. this.m_pMembers.Location = new System.Drawing.Point(8, 136);
  296. this.m_pMembers.Name = "m_pMembers";
  297. this.m_pMembers.Size = new System.Drawing.Size(264, 210);
  298. this.m_pMembers.TabIndex = 8;
  299. // 
  300. // m_pMember
  301. // 
  302. this.m_pMember.DecimalPlaces = 2;
  303. this.m_pMember.DecMaxValue = new System.Decimal(new int[] {
  304.   999999999,
  305.   0,
  306.   0,
  307.   0});
  308. this.m_pMember.DecMinValue = new System.Decimal(new int[] {
  309.   999999999,
  310.   0,
  311.   0,
  312.   -2147483648});
  313. this.m_pMember.Lines = new string[0];
  314. this.m_pMember.Location = new System.Drawing.Point(8, 104);
  315. this.m_pMember.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  316. this.m_pMember.MaxLength = 32767;
  317. this.m_pMember.Multiline = false;
  318. this.m_pMember.Name = "m_pMember";
  319. this.m_pMember.PasswordChar = '';
  320. this.m_pMember.ReadOnly = false;
  321. this.m_pMember.ScrollBars = System.Windows.Forms.ScrollBars.None;
  322. this.m_pMember.Size = new System.Drawing.Size(192, 20);
  323. this.m_pMember.TabIndex = 4;
  324. this.m_pMember.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  325. this.m_pMember.UseStaticViewStyle = true;
  326. // 
  327. // mt_member
  328. // 
  329. this.mt_member.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  330. this.mt_member.Location = new System.Drawing.Point(8, 88);
  331. this.mt_member.Name = "mt_member";
  332. this.mt_member.Size = new System.Drawing.Size(144, 16);
  333. this.mt_member.TabIndex = 12;
  334. this.mt_member.Text = "Member email address";
  335. this.mt_member.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  336. this.mt_member.UseStaticViewStyle = true;
  337. // 
  338. // m_pCancel
  339. // 
  340. this.m_pCancel.Location = new System.Drawing.Point(280, 320);
  341. this.m_pCancel.Name = "m_pCancel";
  342. this.m_pCancel.Size = new System.Drawing.Size(80, 24);
  343. this.m_pCancel.TabIndex = 0;
  344. this.m_pCancel.Text = "Cancel";
  345. this.m_pCancel.UseStaticViewStyle = true;
  346. this.m_pCancel.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pCancel_ButtonPressed);
  347. // 
  348. // wfrm_Alias
  349. // 
  350. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  351. this.ClientSize = new System.Drawing.Size(370, 351);
  352. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  353.   this.m_pCancel,
  354.   this.mt_member,
  355.   this.m_pMember,
  356.   this.m_pOk,
  357.   this.m_pRemove,
  358.   this.m_pAdd,
  359.   this.m_pDomains,
  360.   this.mt_symbolAT,
  361.   this.m_pName,
  362.   this.m_pDescription,
  363.   this.mt_name,
  364.   this.mt_description,
  365.   this.m_pMembers});
  366. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  367. this.MaximizeBox = false;
  368. this.MinimizeBox = false;
  369. this.Name = "wfrm_Alias";
  370. this.ShowInTaskbar = false;
  371. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  372. this.Text = "AliasName Properties";
  373. ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).EndInit();
  374. ((System.ComponentModel.ISupportInitialize)(this.m_pRemove)).EndInit();
  375. ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).EndInit();
  376. ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).EndInit();
  377. ((System.ComponentModel.ISupportInitialize)(this.m_pName)).EndInit();
  378. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).EndInit();
  379. ((System.ComponentModel.ISupportInitialize)(this.m_pMember)).EndInit();
  380. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).EndInit();
  381. this.ResumeLayout(false);
  382. }
  383. #endregion
  384. #region Events handling
  385. #region function m_pAdd_Click
  386. private void m_pAdd_Click(object sender, System.EventArgs e)
  387. {
  388. string member = m_pMember.Text;
  389. if(member.Length == 0){
  390. MessageBox.Show("Member Name Cannot be Empty !!!");
  391. m_pMember.FlashControl();
  392. return;
  393. }
  394. if(member.IndexOf("<") == -1){
  395. member = "<" + member;
  396. }
  397. if(member.IndexOf(">") == -1){
  398. member += ">";
  399. }
  400. m_pMembers.Items.Add(member);
  401. m_pMember.Text = "";
  402. m_pMember.Focus();
  403. m_pDomains.Enabled = false;
  404. }
  405. #endregion
  406. #region function m_pRemove_Click
  407. private void m_pRemove_Click(object sender, System.EventArgs e)
  408. {
  409. if(m_pMembers.SelectedIndex > -1){
  410. m_pMembers.Items.RemoveAt(m_pMembers.SelectedIndex);
  411. if(m_pMembers.Items.Count == 0){
  412. m_pDomains.Enabled = true;
  413. }
  414. }
  415. }
  416. #endregion
  417. #region function m_pOk_Click
  418. private void m_pOk_Click(object sender, System.EventArgs e)
  419. {
  420. if(m_pName.Text.Length <= 0){
  421. MessageBox.Show("AliasName Name Cannot be Empty !!!");
  422. m_pName.FlashControl();
  423. return;
  424. }
  425. if(m_pMembers.Items.Count == 0){
  426. MessageBox.Show("Please add at least one member !!!");
  427. return;
  428. }
  429. try
  430. {
  431. string member = "";
  432. foreach(string str in m_pMembers.Items){
  433. member += str + ";";
  434. }
  435. // remove ";" from end
  436. member = member.Substring(0,member.Length-1);
  437. m_AliasName   = m_pName.Text + "@" + m_pDomains.Text;
  438. m_Descriprion = m_pDescription.Text;
  439. m_Members     = member;
  440. m_DomainID    = m_pDomains.SelectedItem.Tag.ToString();
  441. }
  442. catch(Exception x)
  443. {
  444. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  445. frm.ShowDialog(this);
  446. }
  447. this.DialogResult = DialogResult.OK;
  448. this.Close();
  449. }
  450. #endregion
  451. #region function m_pCancel_ButtonPressed
  452. private void m_pCancel_ButtonPressed(object sender, System.EventArgs e)
  453. {
  454. this.DialogResult = DialogResult.Cancel;
  455. this.Close();
  456. }
  457. #endregion
  458. #endregion
  459. #region Properties Implementation
  460. public string AliasName
  461. {
  462. get{ return m_AliasName; }
  463. }
  464. public string Descriprion
  465. {
  466. get{ return m_Descriprion; }
  467. }
  468. public string Members
  469. {
  470. get{ return m_Members; }
  471. }
  472. public string DomainID
  473. {
  474. get{ return m_DomainID; }
  475. }
  476. #endregion
  477. }
  478. }