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

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 User_Frm.
  13. /// </summary>
  14. public class wfrm_User : System.Windows.Forms.Form
  15. {
  16. /// <summary>
  17. /// Required designer variable.
  18. /// </summary>
  19. private System.ComponentModel.Container components = null;
  20. private System.Windows.Forms.ListBox m_pAddresses;
  21. private LumiSoft.UI.Controls.WLabel mt_fullname;
  22. private LumiSoft.UI.Controls.WLabel mt_username;
  23. private LumiSoft.UI.Controls.WLabel mt_password;
  24. private LumiSoft.UI.Controls.WLabel mt_description;
  25. private LumiSoft.UI.Controls.WLabel mt_Emails;
  26. private LumiSoft.UI.Controls.WLabel mt_symbolAT;
  27. private LumiSoft.UI.Controls.WComboBox m_pDomains;
  28. private LumiSoft.UI.Controls.WEditBox m_pFullName;
  29. private LumiSoft.UI.Controls.WEditBox m_pLogOnName;
  30. private LumiSoft.UI.Controls.WEditBox m_pPassword;
  31. private LumiSoft.UI.Controls.WEditBox m_pDescription;
  32. private LumiSoft.UI.Controls.WEditBox m_pAddress;
  33. private LumiSoft.UI.Controls.WButton m_pGenerate;
  34. private LumiSoft.UI.Controls.WButton m_pAdd;
  35. private LumiSoft.UI.Controls.WButton m_pRemove;
  36. private LumiSoft.UI.Controls.WLabel mt_mailboxsize;
  37. private LumiSoft.UI.Controls.WLabel mt_userenabled;
  38. private LumiSoft.UI.Controls.WLabel wLabel3;
  39. private LumiSoft.UI.Controls.WSpinEdit m_pMailboxSize;
  40. private LumiSoft.UI.Controls.WCheckBox.WCheckBox m_pUserEnabled;
  41. private LumiSoft.UI.Controls.WButton m_pOk;
  42. private LumiSoft.UI.Controls.WButton m_pCancel;
  43. private ServerAPI m_ServerAPI = null;
  44. private DataRow drUser        = null;
  45. private bool    m_New         = false;
  46. private string  m_FullName    = "";
  47. private string  m_UserName    = "";
  48. private string  m_Password    = "";
  49. private string  m_Descript    = "";
  50. private string  m_Emailss      = "";
  51. private string  m_DomainID    = "";
  52. private int     m_MailboxSize = 20;
  53. public wfrm_User(ServerAPI serverAPI,string domainID)
  54. {
  55. //
  56. // Required for Windows Form Designer support
  57. //
  58. InitializeComponent();
  59. //
  60. // TODO: Add any constructor code after InitializeComponent call
  61. //
  62. try
  63. {
  64. m_ServerAPI = serverAPI;
  65.  
  66. DataView dvDomains = m_ServerAPI.GetDomainList();
  67. foreach(DataRowView vDr in dvDomains){
  68. m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
  69. }
  70. if(m_pDomains.Items.Count > 0){
  71. m_pDomains.SelectedIndex = 0;
  72. }
  73. if(domainID != "ALL"){
  74. m_pDomains.SelectItemByTag(domainID);
  75. }
  76. m_New = true;
  77. }
  78. catch(Exception x)
  79. {
  80. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  81. frm.ShowDialog(this);
  82. }
  83. }
  84. public wfrm_User(ServerAPI serverAPI,DataRow dr)
  85. {
  86. //
  87. // Required for Windows Form Designer support
  88. //
  89. InitializeComponent();
  90. //
  91. // TODO: Add any constructor code after InitializeComponent call
  92. //
  93. try
  94. {
  95. m_ServerAPI = serverAPI;
  96. drUser      = dr;
  97. m_pFullName.Text    = dr["FullName"].ToString();
  98. m_pLogOnName.Text   = dr["UserName"].ToString();
  99. m_pPassword.Text    = dr["Password"].ToString();
  100. m_pDescription.Text = dr["Description"].ToString();
  101. m_pMailboxSize.Text = dr["Mailbox_Size"].ToString();
  102. string[] addresses = dr["Emails"].ToString().Split(new char[]{';'});
  103. foreach(string adr in addresses){
  104. m_pAddresses.Items.Add(adr);
  105. }
  106. DataView dvDomains = m_ServerAPI.GetDomainList();
  107. foreach(DataRowView vDr in dvDomains){
  108. m_pDomains.Items.Add(vDr["DomainName"].ToString(),vDr["DomainID"].ToString());
  109. }
  110. if(m_pAddresses.Items.Count > 0){
  111. m_pDomains.SelectItemByTag(dr["DomainID"].ToString());
  112. m_pDomains.Enabled = false;
  113. }
  114. }
  115. catch(Exception x)
  116. {
  117. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  118. frm.ShowDialog(this);
  119. }
  120. }
  121. #region function Dispose
  122. /// <summary>
  123. /// Clean up any resources being used.
  124. /// </summary>
  125. protected override void Dispose( bool disposing )
  126. {
  127. if( disposing )
  128. {
  129. if(components != null)
  130. {
  131. components.Dispose();
  132. }
  133. }
  134. base.Dispose( disposing );
  135. }
  136. #endregion
  137. #region Windows Form Designer generated code
  138. /// <summary>
  139. /// Required method for Designer support - do not modify
  140. /// the contents of this method with the code editor.
  141. /// </summary>
  142. private void InitializeComponent()
  143. {
  144. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(wfrm_User));
  145. this.m_pAddresses = new System.Windows.Forms.ListBox();
  146. this.mt_fullname = new LumiSoft.UI.Controls.WLabel();
  147. this.mt_username = new LumiSoft.UI.Controls.WLabel();
  148. this.mt_password = new LumiSoft.UI.Controls.WLabel();
  149. this.mt_description = new LumiSoft.UI.Controls.WLabel();
  150. this.mt_Emails = new LumiSoft.UI.Controls.WLabel();
  151. this.m_pFullName = new LumiSoft.UI.Controls.WEditBox();
  152. this.m_pLogOnName = new LumiSoft.UI.Controls.WEditBox();
  153. this.m_pPassword = new LumiSoft.UI.Controls.WEditBox();
  154. this.m_pDescription = new LumiSoft.UI.Controls.WEditBox();
  155. this.m_pAddress = new LumiSoft.UI.Controls.WEditBox();
  156. this.mt_symbolAT = new LumiSoft.UI.Controls.WLabel();
  157. this.m_pDomains = new LumiSoft.UI.Controls.WComboBox();
  158. this.m_pGenerate = new LumiSoft.UI.Controls.WButton();
  159. this.m_pAdd = new LumiSoft.UI.Controls.WButton();
  160. this.m_pRemove = new LumiSoft.UI.Controls.WButton();
  161. this.m_pOk = new LumiSoft.UI.Controls.WButton();
  162. this.mt_mailboxsize = new LumiSoft.UI.Controls.WLabel();
  163. this.mt_userenabled = new LumiSoft.UI.Controls.WLabel();
  164. this.wLabel3 = new LumiSoft.UI.Controls.WLabel();
  165. this.m_pMailboxSize = new LumiSoft.UI.Controls.WSpinEdit();
  166. this.m_pUserEnabled = new LumiSoft.UI.Controls.WCheckBox.WCheckBox();
  167. this.m_pCancel = new LumiSoft.UI.Controls.WButton();
  168. ((System.ComponentModel.ISupportInitialize)(this.m_pFullName)).BeginInit();
  169. ((System.ComponentModel.ISupportInitialize)(this.m_pLogOnName)).BeginInit();
  170. ((System.ComponentModel.ISupportInitialize)(this.m_pPassword)).BeginInit();
  171. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).BeginInit();
  172. ((System.ComponentModel.ISupportInitialize)(this.m_pAddress)).BeginInit();
  173. ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).BeginInit();
  174. ((System.ComponentModel.ISupportInitialize)(this.m_pGenerate)).BeginInit();
  175. ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).BeginInit();
  176. ((System.ComponentModel.ISupportInitialize)(this.m_pRemove)).BeginInit();
  177. ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).BeginInit();
  178. ((System.ComponentModel.ISupportInitialize)(this.m_pMailboxSize)).BeginInit();
  179. ((System.ComponentModel.ISupportInitialize)(this.m_pUserEnabled)).BeginInit();
  180. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).BeginInit();
  181. this.SuspendLayout();
  182. // 
  183. // m_pAddresses
  184. // 
  185. this.m_pAddresses.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  186. this.m_pAddresses.Location = new System.Drawing.Point(8, 216);
  187. this.m_pAddresses.Name = "m_pAddresses";
  188. this.m_pAddresses.Size = new System.Drawing.Size(264, 145);
  189. this.m_pAddresses.TabIndex = 13;
  190. // 
  191. // mt_fullname
  192. // 
  193. this.mt_fullname.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  194. this.mt_fullname.Location = new System.Drawing.Point(8, 8);
  195. this.mt_fullname.Name = "mt_fullname";
  196. this.mt_fullname.Size = new System.Drawing.Size(104, 16);
  197. this.mt_fullname.TabIndex = 14;
  198. this.mt_fullname.Text = "Full Name";
  199. this.mt_fullname.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  200. this.mt_fullname.UseStaticViewStyle = true;
  201. // 
  202. // mt_username
  203. // 
  204. this.mt_username.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  205. this.mt_username.Location = new System.Drawing.Point(8, 48);
  206. this.mt_username.Name = "mt_username";
  207. this.mt_username.Size = new System.Drawing.Size(104, 16);
  208. this.mt_username.TabIndex = 15;
  209. this.mt_username.Text = "User Name";
  210. this.mt_username.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  211. this.mt_username.UseStaticViewStyle = true;
  212. // 
  213. // mt_password
  214. // 
  215. this.mt_password.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  216. this.mt_password.Location = new System.Drawing.Point(120, 48);
  217. this.mt_password.Name = "mt_password";
  218. this.mt_password.Size = new System.Drawing.Size(104, 16);
  219. this.mt_password.TabIndex = 16;
  220. this.mt_password.Text = "Password";
  221. this.mt_password.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  222. this.mt_password.UseStaticViewStyle = true;
  223. // 
  224. // mt_description
  225. // 
  226. this.mt_description.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  227. this.mt_description.Location = new System.Drawing.Point(8, 88);
  228. this.mt_description.Name = "mt_description";
  229. this.mt_description.Size = new System.Drawing.Size(104, 16);
  230. this.mt_description.TabIndex = 17;
  231. this.mt_description.Text = "Description";
  232. this.mt_description.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  233. this.mt_description.UseStaticViewStyle = true;
  234. // 
  235. // mt_Emails
  236. // 
  237. this.mt_Emails.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  238. this.mt_Emails.Location = new System.Drawing.Point(8, 168);
  239. this.mt_Emails.Name = "mt_Emails";
  240. this.mt_Emails.Size = new System.Drawing.Size(104, 16);
  241. this.mt_Emails.TabIndex = 19;
  242. this.mt_Emails.Text = "E-mail Address";
  243. this.mt_Emails.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  244. this.mt_Emails.UseStaticViewStyle = true;
  245. // 
  246. // m_pFullName
  247. // 
  248. this.m_pFullName.DecimalPlaces = 2;
  249. this.m_pFullName.DecMaxValue = new System.Decimal(new int[] {
  250. 999999999,
  251. 0,
  252. 0,
  253. 0});
  254. this.m_pFullName.DecMinValue = new System.Decimal(new int[] {
  255. 999999999,
  256. 0,
  257. 0,
  258. -2147483648});
  259. this.m_pFullName.Lines = new string[0];
  260. this.m_pFullName.Location = new System.Drawing.Point(8, 24);
  261. this.m_pFullName.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  262. this.m_pFullName.MaxLength = 32767;
  263. this.m_pFullName.Multiline = false;
  264. this.m_pFullName.Name = "m_pFullName";
  265. this.m_pFullName.PasswordChar = '';
  266. this.m_pFullName.ReadOnly = false;
  267. this.m_pFullName.ScrollBars = System.Windows.Forms.ScrollBars.None;
  268. this.m_pFullName.Size = new System.Drawing.Size(216, 20);
  269. this.m_pFullName.TabIndex = 1;
  270. this.m_pFullName.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  271. this.m_pFullName.UseStaticViewStyle = true;
  272. // 
  273. // m_pLogOnName
  274. // 
  275. this.m_pLogOnName.DecimalPlaces = 2;
  276. this.m_pLogOnName.DecMaxValue = new System.Decimal(new int[] {
  277.  999999999,
  278.  0,
  279.  0,
  280.  0});
  281. this.m_pLogOnName.DecMinValue = new System.Decimal(new int[] {
  282.  999999999,
  283.  0,
  284.  0,
  285.  -2147483648});
  286. this.m_pLogOnName.Lines = new string[0];
  287. this.m_pLogOnName.Location = new System.Drawing.Point(8, 64);
  288. this.m_pLogOnName.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  289. this.m_pLogOnName.MaxLength = 32767;
  290. this.m_pLogOnName.Multiline = false;
  291. this.m_pLogOnName.Name = "m_pLogOnName";
  292. this.m_pLogOnName.PasswordChar = '';
  293. this.m_pLogOnName.ReadOnly = false;
  294. this.m_pLogOnName.ScrollBars = System.Windows.Forms.ScrollBars.None;
  295. this.m_pLogOnName.Size = new System.Drawing.Size(104, 20);
  296. this.m_pLogOnName.TabIndex = 2;
  297. this.m_pLogOnName.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  298. this.m_pLogOnName.UseStaticViewStyle = true;
  299. // 
  300. // m_pPassword
  301. // 
  302. this.m_pPassword.DecimalPlaces = 2;
  303. this.m_pPassword.DecMaxValue = new System.Decimal(new int[] {
  304. 999999999,
  305. 0,
  306. 0,
  307. 0});
  308. this.m_pPassword.DecMinValue = new System.Decimal(new int[] {
  309. 999999999,
  310. 0,
  311. 0,
  312. -2147483648});
  313. this.m_pPassword.Lines = new string[0];
  314. this.m_pPassword.Location = new System.Drawing.Point(120, 64);
  315. this.m_pPassword.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  316. this.m_pPassword.MaxLength = 32767;
  317. this.m_pPassword.Multiline = false;
  318. this.m_pPassword.Name = "m_pPassword";
  319. this.m_pPassword.PasswordChar = '';
  320. this.m_pPassword.ReadOnly = false;
  321. this.m_pPassword.ScrollBars = System.Windows.Forms.ScrollBars.None;
  322. this.m_pPassword.Size = new System.Drawing.Size(104, 20);
  323. this.m_pPassword.TabIndex = 3;
  324. this.m_pPassword.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  325. this.m_pPassword.UseStaticViewStyle = true;
  326. // 
  327. // m_pDescription
  328. // 
  329. this.m_pDescription.DecimalPlaces = 2;
  330. this.m_pDescription.DecMaxValue = new System.Decimal(new int[] {
  331.    999999999,
  332.    0,
  333.    0,
  334.    0});
  335. this.m_pDescription.DecMinValue = new System.Decimal(new int[] {
  336.    999999999,
  337.    0,
  338.    0,
  339.    -2147483648});
  340. this.m_pDescription.Lines = new string[0];
  341. this.m_pDescription.Location = new System.Drawing.Point(8, 104);
  342. this.m_pDescription.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  343. this.m_pDescription.MaxLength = 32767;
  344. this.m_pDescription.Multiline = false;
  345. this.m_pDescription.Name = "m_pDescription";
  346. this.m_pDescription.PasswordChar = '';
  347. this.m_pDescription.ReadOnly = false;
  348. this.m_pDescription.ScrollBars = System.Windows.Forms.ScrollBars.None;
  349. this.m_pDescription.Size = new System.Drawing.Size(352, 20);
  350. this.m_pDescription.TabIndex = 5;
  351. this.m_pDescription.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  352. this.m_pDescription.UseStaticViewStyle = true;
  353. // 
  354. // m_pAddress
  355. // 
  356. this.m_pAddress.DecimalPlaces = 2;
  357. this.m_pAddress.DecMaxValue = new System.Decimal(new int[] {
  358.    999999999,
  359.    0,
  360.    0,
  361.    0});
  362. this.m_pAddress.DecMinValue = new System.Decimal(new int[] {
  363.    999999999,
  364.    0,
  365.    0,
  366.    -2147483648});
  367. this.m_pAddress.Lines = new string[0];
  368. this.m_pAddress.Location = new System.Drawing.Point(8, 184);
  369. this.m_pAddress.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  370. this.m_pAddress.MaxLength = 32767;
  371. this.m_pAddress.Multiline = false;
  372. this.m_pAddress.Name = "m_pAddress";
  373. this.m_pAddress.PasswordChar = '';
  374. this.m_pAddress.ReadOnly = false;
  375. this.m_pAddress.ScrollBars = System.Windows.Forms.ScrollBars.None;
  376. this.m_pAddress.Size = new System.Drawing.Size(192, 20);
  377. this.m_pAddress.TabIndex = 8;
  378. this.m_pAddress.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  379. this.m_pAddress.UseStaticViewStyle = true;
  380. // 
  381. // mt_symbolAT
  382. // 
  383. this.mt_symbolAT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  384. this.mt_symbolAT.Location = new System.Drawing.Point(200, 184);
  385. this.mt_symbolAT.Name = "mt_symbolAT";
  386. this.mt_symbolAT.Size = new System.Drawing.Size(16, 24);
  387. this.mt_symbolAT.TabIndex = 22;
  388. this.mt_symbolAT.Text = "@";
  389. this.mt_symbolAT.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
  390. this.mt_symbolAT.UseStaticViewStyle = true;
  391. // 
  392. // m_pDomains
  393. // 
  394. this.m_pDomains.AcceptsPlussKey = true;
  395. this.m_pDomains.BackColor = System.Drawing.Color.White;
  396. this.m_pDomains.ButtonIcon = ((System.Drawing.Icon)(resources.GetObject("m_pDomains.ButtonIcon")));
  397. this.m_pDomains.ButtonWidth = 18;
  398. this.m_pDomains.DropDownWidth = 144;
  399. this.m_pDomains.Location = new System.Drawing.Point(216, 184);
  400. this.m_pDomains.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  401. this.m_pDomains.MaxLength = 32767;
  402. this.m_pDomains.Name = "m_pDomains";
  403. this.m_pDomains.ReadOnly = false;
  404. this.m_pDomains.SelectedIndex = -1;
  405. this.m_pDomains.Size = new System.Drawing.Size(144, 20);
  406. this.m_pDomains.TabIndex = 9;
  407. this.m_pDomains.UseStaticViewStyle = true;
  408. this.m_pDomains.VisibleItems = 5;
  409. // 
  410. // m_pGenerate
  411. // 
  412. this.m_pGenerate.Location = new System.Drawing.Point(232, 64);
  413. this.m_pGenerate.Name = "m_pGenerate";
  414. this.m_pGenerate.Size = new System.Drawing.Size(128, 24);
  415. this.m_pGenerate.TabIndex = 4;
  416. this.m_pGenerate.Text = "Generate Password";
  417. this.m_pGenerate.UseStaticViewStyle = true;
  418. this.m_pGenerate.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pGenerate_Click);
  419. // 
  420. // m_pAdd
  421. // 
  422. this.m_pAdd.Location = new System.Drawing.Point(280, 216);
  423. this.m_pAdd.Name = "m_pAdd";
  424. this.m_pAdd.Size = new System.Drawing.Size(80, 24);
  425. this.m_pAdd.TabIndex = 10;
  426. this.m_pAdd.Text = "Add";
  427. this.m_pAdd.UseStaticViewStyle = true;
  428. this.m_pAdd.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pAdd_Click);
  429. // 
  430. // m_pRemove
  431. // 
  432. this.m_pRemove.Location = new System.Drawing.Point(280, 248);
  433. this.m_pRemove.Name = "m_pRemove";
  434. this.m_pRemove.Size = new System.Drawing.Size(80, 24);
  435. this.m_pRemove.TabIndex = 11;
  436. this.m_pRemove.Text = "Remove";
  437. this.m_pRemove.UseStaticViewStyle = true;
  438. this.m_pRemove.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pRemove_Click);
  439. // 
  440. // m_pOk
  441. // 
  442. this.m_pOk.Location = new System.Drawing.Point(280, 304);
  443. this.m_pOk.Name = "m_pOk";
  444. this.m_pOk.Size = new System.Drawing.Size(80, 24);
  445. this.m_pOk.TabIndex = 12;
  446. this.m_pOk.Text = "OK";
  447. this.m_pOk.UseStaticViewStyle = true;
  448. this.m_pOk.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.n_pOk_Click);
  449. // 
  450. // mt_mailboxsize
  451. // 
  452. this.mt_mailboxsize.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  453. this.mt_mailboxsize.Location = new System.Drawing.Point(8, 136);
  454. this.mt_mailboxsize.Name = "mt_mailboxsize";
  455. this.mt_mailboxsize.Size = new System.Drawing.Size(112, 24);
  456. this.mt_mailboxsize.TabIndex = 18;
  457. this.mt_mailboxsize.Text = "Max. Mailbox Size";
  458. this.mt_mailboxsize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
  459. this.mt_mailboxsize.UseStaticViewStyle = true;
  460. // 
  461. // mt_userenabled
  462. // 
  463. this.mt_userenabled.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  464. this.mt_userenabled.Location = new System.Drawing.Point(224, 136);
  465. this.mt_userenabled.Name = "mt_userenabled";
  466. this.mt_userenabled.Size = new System.Drawing.Size(104, 24);
  467. this.mt_userenabled.TabIndex = 21;
  468. this.mt_userenabled.Text = "User Enabled";
  469. this.mt_userenabled.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
  470. this.mt_userenabled.UseStaticViewStyle = true;
  471. // 
  472. // wLabel3
  473. // 
  474. this.wLabel3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  475. this.wLabel3.Location = new System.Drawing.Point(176, 136);
  476. this.wLabel3.Name = "wLabel3";
  477. this.wLabel3.Size = new System.Drawing.Size(40, 24);
  478. this.wLabel3.TabIndex = 20;
  479. this.wLabel3.Text = "MB";
  480. this.wLabel3.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  481. this.wLabel3.UseStaticViewStyle = true;
  482. // 
  483. // m_pMailboxSize
  484. // 
  485. this.m_pMailboxSize.BackColor = System.Drawing.Color.White;
  486. this.m_pMailboxSize.ButtonsAlign = LumiSoft.UI.Controls.LeftRight.Left;
  487. this.m_pMailboxSize.DecimalPlaces = 0;
  488. this.m_pMailboxSize.DecMaxValue = new System.Decimal(new int[] {
  489.    999999999,
  490.    0,
  491.    0,
  492.    0});
  493. this.m_pMailboxSize.DecMinValue = new System.Decimal(new int[] {
  494.    999999999,
  495.    0,
  496.    0,
  497.    -2147483648});
  498. this.m_pMailboxSize.DecValue = new System.Decimal(new int[] {
  499. 20,
  500. 0,
  501. 0,
  502. 0});
  503. this.m_pMailboxSize.Location = new System.Drawing.Point(120, 136);
  504. this.m_pMailboxSize.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Numeric;
  505. this.m_pMailboxSize.MaxLength = 32767;
  506. this.m_pMailboxSize.Name = "m_pMailboxSize";
  507. this.m_pMailboxSize.ReadOnly = false;
  508. this.m_pMailboxSize.Size = new System.Drawing.Size(56, 20);
  509. this.m_pMailboxSize.TabIndex = 6;
  510. this.m_pMailboxSize.Text = "20";
  511. this.m_pMailboxSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
  512. this.m_pMailboxSize.UseStaticViewStyle = true;
  513. // 
  514. // m_pUserEnabled
  515. // 
  516. this.m_pUserEnabled.Checked = false;
  517. this.m_pUserEnabled.Enabled = false;
  518. this.m_pUserEnabled.Location = new System.Drawing.Point(328, 136);
  519. this.m_pUserEnabled.Name = "m_pUserEnabled";
  520. this.m_pUserEnabled.ReadOnly = false;
  521. this.m_pUserEnabled.Size = new System.Drawing.Size(30, 22);
  522. this.m_pUserEnabled.TabIndex = 7;
  523. this.m_pUserEnabled.UseStaticViewStyle = true;
  524. // 
  525. // m_pCancel
  526. // 
  527. this.m_pCancel.Location = new System.Drawing.Point(280, 336);
  528. this.m_pCancel.Name = "m_pCancel";
  529. this.m_pCancel.Size = new System.Drawing.Size(80, 24);
  530. this.m_pCancel.TabIndex = 0;
  531. this.m_pCancel.Text = "Cancel";
  532. this.m_pCancel.UseStaticViewStyle = true;
  533. this.m_pCancel.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pCancel_ButtonPressed);
  534. // 
  535. // wfrm_User
  536. // 
  537. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  538. this.ClientSize = new System.Drawing.Size(370, 367);
  539. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  540.   this.m_pCancel,
  541.   this.m_pUserEnabled,
  542.   this.m_pMailboxSize,
  543.   this.wLabel3,
  544.   this.mt_userenabled,
  545.   this.mt_mailboxsize,
  546.   this.m_pOk,
  547.   this.m_pRemove,
  548.   this.m_pAdd,
  549.   this.m_pGenerate,
  550.   this.m_pDomains,
  551.   this.mt_symbolAT,
  552.   this.m_pAddress,
  553.   this.m_pDescription,
  554.   this.m_pPassword,
  555.   this.m_pLogOnName,
  556.   this.m_pFullName,
  557.   this.mt_Emails,
  558.   this.mt_description,
  559.   this.mt_password,
  560.   this.mt_username,
  561.   this.mt_fullname,
  562.   this.m_pAddresses});
  563. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  564. this.MaximizeBox = false;
  565. this.MinimizeBox = false;
  566. this.Name = "wfrm_User";
  567. this.ShowInTaskbar = false;
  568. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  569. this.Text = "User Properties";
  570. ((System.ComponentModel.ISupportInitialize)(this.m_pFullName)).EndInit();
  571. ((System.ComponentModel.ISupportInitialize)(this.m_pLogOnName)).EndInit();
  572. ((System.ComponentModel.ISupportInitialize)(this.m_pPassword)).EndInit();
  573. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).EndInit();
  574. ((System.ComponentModel.ISupportInitialize)(this.m_pAddress)).EndInit();
  575. ((System.ComponentModel.ISupportInitialize)(this.m_pDomains)).EndInit();
  576. ((System.ComponentModel.ISupportInitialize)(this.m_pGenerate)).EndInit();
  577. ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).EndInit();
  578. ((System.ComponentModel.ISupportInitialize)(this.m_pRemove)).EndInit();
  579. ((System.ComponentModel.ISupportInitialize)(this.m_pOk)).EndInit();
  580. ((System.ComponentModel.ISupportInitialize)(this.m_pMailboxSize)).EndInit();
  581. ((System.ComponentModel.ISupportInitialize)(this.m_pUserEnabled)).EndInit();
  582. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).EndInit();
  583. this.ResumeLayout(false);
  584. }
  585. #endregion
  586. #region Events handling
  587. #region function n_pOk_Click
  588. private void n_pOk_Click(object sender, System.EventArgs e)
  589. {
  590. #region validation stuff
  591.             
  592. if(m_pLogOnName.Text.Length <= 0){
  593. MessageBox.Show("User Name cannot be Empty !!!");
  594. m_pLogOnName.FlashControl();
  595. return;
  596. }
  597. if(m_pPassword.Text.Length <= 0){
  598. MessageBox.Show("Password cannot be Empty !!!");
  599. m_pPassword.FlashControl();
  600. return;
  601. }
  602. if(m_pAddresses.Items.Count == 0){
  603. MessageBox.Show("Please add at least one Emails address !!!");
  604. // m_pAddresses.F
  605. return;
  606. }
  607. #endregion
  608. try
  609. {
  610. if(m_New && m_ServerAPI.MailboxExists(m_pLogOnName.Text)){
  611. MessageBox.Show("User alredy exists !nPlease select another User Name.");
  612. m_pLogOnName.FlashControl();
  613. return;
  614. }
  615. string address = "";
  616. foreach(string str in m_pAddresses.Items){
  617. address += str + ";";
  618. }
  619. // remove ";" from end
  620. address = address.Substring(0,address.Length-1);
  621. m_FullName    = m_pFullName.Text;
  622. m_UserName    = m_pLogOnName.Text;
  623. m_Password    = m_pPassword.Text;
  624. m_Descript    = m_pDescription.Text;
  625. m_Emailss     = address;
  626. m_DomainID    = m_pDomains.SelectedItem.Tag.ToString();
  627. m_MailboxSize = (int)m_pMailboxSize.DecValue;
  628. }
  629. catch(Exception x)
  630. {
  631. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  632. frm.ShowDialog(this);
  633. }
  634. this.DialogResult = DialogResult.OK;
  635. this.Close();
  636. }
  637. #endregion
  638. #region function m_pGenerate_Click
  639. private void m_pGenerate_Click(object sender, System.EventArgs e)
  640. {
  641. m_pPassword.Text = Guid.NewGuid().ToString().Substring(0,8);
  642. }
  643. #endregion
  644. #region function m_pAdd_Click
  645. private void m_pAdd_Click(object sender, System.EventArgs e)
  646. {
  647. string address = m_pAddress.Text + "@" + m_pDomains.Text;
  648. #region Validation
  649. if(m_pAddress.Text.Length == 0){
  650. MessageBox.Show("Emails address can't be empty.");
  651. m_pAddress.FlashControl();
  652. return;
  653. }
  654. if(m_ServerAPI.EmailAddressExists(address)){
  655. MessageBox.Show("Emails address exists already.");
  656. return;
  657. }
  658. #endregion
  659. if(address.IndexOf("<") == -1){
  660. address = "<" + address;
  661. }
  662. if(address.IndexOf(">") == -1){
  663. address += ">";
  664. }
  665. m_pAddresses.Items.Add(address);
  666. m_pAddress.Text = "";
  667. m_pAddress.Focus();
  668. m_pDomains.Enabled = false;
  669. }
  670. #endregion
  671. #region function m_pRemove_Click
  672. private void m_pRemove_Click(object sender, System.EventArgs e)
  673. {
  674. if(m_pAddresses.SelectedIndex > -1){
  675. m_pAddresses.Items.RemoveAt(m_pAddresses.SelectedIndex);
  676. if(m_pAddresses.Items.Count == 0){
  677. m_pDomains.Enabled = true;
  678. }
  679. }
  680. }
  681. #endregion
  682. #region function m_pCancel_ButtonPressed
  683. private void m_pCancel_ButtonPressed(object sender, System.EventArgs e)
  684. {
  685. this.DialogResult = DialogResult.Cancel;
  686. this.Close();
  687. }
  688. #endregion
  689. #endregion
  690. #region Properties Implementation
  691. public string FullName
  692. {
  693. get{ return m_FullName; }
  694. }
  695. public string UserName
  696. {
  697. get{ return m_UserName; }
  698. }
  699. public string Password
  700. {
  701. get{ return m_Password; }
  702. }
  703. public string Description
  704. {
  705. get{ return m_Descript; }
  706. }
  707. public string Emailss
  708. {
  709. get{ return m_Emailss; }
  710. }
  711. public string DomainID
  712. {
  713. get{ return m_DomainID; }
  714. }
  715. public int MailboxSize
  716. {
  717. get{ return m_MailboxSize; }
  718. }
  719. #endregion
  720. }
  721. }