frmfeesel.cs

来自「小区物业管理:管理小区的费用、小区工作人员的编排和工资管理、小区的运作、对住户资」· CS 代码 · 共 417 行 · 第 1/2 页

CS
417
字号
			this.ppdlgOrderDatails.AutoScrollMinSize = new System.Drawing.Size(0, 0);
			this.ppdlgOrderDatails.ClientSize = new System.Drawing.Size(400, 300);
			this.ppdlgOrderDatails.Document = this.pdocOrderDetails;
			this.ppdlgOrderDatails.Enabled = true;
			this.ppdlgOrderDatails.Icon = ((System.Drawing.Icon)(resources.GetObject("ppdlgOrderDatails.Icon")));
			this.ppdlgOrderDatails.Location = new System.Drawing.Point(22, 29);
			this.ppdlgOrderDatails.MinimumSize = new System.Drawing.Size(375, 250);
			this.ppdlgOrderDatails.Name = "ppdlgOrderDatails";
			this.ppdlgOrderDatails.TransparencyKey = System.Drawing.Color.Empty;
			this.ppdlgOrderDatails.Visible = false;
			// 
			// pdocOrderDetails
			// 
			this.pdocOrderDetails.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pdocOrderDetails_PrintPage);
			// 
			// printDialog2
			// 
			this.printDialog2.Document = this.pdocOrderDetails;
			// 
			// pageSetupDialog1
			// 
			this.pageSetupDialog1.Document = this.pdocOrderDetails;
			// 
			// frmfeesel
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(8, 16);
			this.ClientSize = new System.Drawing.Size(632, 398);
			this.Controls.Add(this.button6);
			this.Controls.Add(this.button5);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.groupBox1);
			this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(640, 432);
			this.MinimumSize = new System.Drawing.Size(640, 432);
			this.Name = "frmfeesel";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "费用查询";
			this.Load += new System.EventHandler(this.frmfeesel_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void groupBox1_Enter(object sender, System.EventArgs e)
		{
		
		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void frmfeesel_Load(object sender, System.EventArgs e)
		{
			 
			//DATAGRID
			objSqlConn=new SqlConnection("database=atorregulate;user id=sa;password=;SERVER=(local)");
			objSqlConn.Open();
			objSqlDataAdapter=new SqlDataAdapter();
			objSqlDataAdapter.SelectCommand=new SqlCommand("select Musername as 业主,Mhomenumber as 房号,Mwater as 水费,Melecticity as 电费, Mcar as 停车费,Mregulate as 管理费,Mrange as 排污费,Mgas as 煤气费 from userfee",objSqlConn);
			objDataSet=new DataSet();
			objSqlDataAdapter.Fill(objDataSet,"userfee");
			//将DATAGRID控件绑定到数据集表
			this.dataGrid1.SetDataBinding(objDataSet,"userfee");
			
		}

		private void label1_Click(object sender, System.EventArgs e)
		{
		
		}

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

		private void button3_Click(object sender, System.EventArgs e)
		{
			string name=this.textBox1.Text;
			DialogResult objDialogResult = MessageBox.Show("确定已收取各住户所有费用?","确认",MessageBoxButtons.YesNo);
			if(objDialogResult.Equals(DialogResult.Yes))
			{
				try
				{
					objSqlConn=new SqlConnection("database=atorregulate;user id=sa;password=;SERVER=(local)");
					objSqlConn.Open();
					objSqlCommand=new SqlCommand("delete from userfee where Musername='"+name+"' or Mhomenumber='"+name+"'",objSqlConn);
					this.objSqlCommand.ExecuteNonQuery();
					MessageBox.Show("已成功交费","服务器确认");
				}
				catch(SqlException ex)
				{
					MessageBox.Show(ex.ToString());
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string name=this.textBox1.Text;
			objSqlConn=new SqlConnection("database=atorregulate;user id=sa;password=;SERVER=(local)");
			objSqlConn.Open();
			objSqlDataAdapter=new SqlDataAdapter();
			objSqlDataAdapter.SelectCommand=new SqlCommand("select Musername as 业主,Mhomenumber as 房号,Mwater as 水费,Melecticity as 电费, Mcar as 停车费,Mregulate as 管理费,Mrange as 排污费,Mgas as 煤气费,Mtype as 状态 from trigfee where Musername='"+name+"' or Mhomenumber='"+name+"'",objSqlConn);
			objDataSet=new DataSet();
			objSqlDataAdapter.Fill(objDataSet,"trigfee");
			//将DATAGRID控件绑定到数据集表
			this.dataGrid1.SetDataBinding(objDataSet,"trigfee");
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			objSqlConn=new SqlConnection("database=atorregulate;user id=sa;password=;SERVER=(local)");
			objSqlConn.Open();
			objSqlDataAdapter=new SqlDataAdapter();
			objSqlDataAdapter.SelectCommand=new SqlCommand("select Musername as 业主,Mhomenumber as 房号,Mwater as 水费,Melecticity as 电费, Mcar as 停车费,Mregulate as 管理费,Mrange as 排污费,Mgas as 煤气费 from userfee",objSqlConn);
			objDataSet=new DataSet();
			objSqlDataAdapter.Fill(objDataSet,"userfee");
			//将DATAGRID控件绑定到数据集表
			this.dataGrid1.SetDataBinding(objDataSet,"userfee");
		}

		private void button6_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void button5_Click(object sender, System.EventArgs e)
		{
			this.ppdlgOrderDatails .ShowDialog ();
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			if (this.printDialog2 .ShowDialog ()==DialogResult.OK )
			{
				this.pdocOrderDetails .Print ();
			}
		}

		private void pdocOrderDetails_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			Font objFont=new Font ("Tahoma",11,FontStyle.Regular );
			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 .Bottom );

			e.Graphics .DrawLine (objPen,nLeft,nTop,nLeft+nWidth,nTop);
			e.Graphics .DrawLine (objPen,nLeft,nTop+nHeight,nLeft+nWidth,nTop+nHeight);
			e.Graphics .DrawLine (objPen,nLeft,nTop,nLeft,nTop+nHeight);
			e.Graphics .DrawLine (objPen,nLeft+nWidth,nTop,nLeft+nWidth,nTop+nHeight);

			e.Graphics.DrawString ("住户交费细目",new Font ("Garamond",36,FontStyle.Bold ),Brushes.Blue ,nLeft+30,nTop+10);
			e.Graphics.DrawString ("业主",objFont,objBrush ,nLeft+20,nTop+60);
			e.Graphics.DrawString ("房间号",objFont,objBrush ,nLeft+70,nTop+60);
			e.Graphics.DrawString ("水费",objFont,objBrush ,nLeft+140,nTop+60);
			e.Graphics.DrawString ("电费",objFont,objBrush ,nLeft+280,nTop+60);
			e.Graphics.DrawString ("停车费",objFont,objBrush ,nLeft+430,nTop+60);
			e.Graphics.DrawString ("管理费",objFont,objBrush ,nLeft+520,nTop+60);
			e.Graphics.DrawString ("排污费",objFont,objBrush ,nLeft+520,nTop+60);
			e.Graphics.DrawString ("煤气费",objFont,objBrush ,nLeft+520,nTop+60);
			try
			{
				objSqlConn=new SqlConnection ("Server=(local);database=atorregulate;user id=sa;password=;");
				objSqlConn.Open ();
				objSqlCommand=new SqlCommand ("Select * from userfee",objSqlConn);
				objSqlDataReader=objSqlCommand.ExecuteReader ();			

				int nLine=1;
				while(objSqlDataReader.Read ())
				{
					e.Graphics .DrawString (objSqlDataReader["Musername"].ToString (),objFont,objBrush,nLeft+20,nTop+60+nLine*30);
					e.Graphics .DrawString (objSqlDataReader["Mhomenumber"].ToString (),objFont,objBrush,nLeft+70,nTop+60+nLine*30);
					e.Graphics .DrawString (objSqlDataReader["Mwater"].ToString (),objFont,objBrush,nLeft+140,nTop+60+nLine*30);
					e.Graphics .DrawString (objSqlDataReader["Melecticity"].ToString (),objFont,objBrush,nLeft+280,nTop+60+nLine*30);
					e.Graphics .DrawString (objSqlDataReader["Mcar"].ToString (),objFont,objBrush,nLeft+430,nTop+60+nLine*30);
					e.Graphics .DrawString (objSqlDataReader["Mregulate"].ToString (),objFont,objBrush,nLeft+520,nTop+60+nLine*30);
					e.Graphics .DrawString (objSqlDataReader["Mrange"].ToString (),objFont,objBrush,nLeft+520,nTop+60+nLine*30);
					e.Graphics .DrawString (objSqlDataReader["Mgas"].ToString (),objFont,objBrush,nLeft+520,nTop+60+nLine*30);
					nLine++;
				}
			}
			catch(SqlException ex)
			{
				MessageBox.Show (ex.Message );
			}
		}
	}
}

⌨️ 快捷键说明

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