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

Email服务器

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. namespace LumiSoft.MailServer
  8. {
  9. /// <summary>
  10. /// Summary description for Domain_Frm.
  11. /// </summary>
  12. public class wfrm_Domain : System.Windows.Forms.Form
  13. {
  14. private LumiSoft.UI.Controls.WLabel mt_domain;
  15. private LumiSoft.UI.Controls.WLabel mt_description;
  16. private LumiSoft.UI.Controls.WEditBox m_pDomain;
  17. private LumiSoft.UI.Controls.WEditBox m_pDescription;
  18. private LumiSoft.UI.Controls.WButton m_pCancel;
  19. private LumiSoft.UI.Controls.WButton m_pAdd;
  20. /// <summary>
  21. /// Required designer variable.
  22. /// </summary>
  23. private System.ComponentModel.Container components = null;
  24. private ServerAPI m_ServerAPI = null;
  25. private DataRow   m_DataRow   = null;
  26. /// <summary>
  27. /// Default constructor.
  28. /// </summary>
  29. /// <param name="serverAPI"></param>
  30. public wfrm_Domain(ServerAPI serverAPI)
  31. {
  32. //
  33. // Required for Windows Form Designer support
  34. //
  35. InitializeComponent();
  36. //
  37. // TODO: Add any constructor code after InitializeComponent call
  38. //
  39. try
  40. {
  41. m_ServerAPI = serverAPI;
  42. }
  43. catch(Exception x)
  44. {
  45. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  46. frm.ShowDialog(this);
  47. }
  48. }
  49. #region function Dispose
  50. /// <summary>
  51. /// Clean up any resources being used.
  52. /// </summary>
  53. protected override void Dispose( bool disposing )
  54. {
  55. if( disposing )
  56. {
  57. if(components != null)
  58. {
  59. components.Dispose();
  60. }
  61. }
  62. base.Dispose( disposing );
  63. }
  64. #endregion
  65. #region Windows Form Designer generated code
  66. /// <summary>
  67. /// Required method for Designer support - do not modify
  68. /// the contents of this method with the code editor.
  69. /// </summary>
  70. private void InitializeComponent()
  71. {
  72. this.mt_domain = new LumiSoft.UI.Controls.WLabel();
  73. this.mt_description = new LumiSoft.UI.Controls.WLabel();
  74. this.m_pDomain = new LumiSoft.UI.Controls.WEditBox();
  75. this.m_pDescription = new LumiSoft.UI.Controls.WEditBox();
  76. this.m_pCancel = new LumiSoft.UI.Controls.WButton();
  77. this.m_pAdd = new LumiSoft.UI.Controls.WButton();
  78. ((System.ComponentModel.ISupportInitialize)(this.m_pDomain)).BeginInit();
  79. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).BeginInit();
  80. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).BeginInit();
  81. ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).BeginInit();
  82. this.SuspendLayout();
  83. // 
  84. // mt_domain
  85. // 
  86. this.mt_domain.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  87. this.mt_domain.Location = new System.Drawing.Point(8, 8);
  88. this.mt_domain.Name = "mt_domain";
  89. this.mt_domain.Size = new System.Drawing.Size(104, 16);
  90. this.mt_domain.TabIndex = 4;
  91. this.mt_domain.Text = "Domain";
  92. this.mt_domain.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  93. this.mt_domain.UseStaticViewStyle = true;
  94. // 
  95. // mt_description
  96. // 
  97. this.mt_description.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  98. this.mt_description.Location = new System.Drawing.Point(8, 48);
  99. this.mt_description.Name = "mt_description";
  100. this.mt_description.Size = new System.Drawing.Size(104, 16);
  101. this.mt_description.TabIndex = 5;
  102. this.mt_description.Text = "Description";
  103. this.mt_description.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  104. this.mt_description.UseStaticViewStyle = true;
  105. // 
  106. // m_pDomain
  107. // 
  108. this.m_pDomain.DecimalPlaces = 2;
  109. this.m_pDomain.DecMaxValue = new System.Decimal(new int[] {
  110.   999999999,
  111.   0,
  112.   0,
  113.   0});
  114. this.m_pDomain.DecMinValue = new System.Decimal(new int[] {
  115.   999999999,
  116.   0,
  117.   0,
  118.   -2147483648});
  119. this.m_pDomain.Lines = new string[0];
  120. this.m_pDomain.Location = new System.Drawing.Point(8, 24);
  121. this.m_pDomain.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  122. this.m_pDomain.MaxLength = 32767;
  123. this.m_pDomain.Multiline = false;
  124. this.m_pDomain.Name = "m_pDomain";
  125. this.m_pDomain.PasswordChar = '';
  126. this.m_pDomain.ReadOnly = false;
  127. this.m_pDomain.ScrollBars = System.Windows.Forms.ScrollBars.None;
  128. this.m_pDomain.Size = new System.Drawing.Size(136, 20);
  129. this.m_pDomain.TabIndex = 1;
  130. this.m_pDomain.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  131. this.m_pDomain.UseStaticViewStyle = true;
  132. // 
  133. // m_pDescription
  134. // 
  135. this.m_pDescription.DecimalPlaces = 2;
  136. this.m_pDescription.DecMaxValue = new System.Decimal(new int[] {
  137.    999999999,
  138.    0,
  139.    0,
  140.    0});
  141. this.m_pDescription.DecMinValue = new System.Decimal(new int[] {
  142.    999999999,
  143.    0,
  144.    0,
  145.    -2147483648});
  146. this.m_pDescription.Lines = new string[0];
  147. this.m_pDescription.Location = new System.Drawing.Point(8, 64);
  148. this.m_pDescription.Mask = LumiSoft.UI.Controls.WEditBox_Mask.Text;
  149. this.m_pDescription.MaxLength = 32767;
  150. this.m_pDescription.Multiline = false;
  151. this.m_pDescription.Name = "m_pDescription";
  152. this.m_pDescription.PasswordChar = '';
  153. this.m_pDescription.ReadOnly = false;
  154. this.m_pDescription.ScrollBars = System.Windows.Forms.ScrollBars.None;
  155. this.m_pDescription.Size = new System.Drawing.Size(280, 20);
  156. this.m_pDescription.TabIndex = 2;
  157. this.m_pDescription.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
  158. this.m_pDescription.UseStaticViewStyle = true;
  159. // 
  160. // m_pCancel
  161. // 
  162. this.m_pCancel.Location = new System.Drawing.Point(208, 96);
  163. this.m_pCancel.Name = "m_pCancel";
  164. this.m_pCancel.Size = new System.Drawing.Size(72, 24);
  165. this.m_pCancel.TabIndex = 0;
  166. this.m_pCancel.Text = "Cancel";
  167. this.m_pCancel.UseStaticViewStyle = true;
  168. this.m_pCancel.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pCancel_Click);
  169. // 
  170. // m_pAdd
  171. // 
  172. this.m_pAdd.Location = new System.Drawing.Point(128, 96);
  173. this.m_pAdd.Name = "m_pAdd";
  174. this.m_pAdd.Size = new System.Drawing.Size(72, 24);
  175. this.m_pAdd.TabIndex = 3;
  176. this.m_pAdd.Text = "OK";
  177. this.m_pAdd.UseStaticViewStyle = true;
  178. this.m_pAdd.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pAdd_Click);
  179. // 
  180. // wfrm_Domain
  181. // 
  182. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  183. this.ClientSize = new System.Drawing.Size(298, 127);
  184. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  185.   this.m_pAdd,
  186.   this.m_pCancel,
  187.   this.m_pDescription,
  188.   this.m_pDomain,
  189.   this.mt_description,
  190.   this.mt_domain});
  191. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  192. this.MaximizeBox = false;
  193. this.MinimizeBox = false;
  194. this.Name = "wfrm_Domain";
  195. this.ShowInTaskbar = false;
  196. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  197. this.Text = "New Domain";
  198. ((System.ComponentModel.ISupportInitialize)(this.m_pDomain)).EndInit();
  199. ((System.ComponentModel.ISupportInitialize)(this.m_pDescription)).EndInit();
  200. ((System.ComponentModel.ISupportInitialize)(this.m_pCancel)).EndInit();
  201. ((System.ComponentModel.ISupportInitialize)(this.m_pAdd)).EndInit();
  202. this.ResumeLayout(false);
  203. }
  204. #endregion
  205. #region Events handling
  206. #region function m_pAdd_Click
  207. private void m_pAdd_Click(object sender, System.EventArgs e)
  208. {
  209. try
  210. {
  211. if(m_pDomain.Text.Length <= 0){
  212. MessageBox.Show("Domain Name Cannot be Empty !!!");
  213. m_pDomain.FlashControl();
  214. return;
  215. }
  216. if(m_ServerAPI.DomainExists(m_pDomain.Text)){
  217. MessageBox.Show("Domain already exists.");
  218. return;
  219. }
  220. m_DataRow = m_ServerAPI.AddDomain(m_pDomain.Text,m_pDescription.Text);
  221. if(m_DataRow == null){
  222. MessageBox.Show("Error creating domain.");
  223. return;
  224. }
  225. this.DialogResult = DialogResult.OK;
  226. this.Close();
  227. }
  228. catch(Exception x)
  229. {
  230. wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
  231. frm.ShowDialog(this);
  232. }
  233. }
  234. #endregion
  235. #region function m_pCancel_Click
  236. private void m_pCancel_Click(object sender, System.EventArgs e)
  237. {
  238. this.Close();
  239. }
  240. #endregion
  241. #endregion
  242. #region Properties Implementation
  243. public DataRow wp_Dr
  244. {
  245. get{ return m_DataRow; }
  246. }
  247. #endregion
  248. }
  249. }