⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systemmanage.cs

📁 这是一个邮件系统源码可以好好学习一下很好用的
💻 CS
📖 第 1 页 / 共 2 页
字号:
																						  this.sbIp});
			this.statusBar1.ShowPanels = true;
			this.statusBar1.Size = new System.Drawing.Size(762, 32);
			this.statusBar1.TabIndex = 3;
			// 
			// sbWeclome
			// 
			this.sbWeclome.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
			this.sbWeclome.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.sbWeclome.Text = "欢迎使用ArgentSwan邮件管理系统";
			this.sbWeclome.Width = 186;
			// 
			// sbTime
			// 
			this.sbTime.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
			this.sbTime.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.sbTime.Width = 186;
			// 
			// sbCpmputerName
			// 
			this.sbCpmputerName.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
			this.sbCpmputerName.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.sbCpmputerName.Width = 186;
			// 
			// sbIp
			// 
			this.sbIp.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
			this.sbIp.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.sbIp.Width = 186;
			// 
			// richTextBox1
			// 
			this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.richTextBox1.Location = new System.Drawing.Point(0, 141);
			this.richTextBox1.Name = "richTextBox1";
			this.richTextBox1.Size = new System.Drawing.Size(762, 321);
			this.richTextBox1.TabIndex = 2;
			this.richTextBox1.Text = "";
			// 
			// splitter2
			// 
			this.splitter2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.splitter2.Dock = System.Windows.Forms.DockStyle.Top;
			this.splitter2.Location = new System.Drawing.Point(0, 136);
			this.splitter2.Name = "splitter2";
			this.splitter2.Size = new System.Drawing.Size(762, 5);
			this.splitter2.TabIndex = 1;
			this.splitter2.TabStop = false;
			// 
			// ltReceive
			// 
			this.ltReceive.Dock = System.Windows.Forms.DockStyle.Top;
			this.ltReceive.Location = new System.Drawing.Point(0, 0);
			this.ltReceive.MultiSelect = false;
			this.ltReceive.Name = "ltReceive";
			this.ltReceive.Size = new System.Drawing.Size(762, 136);
			this.ltReceive.TabIndex = 0;
			this.ltReceive.View = System.Windows.Forms.View.Details;
			// 
			// contextMenu1
			// 
			this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.menuItem6});
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 0;
			this.menuItem6.Text = "默认连接";
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// timer1
			// 
			this.timer1.Enabled = true;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// toolBarRecive
			// 
			this.toolBarRecive.DropDownMenu = this.contextMenu1;
			this.toolBarRecive.ImageIndex = 0;
			this.toolBarRecive.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
			this.toolBarRecive.Text = "收取";
			// 
			// toolBarSend
			// 
			this.toolBarSend.ImageIndex = 1;
			this.toolBarSend.Text = "发送";
			// 
			// toolBarWrite
			// 
			this.toolBarWrite.ImageIndex = 2;
			this.toolBarWrite.Text = "写邮件";
			// 
			// toolBar1
			// 
			this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarRecive,
																						this.toolBarSend,
																						this.toolBarButton1,
																						this.toolBarWrite});
			this.toolBar1.ButtonSize = new System.Drawing.Size(70, 37);
			this.toolBar1.Divider = false;
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Location = new System.Drawing.Point(0, 0);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(888, 43);
			this.toolBar1.TabIndex = 0;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// printPreviewDialog1
			// 
			this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
			this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
			this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
			this.printPreviewDialog1.Enabled = true;
			this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
			this.printPreviewDialog1.Location = new System.Drawing.Point(44, 58);
			this.printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
			this.printPreviewDialog1.Name = "printPreviewDialog1";
			this.printPreviewDialog1.TransparencyKey = System.Drawing.Color.Empty;
			this.printPreviewDialog1.Visible = false;
			// 
			// imageAccount
			// 
			this.imageAccount.ImageSize = new System.Drawing.Size(16, 16);
			this.imageAccount.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageAccount.ImageStream")));
			this.imageAccount.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// SystemManage
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(888, 505);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.splitter1);
			this.Controls.Add(this.treeView1);
			this.Controls.Add(this.toolBar1);
			this.Menu = this.mainMenu1;
			this.Name = "SystemManage";
			this.Text = "邮件管理系统";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.panel1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.sbWeclome)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbTime)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbCpmputerName)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbIp)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			
			Application.Run(new SystemManage());
		}

		

		PrintDocument print=new PrintDocument ();
		private void menuItem11_Click(object sender, System.EventArgs e)
		{
			
			this.printDialog1 .Document =print;
			if(this.printDialog1 .ShowDialog ()==DialogResult.OK )
			{
				print.Print ();
			
			}
		}


		private void printDocument1_PrintPage(object sender, 
			System.Drawing.Printing.PrintPageEventArgs e)
		{
			e.Graphics.DrawString(this.richTextBox1 .Text , 
				new Font("Arial", 80, FontStyle.Bold), Brushes.Black, 150, 125);
		}

		private void menuItem12_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.printDocument1.PrintPage += new
					System.Drawing.Printing.PrintPageEventHandler
					(this.printDocument1_PrintPage);
				this.printPreviewDialog1 .Document =this.printDocument1 ;
				this.printPreviewDialog1 .ShowDialog ();
			}
			catch(Exception ex)
			{
				//				MessageBox.Show ("请确定你已经安装了打印机");
				MessageBox.Show (ex.ToString ());
			}
			
		}

		//退出应用程序
		private void menuItem15_Click(object sender, System.EventArgs e)
		{
			Application.Exit ();
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch(toolBar1.Buttons .IndexOf (e.Button ))
			{
				case 0:

					break;
				case 1:

					break;
				default:
					if(AccountName==null)
					{
						MessageBox.Show ("请先注册帐号!");
						return;
					}
					SendMailForm send=new SendMailForm ();
					send.Show ();
					break;
			}
			
		}



		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			try
			{
				NewAccount newaccount=new NewAccount ();
				newaccount.Show ();
			}
			catch(Exception ee)
			{
				MessageBox.Show (ee.ToString ());
			}
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			extra=new AddExtra();
			this.sbCpmputerName.Text ="主机名:"+extra.GetName ();
			this.sbTime .Text =extra.GetTime ();
			this.sbIp .Text ="IP地址:";
			string []IpAddress=extra.GetIP ();
			for(int i=0;i<IpAddress.Length/2;i++)
			{
				this.sbIp .Text+=IpAddress[i];
			}
			LoadAccount();
		}
			

		//再加载窗口的同时加载已经注册的帐户
		public  void LoadAccount()
		{
			try
			{
				AccountOperate acOperate=new AccountOperate();
				ArrayList Array=acOperate.ReadFromDataBase ("select AccountName from Users","AccountName");
				for( int i=0;i<Array.Count ;i++)
				{
					TreeNode Nodes=new TreeNode (Array[i].ToString (),0,0);
					treeView1 .Nodes .Add (Nodes);
					TreeNode SubNode1=new TreeNode ("收信箱",1,1);
					Nodes.Nodes .Add (SubNode1);
					TreeNode SubNode2=new TreeNode ("发件箱",2,2);
					Nodes.Nodes .Add (SubNode2);
					TreeNode SubNode3=new TreeNode ("已发送邮件箱",3,3);
					Nodes.Nodes .Add (SubNode3);
					TreeNode SubNode4=new TreeNode ("垃圾邮件箱",4,4);
					Nodes.Nodes .Add (SubNode4);
					TreeNode SubNode5=new TreeNode ("废件箱",5,5);
					Nodes.Nodes .Add (SubNode5);
			
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show (ex.ToString ());
			}
			this.ltReceive.Columns .Add("作者",100,HorizontalAlignment.Center);
			this.ltReceive.Columns .Add ("主题",150,HorizontalAlignment.Center);
			this.ltReceive.Columns .Add ("日期",200,HorizontalAlignment.Center);
			this.ltReceive.Columns .Add ("大小",120,HorizontalAlignment.Center);
		}
	

		//在新建一个帐户的同时,将它加载到TreeView控件中
		public void addNewAccount()
		{
			try
			{	
				TreeNode Nodes=new TreeNode (AccountName);
				treeView1 .Nodes .Add (Nodes);
				TreeNode SubNode1=new TreeNode ("收信箱",1,1);
				Nodes.Nodes .Add (SubNode1);
				TreeNode SubNode2=new TreeNode ("发件箱",2,2);
				Nodes.Nodes .Add (SubNode2);
				TreeNode SubNode3=new TreeNode ("已发送邮件箱",3,3);
				Nodes.Nodes .Add (SubNode3);
				TreeNode SubNode4=new TreeNode ("垃圾邮件箱",4,4);
				Nodes.Nodes .Add (SubNode4);
				TreeNode SubNode5=new TreeNode ("废件箱",5,5);
				Nodes.Nodes .Add (SubNode5);
				
			}
			catch(Exception ex)
			{
				MessageBox.Show (ex.ToString ());
			}
		}

		private void menuItem19_Click(object sender, System.EventArgs e)
		{
			//调用关于窗口
			Assembly ass=Assembly.GetExecutingAssembly();
			FileVersionInfo myVersion=FileVersionInfo.GetVersionInfo(ass.Location );
			ShellAbout(this.Handle ,"邮件收发系统#","版本"+myVersion.FileMajorPart +"."+myVersion.FileMinorPart+"." +myVersion.CompanyName ,this.Icon .Handle );
		
		}

		private void timer1_Tick(object sender, System.EventArgs e)
		{
			//新建帐号的时候
			if(flag)
			{
				addNewAccount();
			}
			flag=false;
		}

		//在选中一个帐户的时候,所有的相关信息跟着改变(主要是发送邮件的参数)
		private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			//帐户操作的有关类
			AccountOperate acOperate=new AccountOperate();
			try
			{
				//判断是否是根节点
				if(e.Node .Parent==null)
				{
					AccountName =e.Node.Text ; 
				}
				else if(e.Node .Parent !=null)
				{
					AccountName=e.Node .Parent .Text ;
				}
				string []accountInfo=acOperate.AccountFileInfo("Select userName,PassW, MailAddress,Smtp,Port from users where AccountName='"+AccountName +"'");
				UserName=accountInfo[0];
				PassWd=accountInfo[1];
				MailAddress=accountInfo[2];
				SmtpName=accountInfo[3];
				SmtpPort=int.Parse (accountInfo[4]);
			}
				
			
			catch(Exception ex)
			{
				MessageBox.Show (ex.ToString ());
			}
			
		}

		//删除选定帐户的操作
		private void menuItem27_Click(object sender, System.EventArgs e)
		{
			try
			{
				AccountOperate acOperate=new AccountOperate();
				acOperate.AddDelAccount("delete * from users where AccountName='"+AccountName+"'");
			
				if(this.treeView1.SelectedNode !=null)
				{
					if(MessageBox.Show ("你确定要删除吗?","请确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
					{
						this.treeView1.Nodes .Remove(this.treeView1 .SelectedNode );

					}
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
			}
		}
		
	}
}
			
			
			
		
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -