frmfeed.cs
来自「小区物业管理:管理小区的费用、小区工作人员的编排和工资管理、小区的运作、对住户资」· CS 代码 · 共 339 行
CS
339 行
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace WindowsApplication1
{
/// <summary>
/// frmfeed 的摘要说明。
/// </summary>
public class frmfeed : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private SqlConnection objSqlConn;
private SqlCommand objSqlCmd;
private SqlDataAdapter objSqlDataAdapter;
private DataSet objDataSet;
private SqlDataReader objSqlDataReader;
private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
private System.Windows.Forms.PrintPreviewDialog ppdlgOrderDatails;
private System.Windows.Forms.PrintDialog printDialog2;
private System.Drawing.Printing.PrintDocument pdocOrderDetails;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmfeed()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmfeed));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.pdocOrderDetails = new System.Drawing.Printing.PrintDocument();
this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
this.ppdlgOrderDatails = new System.Windows.Forms.PrintPreviewDialog();
this.printDialog2 = new System.Windows.Forms.PrintDialog();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.groupBox1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.groupBox1.Location = new System.Drawing.Point(16, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(456, 48);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "精确查询";
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button1.Location = new System.Drawing.Point(368, 19);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "定位";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(240, 19);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(120, 23);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 19);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(232, 13);
this.label1.TabIndex = 0;
this.label1.Text = "请输入需要查询的业主名或房间号:";
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button2.Location = new System.Drawing.Point(488, 24);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 24);
this.button2.TabIndex = 1;
this.button2.Text = "全部";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16, 64);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(552, 232);
this.dataGrid1.TabIndex = 2;
//
// button3
//
this.button3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button3.Location = new System.Drawing.Point(288, 304);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(88, 32);
this.button3.TabIndex = 3;
this.button3.Text = "打印";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button4.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button4.Location = new System.Drawing.Point(384, 304);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(88, 32);
this.button4.TabIndex = 4;
this.button4.Text = "打印预览";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button5.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button5.Location = new System.Drawing.Point(480, 304);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(88, 32);
this.button5.TabIndex = 5;
this.button5.Text = "关闭";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// pdocOrderDetails
//
this.pdocOrderDetails.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pdocOrderDetails_PrintPage);
//
// pageSetupDialog1
//
this.pageSetupDialog1.Document = this.pdocOrderDetails;
//
// ppdlgOrderDatails
//
this.ppdlgOrderDatails.AutoScrollMargin = new System.Drawing.Size(0, 0);
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(66, 87);
this.ppdlgOrderDatails.MinimumSize = new System.Drawing.Size(375, 250);
this.ppdlgOrderDatails.Name = "ppdlgOrderDatails";
this.ppdlgOrderDatails.TransparencyKey = System.Drawing.Color.Empty;
this.ppdlgOrderDatails.Visible = false;
//
// printDialog2
//
this.printDialog2.Document = this.pdocOrderDetails;
//
// frmfeed
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(584, 350);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.button2);
this.Controls.Add(this.groupBox1);
this.Name = "frmfeed";
this.Text = "收费查询";
this.Load += new System.EventHandler(this.frmfeed_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
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 煤气费 from trigfee where Musername='"+name+"' or Mhomenumber='"+name+"' and Mtype='已交'",objSqlConn);
objDataSet=new DataSet();
objSqlDataAdapter.Fill(objDataSet,"trigfee");
//将DATAGRID控件绑定到数据集表
this.dataGrid1.SetDataBinding(objDataSet,"trigfee");
}
private void frmfeed_Load(object sender, System.EventArgs e)
{
}
private void button6_Click(object sender, System.EventArgs e)
{
}
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 trigfee where Mtype='已交'",objSqlConn);
objDataSet=new DataSet();
objSqlDataAdapter.Fill(objDataSet,"trigfee");
//将DATAGRID控件绑定到数据集表
this.dataGrid1.SetDataBinding(objDataSet,"trigfee");
}
private void button4_Click(object sender, System.EventArgs e)
{
this.ppdlgOrderDatails .ShowDialog ();
}
private void button3_Click(object sender, System.EventArgs e)
{
if (this.printDialog2 .ShowDialog ()==DialogResult.OK )
{
this.pdocOrderDetails .Print ();
}
}
private void button5_Click(object sender, System.EventArgs e)
{
this.Close();
}
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 ();
objSqlCmd=new SqlCommand ("Select * from userfee",objSqlConn);
objSqlDataReader=objSqlCmd.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 + -
显示快捷键?