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

📄 frmsalehousessel.cs

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

namespace frmLogin
{
	/// <summary>
	/// frmSaleHousesSel 的摘要说明。
	/// </summary>
	public class frmSaleHousesSel : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton toolBarButton1;
		private System.Windows.Forms.ToolBarButton toolBarButton3;
		private System.Windows.Forms.ToolBarButton toolBarButton4;
		public System.Windows.Forms.DataGrid dataGrid1;
		//private System.Windows.Forms.PrintPreviewDialog ppdlgHouse;
		private System.ComponentModel.IContainer components;
		//用户字段
		private SqlConnection con;
		private SqlDataAdapter dda;
		private DataSet ds,dds;
		//private SqlCommand cmd;
		//private SqlDataReader sr;
		private System.Drawing.Printing.PrintDocument printDocument1;
		private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
		private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1;
		private System.Windows.Forms.ToolTip hehe;
		private ConDA conDA;
		private HouseBS.YesSellsBS YesSellsBS;
		private HouseBE.House YHouse;
	
		

		public frmSaleHousesSel()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			this.conDA=new ConDA();
			this.con=this.conDA._con;

			//
			// 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(frmSaleHousesSel));
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.printDocument1 = new System.Drawing.Printing.PrintDocument();
			this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
			this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
			this.hehe = new System.Windows.Forms.ToolTip(this.components);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(30, 30);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// toolBar1
			// 
			this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton1,
																						this.toolBarButton3,
																						this.toolBarButton4});
			this.toolBar1.ButtonSize = new System.Drawing.Size(70, 55);
			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(576, 55);
			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 = "查找";
			// 
			// toolBarButton3
			// 
			this.toolBarButton3.ImageIndex = 2;
			this.toolBarButton3.Text = "打印";
			this.toolBarButton3.ToolTipText = "打印";
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.ImageIndex = 3;
			this.toolBarButton4.Text = "退出";
			this.toolBarButton4.ToolTipText = "退出";
			// 
			// dataGrid1
			// 
			this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.dataGrid1.CaptionBackColor = System.Drawing.Color.LightBlue;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dataGrid1.GridLineColor = System.Drawing.Color.Orange;
			this.dataGrid1.HeaderForeColor = System.Drawing.Color.Blue;
			this.dataGrid1.Location = new System.Drawing.Point(0, 55);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.Size = new System.Drawing.Size(576, 347);
			this.dataGrid1.TabIndex = 1;
			this.dataGrid1.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dataGrid1_Navigate);
			// 
			// printDocument1
			// 
			this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
			// 
			// pageSetupDialog1
			// 
			this.pageSetupDialog1.Document = this.printDocument1;
			// 
			// 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(88, 88);
			this.printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
			this.printPreviewDialog1.Name = "printPreviewDialog1";
			this.printPreviewDialog1.TransparencyKey = System.Drawing.Color.Empty;
			this.printPreviewDialog1.Visible = false;
			// 
			// hehe
			// 
			this.hehe.ShowAlways = true;
			// 
			// frmSaleHousesSel
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(576, 402);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.toolBar1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmSaleHousesSel";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "出售房查询";
			this.Load += new System.EventHandler(this.frmSaleHousesSel_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void frmSaleHousesSel_Load(object sender, System.EventArgs e)
		{
			try
			{
				this.YesSellsBS=new YesSellsBS();
				ds=this.YesSellsBS.select();
				this.dataGrid1.DataSource=ds;
				this.dataGrid1.DataMember="HouseSalesView";
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
				return;
			}
		 }

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			
			if(e.Button==this.toolBar1.Buttons[0])
			{
				frmSaleFind ff=new frmSaleFind();
				ff.Owner=this;
				ff.ShowDialog();
				if(ff.ID.Equals(" "))
				{
					
				}else{
				string YhouseNO=ff.ID;
				
						dds=new DataSet();
						dda=new SqlDataAdapter("select * from HouseSalesView where 房屋编号='"+YhouseNO+"'",this.con);
						try
						{
							dda.Fill(dds,"obj");
						}
						catch(Exception ex)
						{
							MessageBox.Show(ex.Message);
							return;
						}
						this.dataGrid1.DataSource=dds;
						this.dataGrid1.DataMember="obj";
	
				}
			}
//			else if(e.Button==this.toolBar1.Buttons[1])
//			{
//				//删除
//				int  SaleID=Convert.ToInt32(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][12]);
//				string lpName=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][0]);
//				string Clientname=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][2]);
//				string Spec=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][1]);
//				string houseNO=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][4]);
//				this.YHouse=new House();
//				this.YesSellsBS=new YesSellsBS();
//				this.YHouse.HouseID=SaleID;
//				this.YHouse.getLpName=lpName;
//				this.YHouse.getClientName=Clientname;
//				this.YHouse.getSpecName=Spec;
//				this.YHouse.HouseNO=houseNO;
//				this.YesSellsBS.House=this.YHouse;
//				try
//				{
//					YesSellsBS.delete();
//					MessageBox.Show("删除成功");
//					//重新加载数据
//					frmSaleHousesSel_Load(sender,e);
//
//				}
//				catch(Exception ex)
//				{
//					MessageBox.Show(ex.Message);
//					return;
//				}
//				
//			}
			else if(e.Button==this.toolBar1.Buttons[1])
			{
				//打印
				this.printPreviewDialog1.ShowDialog();
			}
			else
				this.Close();
		}
		
		#region 打印
		
		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.DrawLine(objPen,nLeft,nTop,nWidth+nLeft,nTop);
			e.Graphics.DrawLine(objPen,nLeft,nTop+nHeight,nLeft+nWidth,nTop+nHeight);
			e.Graphics.DrawLine(objPen,nLeft+nWidth,nTop,nLeft+nWidth,nTop+nHeight);
			
			//打印出表头
			
			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("单价",objFont,objBrush,nLeft+420,nTop+60);
			e.Graphics.DrawString("总价",objFont,objBrush,nLeft+480,nTop+60);
			e.Graphics.DrawString("备注",objFont,objBrush,nLeft+520,nTop+60);
			//打印具体数据
			
			try
			{
					HouseBS.YesSellsBS YesSell=new YesSellsBS();
					this.ds=YesSell.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+500,nTop+60+nLine*30);
						e.Graphics.DrawString(rows[6].ToString(),objFont,objBrush,nLeft+520,nTop+60);
						nLine++;
					}
			
			}
			catch(SqlException ex)
			{
				MessageBox.Show(ex.Message);
				throw ex;
			}
			finally
			{
			  this.con.Close();
			}

			//打印图片
			
		}
		#endregion

		private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
		{
			 
		}
		

	}
}

⌨️ 快捷键说明

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