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

📄 frmnosalehouse.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 HouseBS;
using HouseBE;

namespace frmLogin
{
	/// <summary>
	/// frmNoSaleHouse 的摘要说明。
	/// </summary>
	public class frmNoSaleHouse : System.Windows.Forms.Form
	{
		public System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton toolBarButton1;
		private System.Windows.Forms.ToolBarButton toolBarButton3;
		private System.Windows.Forms.ToolBarButton toolBarButton4;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
		private System.Drawing.Printing.PrintDocument pdocHouse;
		private System.Windows.Forms.PrintDialog pdlgPrintDialog;
		private System.Windows.Forms.PrintPreviewDialog ppdlgHouse;
		private System.ComponentModel.IContainer components;
		//用户字段
		public SqlConnection con;
		public SqlDataAdapter da,dda;
		public DataSet ds,dds;
		//private SqlCommand cmd;
		//private SqlDataReader sr;
		public ConDA conDA;
		private HouseBS.NotSellsBS NotSellsBS=new NotSellsBS();
        private HouseBE.House NotHouse=new House();
		public frmNoSaleHouse()
		{
			//
			// 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(frmNoSaleHouse));
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			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.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
			this.pdocHouse = new System.Drawing.Printing.PrintDocument();
			this.pdlgPrintDialog = new System.Windows.Forms.PrintDialog();
			this.ppdlgHouse = new System.Windows.Forms.PrintPreviewDialog();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// 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(574, 342);
			this.dataGrid1.TabIndex = 3;
			this.dataGrid1.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dataGrid1_Navigate);
			// 
			// 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(574, 55);
			this.toolBar1.TabIndex = 2;
			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 = "退出";
			// 
			// 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;
			// 
			// pageSetupDialog1
			// 
			this.pageSetupDialog1.Document = this.pdocHouse;
			// 
			// pdocHouse
			// 
			this.pdocHouse.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pdocHouse_PrintPage);
			// 
			// pdlgPrintDialog
			// 
			this.pdlgPrintDialog.Document = this.pdocHouse;
			// 
			// ppdlgHouse
			// 
			this.ppdlgHouse.AutoScrollMargin = new System.Drawing.Size(0, 0);
			this.ppdlgHouse.AutoScrollMinSize = new System.Drawing.Size(0, 0);
			this.ppdlgHouse.ClientSize = new System.Drawing.Size(400, 300);
			this.ppdlgHouse.Document = this.pdocHouse;
			this.ppdlgHouse.Enabled = true;
			this.ppdlgHouse.Icon = ((System.Drawing.Icon)(resources.GetObject("ppdlgHouse.Icon")));
			this.ppdlgHouse.Location = new System.Drawing.Point(176, 176);
			this.ppdlgHouse.MinimumSize = new System.Drawing.Size(375, 250);
			this.ppdlgHouse.Name = "printPreviewDialog1";
			this.ppdlgHouse.TransparencyKey = System.Drawing.Color.Empty;
			this.ppdlgHouse.Visible = false;
			// 
			// frmNoSaleHouse
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(574, 397);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.toolBar1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Name = "frmNoSaleHouse";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "待出售房查询";
			this.Load += new System.EventHandler(this.frmNoSaleHouse_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void frmNoSaleHouse_Load(object sender, System.EventArgs e)
		{
			try
			{
				ds=new DataSet();
				ds=this.NotSellsBS.select();
				this.dataGrid1.DataSource=ds;
				this.dataGrid1.DataMember="HouseNoSalesView";
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
				throw ex;
			}
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if(e.Button==this.toolBar1.Buttons[0])
			{
				frmNoSaleFind ff=new frmNoSaleFind();
				ff.Owner=this;
				ff.ShowDialog();
				if(ff.ID.Equals(" "))
				{}
				else
				{
					string NhouseNO=ff.ID;
					dds=new DataSet();
					dda=new SqlDataAdapter("select * from HouseNoSalesView where 房屋编号='"+NhouseNO+"'",this.con);
					try
					{
						dda.Fill(dds,"obj");
					}
					catch(Exception ex)
					{
						MessageBox.Show(ex.Message);
					}
					this.dataGrid1.DataSource=dds;
					this.dataGrid1.DataMember="obj";
				}
			}
//			else if(e.Button==this.toolBar1.Buttons[1])
//			{
//				//删除
//				int NOtSaleID=Convert.ToInt32(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][10]);
//				string lpName=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][1]);
//				string Clientname=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][11]);
//				string Spec=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][0]);
//				string houseNO=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][2]);
//				this.NotHouse.HouseID=NOtSaleID;
//				this.NotHouse.getLpName=lpName;
//				this.NotHouse.getClientName=Clientname;
//				this.NotHouse.getSpecName=Spec;
//				this.NotHouse.HouseNO=houseNO;
//				this.NotSellsBS.notSells=this.NotHouse;
//				try
//				{
//					NotSellsBS.delete();
//					MessageBox.Show("删除成功");
//					ds=new DataSet();
//					ds=this.NotSellsBS.select();
//					this.dataGrid1.DataSource=ds;
//					this.dataGrid1.DataMember="HouseNoSalesView";
//				}
//				catch(Exception ex)
//				{
//					MessageBox.Show(ex.StackTrace);
//				}
//			}
			else if(e.Button==this.toolBar1.Buttons[1])
			{
				//打印
				this.ppdlgHouse.ShowDialog();
			}
			else
				this.Close();
		}
		#region 打印
		private void pdocHouse_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);
			
			//打印具体数据
			
			try
			{
				HouseBS.NotSellsBS NotSell=new NotSellsBS();
				this.ds=NotSell.select();
				int nLine=1;
				foreach( DataRow rows in this.ds.Tables[0].Rows)
				{
					e.Graphics.DrawString(rows[2].ToString(),objFont,objBrush,nLeft+10,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[5].ToString(),objFont,objBrush,nLeft+100,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[6].ToString(),objFont,objBrush,nLeft+180,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[4].ToString(),objFont,objBrush,nLeft+300,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[0].ToString(),objFont,objBrush,nLeft+420,nTop+60+nLine*30);
					e.Graphics.DrawString(rows[7].ToString(),objFont,objBrush,nLeft+500,nTop+60+nLine*30);
					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 + -