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

📄 frmbuyhouseclients.cs

📁 实现房产销售的房屋管理 客户管理 并且在客户管理中实现了对预定客户和已购房客户的查询和修改
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using HouseBE;
using HouseBS;
using System.Data;
using System.Data.SqlClient;

namespace frmLogin
{
	/// <summary>
	/// frmBuyHouseClients 的摘要说明。
	/// </summary>
	public class frmBuyHouseClients : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton toolBarButton1;
		private System.Windows.Forms.ToolBarButton toolBarButton2;
		private System.Windows.Forms.ToolBarButton toolBarButton3;
		private System.Windows.Forms.ToolBarButton toolBarButton4;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.ToolTip toolTip1;
		private System.ComponentModel.IContainer components;
        
		private DataSet _ds;
		private HouseBS.ClientBS _clients;
		private System.Windows.Forms.PrintDialog printDialog1;
		private System.Drawing.Printing.PrintDocument printDocument1;
		private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1;
		private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
		//private HouseBE.Client _client;

		public frmBuyHouseClients()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
            this._ds=new DataSet();
			this._clients=new ClientBS();
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmBuyHouseClients));
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
			this.printDialog1 = new System.Windows.Forms.PrintDialog();
			this.printDocument1 = new System.Drawing.Printing.PrintDocument();
			this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
			this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// toolBar1
			// 
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton1,
																						this.toolBarButton2,
																						this.toolBarButton3,
																						this.toolBarButton4});
			this.toolBar1.ButtonSize = new System.Drawing.Size(60, 50);
			this.toolBar1.DropDownArrows = true;
			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(568, 56);
			this.toolBar1.TabIndex = 0;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.ImageIndex = 0;
			this.toolBarButton1.Text = "查找";
			this.toolBarButton1.ToolTipText = "查找";
			// 
			// toolBarButton2
			// 
			this.toolBarButton2.ImageIndex = 1;
			this.toolBarButton2.Text = "导出";
			this.toolBarButton2.ToolTipText = "导出";
			// 
			// toolBarButton3
			// 
			this.toolBarButton3.ImageIndex = 2;
			this.toolBarButton3.Text = "打印";
			this.toolBarButton3.ToolTipText = "打印";
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.ImageIndex = 3;
			this.toolBarButton4.Text = "退出";
			this.toolBarButton4.ToolTipText = "退出";
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(28, 28);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// dataGrid1
			// 
			this.dataGrid1.AlternatingBackColor = System.Drawing.Color.Lavender;
			this.dataGrid1.BackColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.dataGrid1.CaptionBackColor = System.Drawing.Color.LightBlue;
			this.dataGrid1.CaptionForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dataGrid1.FlatMode = true;
			this.dataGrid1.Font = new System.Drawing.Font("Tahoma", 8F);
			this.dataGrid1.ForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.GridLineColor = System.Drawing.Color.Gainsboro;
			this.dataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
			this.dataGrid1.HeaderBackColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid1.HeaderForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.LinkColor = System.Drawing.Color.Teal;
			this.dataGrid1.Location = new System.Drawing.Point(0, 56);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Gainsboro;
			this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.SelectionBackColor = System.Drawing.Color.CadetBlue;
			this.dataGrid1.SelectionForeColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.Size = new System.Drawing.Size(568, 341);
			this.dataGrid1.TabIndex = 1;
			this.dataGrid1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dataGrid1_MouseMove);
			// 
			// toolTip1
			// 
			this.toolTip1.ShowAlways = true;
			// 
			// printDialog1
			// 
			this.printDialog1.Document = this.printDocument1;
			// 
			// printDocument1
			// 
			this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
			// 
			// 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.Document = this.printDocument1;
			this.printPreviewDialog1.Enabled = true;
			this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
			this.printPreviewDialog1.Location = new System.Drawing.Point(66, 66);
			this.printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
			this.printPreviewDialog1.Name = "printPreviewDialog1";
			this.printPreviewDialog1.TransparencyKey = System.Drawing.Color.Empty;
			this.printPreviewDialog1.Visible = false;
			// 
			// pageSetupDialog1
			// 
			this.pageSetupDialog1.Document = this.printDocument1;
			// 
			// frmBuyHouseClients
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(568, 397);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.toolBar1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmBuyHouseClients";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "购房客户查询";
			this.Load += new System.EventHandler(this.frmBuyHouseClients_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void dataGrid1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			this.toolTip1.SetToolTip(this.dataGrid1,"购买楼房的客户信息");
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch(this.toolBar1.Buttons.IndexOf(e.Button))
			{
				case 0:
					frmBuyHouseClientFind fb=new frmBuyHouseClientFind();
					fb.Owner=this;
					fb.ShowDialog();
					if(fb.name=="")
					{
						
					}
					else
					{
						string name=fb.name;
						this._ds=new DataSet();
						this._ds=this._clients.getNameSelect(name);
						this.dataGrid1.DataSource=this._ds;
						this.dataGrid1.DataMember="ClientName";
					}
					break;//查找
				case 1:
					
					break;
					//导出
				case 2:
					this.printPreviewDialog1.ShowDialog();
					break;//打印
				case 3:
					this.Close();
					break;
			}
		}

		private void frmBuyHouseClients_Load(object sender, System.EventArgs e)
		{
		   this._ds=this._clients.select();
		   this.dataGrid1.DataSource=this._ds;
		   this.dataGrid1.DataMember="Client";
		}

		private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			Font objFont = new Font("Tahoma",11,FontStyle.Underline);
			Brush objBrush = Brushes.Black;
			Pen objPen = new Pen(objBrush);
			objPen.Width = 2;
			
			//向打印预缆窗口中添加内容
			
			int nLeft = this.pageSetupDialog1.PageSettings.Margins.Left;
			int nTop = this.pageSetupDialog1.PageSettings.Margins.Top;
			int nWidth = this.pageSetupDialog1.PageSettings.PaperSize.Width-
				(this.pageSetupDialog1.PageSettings.Margins.Left + 
				this.pageSetupDialog1.PageSettings.Margins.Right);
			int nHeight = this.pageSetupDialog1.PageSettings.PaperSize.Height-
				(this.pageSetupDialog1.PageSettings.Margins.Top + 
				this.pageSetupDialog1.PageSettings.Margins.Bottom);
			
			
			//打印出表头
			
			e.Graphics.DrawString("购房客户",new Font("Garamond",40,FontStyle.Bold),Brushes.Blue,nLeft+200,nTop+10);
			e.Graphics.DrawString("客户姓名",objFont,objBrush,nLeft+10,nTop+60);
			e.Graphics.DrawString("客户地址",objFont,objBrush,nLeft+100,nTop+60);
			e.Graphics.DrawString("交易金额",objFont,objBrush,nLeft+180,nTop+60);
			e.Graphics.DrawString("客户电话",objFont,objBrush,nLeft+300,nTop+60);
			e.Graphics.DrawString("客户E-mail",objFont,objBrush,nLeft+420,nTop+60);
			e.Graphics.DrawString("交易时间",objFont,objBrush,nLeft+570,nTop+60);
			
			//打印具体数据
			
			try
			{
				this._ds=this._clients.select();
				int nLine=1;
				foreach( DataRow rows in this._ds.Tables[0].Rows)
				{
					e.Graphics.DrawString(rows[0].ToString(),objFont,objBrush,nLeft+10,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[1].ToString(),objFont,objBrush,nLeft+100,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[2].ToString(),objFont,objBrush,nLeft+180,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[3].ToString(),objFont,objBrush,nLeft+300,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[4].ToString(),objFont,objBrush,nLeft+420,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[5].ToString(),objFont,objBrush,nLeft+570,nTop+60+nLine*30);
					nLine++;
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
	}
}

⌨️ 快捷键说明

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