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

📄 jiesuan.cs

📁 用c#写的房源管理软件。刚开始学C#
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb ; 
namespace HoursInfo
{
	/// <summary>
	/// jiesuan 的摘要说明。
	/// </summary>
	public class jiesuan : System.Windows.Forms.Form
	{
		OleDbDataReader reader;
		private System.Windows.Forms.DateTimePicker beginTime;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.DateTimePicker EndTime;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Button start;
		private System.Data.OleDb.OleDbConnection oleDbConnection1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.TextBox textBox4;
		private System.Windows.Forms.TextBox textBox5;
		private System.Windows.Forms.TextBox textBox6;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.Label label14;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public jiesuan()
		{
			//
			// 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()
		{
			this.beginTime = new System.Windows.Forms.DateTimePicker();
			this.label7 = new System.Windows.Forms.Label();
			this.EndTime = new System.Windows.Forms.DateTimePicker();
			this.label6 = new System.Windows.Forms.Label();
			this.start = new System.Windows.Forms.Button();
			this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.textBox3 = new System.Windows.Forms.TextBox();
			this.textBox4 = new System.Windows.Forms.TextBox();
			this.textBox5 = new System.Windows.Forms.TextBox();
			this.textBox6 = new System.Windows.Forms.TextBox();
			this.label9 = new System.Windows.Forms.Label();
			this.label10 = new System.Windows.Forms.Label();
			this.label11 = new System.Windows.Forms.Label();
			this.label12 = new System.Windows.Forms.Label();
			this.label13 = new System.Windows.Forms.Label();
			this.label14 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// beginTime
			// 
			this.beginTime.Location = new System.Drawing.Point(192, 24);
			this.beginTime.Name = "beginTime";
			this.beginTime.Size = new System.Drawing.Size(112, 21);
			this.beginTime.TabIndex = 134;
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(128, 29);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(72, 16);
			this.label7.TabIndex = 133;
			this.label7.Text = "开始时间:";
			// 
			// EndTime
			// 
			this.EndTime.Location = new System.Drawing.Point(392, 24);
			this.EndTime.Name = "EndTime";
			this.EndTime.Size = new System.Drawing.Size(112, 21);
			this.EndTime.TabIndex = 132;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(328, 29);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(72, 16);
			this.label6.TabIndex = 131;
			this.label6.Text = "结束时间:";
			// 
			// start
			// 
			this.start.Location = new System.Drawing.Point(528, 24);
			this.start.Name = "start";
			this.start.Size = new System.Drawing.Size(128, 23);
			this.start.TabIndex = 135;
			this.start.Text = "开始结算";
			this.start.Click += new System.EventHandler(this.start_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(68, 88);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 16);
			this.label1.TabIndex = 136;
			this.label1.Text = "共有房源:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(68, 126);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 16);
			this.label2.TabIndex = 137;
			this.label2.Text = "已 出 租:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(68, 164);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 16);
			this.label3.TabIndex = 138;
			this.label3.Text = "未 出 租:";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(428, 126);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 16);
			this.label4.TabIndex = 140;
			this.label4.Text = "未 出 售:";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(428, 88);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(72, 16);
			this.label5.TabIndex = 139;
			this.label5.Text = "已 出 售:";
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(428, 164);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(72, 16);
			this.label8.TabIndex = 141;
			this.label8.Text = "共 入 帐:";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(132, 83);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(208, 21);
			this.textBox1.TabIndex = 142;
			this.textBox1.Text = "";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(132, 121);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(208, 21);
			this.textBox2.TabIndex = 143;
			this.textBox2.Text = "";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(132, 159);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(208, 21);
			this.textBox3.TabIndex = 144;
			this.textBox3.Text = "";
			// 
			// textBox4
			// 
			this.textBox4.Location = new System.Drawing.Point(492, 83);
			this.textBox4.Name = "textBox4";
			this.textBox4.Size = new System.Drawing.Size(208, 21);
			this.textBox4.TabIndex = 145;
			this.textBox4.Text = "";
			// 
			// textBox5
			// 
			this.textBox5.Location = new System.Drawing.Point(492, 121);
			this.textBox5.Name = "textBox5";
			this.textBox5.Size = new System.Drawing.Size(208, 21);
			this.textBox5.TabIndex = 146;
			this.textBox5.Text = "";
			// 
			// textBox6
			// 
			this.textBox6.Location = new System.Drawing.Point(492, 159);
			this.textBox6.Name = "textBox6";
			this.textBox6.Size = new System.Drawing.Size(208, 21);
			this.textBox6.TabIndex = 147;
			this.textBox6.Text = "";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(700, 164);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(16, 16);
			this.label9.TabIndex = 153;
			this.label9.Text = "元";
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(700, 126);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(16, 16);
			this.label10.TabIndex = 152;
			this.label10.Text = "套";
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(700, 88);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(16, 16);
			this.label11.TabIndex = 151;
			this.label11.Text = "套";
			// 
			// label12
			// 
			this.label12.Location = new System.Drawing.Point(340, 164);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(16, 16);
			this.label12.TabIndex = 150;
			this.label12.Text = "套";
			// 
			// label13
			// 
			this.label13.Location = new System.Drawing.Point(340, 126);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(16, 16);
			this.label13.TabIndex = 149;
			this.label13.Text = "套";
			// 
			// label14
			// 
			this.label14.Location = new System.Drawing.Point(340, 88);
			this.label14.Name = "label14";
			this.label14.Size = new System.Drawing.Size(16, 16);
			this.label14.TabIndex = 148;
			this.label14.Text = "条";
			// 
			// jiesuan
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(784, 222);
			this.Controls.Add(this.label9);
			this.Controls.Add(this.label10);
			this.Controls.Add(this.label11);
			this.Controls.Add(this.label12);
			this.Controls.Add(this.label13);
			this.Controls.Add(this.label14);
			this.Controls.Add(this.textBox6);
			this.Controls.Add(this.textBox5);
			this.Controls.Add(this.textBox4);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.start);
			this.Controls.Add(this.beginTime);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.EndTime);
			this.Controls.Add(this.label6);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "jiesuan";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "结算";
			this.Load += new System.EventHandler(this.jiesuan_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void jiesuan_Load(object sender, System.EventArgs e)
		{
			oleDbConnection1.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Application.StartupPath+"\\矢量工作站.mdb";
			Console.Write (oleDbConnection1.ConnectionString.ToString()); 
			textBox1.Enabled = false;
			textBox2.Enabled = false;
			textBox3.Enabled = false;
			textBox4.Enabled = false;
			textBox5.Enabled = false;
			textBox6.Enabled = false;
		}

		private void start_Click(object sender, System.EventArgs e)
		{
			int TimeInfoNum = 0;
		    string strbeginTime	 = beginTime.Text;
		    string strEndTime	 = EndTime.Text;
			string strCommand1 = "select * from info where 租售日期 >= '"+strbeginTime+"'and 租售日期 <= '"+strEndTime+"'"; 
			// 打开数据连接 
			oleDbConnection1.Open() ;
			OleDbCommand cmd1 = new OleDbCommand ( strCommand1 , oleDbConnection1 ) ; 
			cmd1.CommandText=strCommand1;
			//获得数据集
			reader = cmd1.ExecuteReader() ;
			//获得符合条件的bool值
			//bool df = reader.HasRows;
			while(reader.Read())
			{
				TimeInfoNum++;
			}
			oleDbConnection1.Close();
//----------------------------------------------------------------------------------------------------------------------------
			int yizu = 0;
			strCommand1 = "select * from info where 租售状态 = '已租' and 租售日期 >= '"+strbeginTime+"'and 租售日期 <= '"+strEndTime+"'"; 
			// 打开数据连接 
			oleDbConnection1.Open() ;
			cmd1 = new OleDbCommand ( strCommand1 , oleDbConnection1 ) ; 
			cmd1.CommandText=strCommand1;
			//获得数据集
			reader = cmd1.ExecuteReader() ;
			//获得符合条件的bool值
			//bool df = reader.HasRows;
			while(reader.Read())
			{
				yizu++;
			}
			oleDbConnection1.Close();

			int weizu = 0;
			strCommand1 = "select * from info where 租售状态 = '未租' and 租售日期 >= '"+strbeginTime+"'and 租售日期 <= '"+strEndTime+"'"; 
			// 打开数据连接 
			oleDbConnection1.Open() ;
			cmd1 = new OleDbCommand ( strCommand1 , oleDbConnection1 ) ; 
			cmd1.CommandText=strCommand1;
			//获得数据集
			reader = cmd1.ExecuteReader() ;
			//获得符合条件的bool值
			//bool df = reader.HasRows;
			while(reader.Read())
			{
				weizu++;
			}
			oleDbConnection1.Close();

			int yishou = 0;
			strCommand1 = "select * from info where 租售状态 = '已售' and 租售日期 >= '"+strbeginTime+"'and 租售日期 <= '"+strEndTime+"'"; 
			// 打开数据连接 
			oleDbConnection1.Open() ;
			cmd1 = new OleDbCommand ( strCommand1 , oleDbConnection1 ) ; 
			cmd1.CommandText=strCommand1;
			//获得数据集
			reader = cmd1.ExecuteReader() ;
			//获得符合条件的bool值
			//bool df = reader.HasRows;
			while(reader.Read())
			{
				yishou++;
			}
			oleDbConnection1.Close();

			int weishou = 0;
			strCommand1 = "select * from info where 租售状态 = '未售' and 租售日期 >= '"+strbeginTime+"'and 租售日期 <= '"+strEndTime+"'"; 
			// 打开数据连接 
			oleDbConnection1.Open() ;
			cmd1 = new OleDbCommand ( strCommand1 , oleDbConnection1 ) ; 
			cmd1.CommandText=strCommand1;
			//获得数据集
			reader = cmd1.ExecuteReader() ;
			//获得符合条件的bool值
			//bool df = reader.HasRows;
			while(reader.Read())
			{
				weishou++;
			}
			oleDbConnection1.Close();

			long jinGold = 0;
			strCommand1 = "select * from 金额 where 租售时间 >= '"+strbeginTime+"'and 租售时间 <= '"+strEndTime+"'"; 
			// 打开数据连接 
			oleDbConnection1.Open() ;
			cmd1 = new OleDbCommand ( strCommand1 , oleDbConnection1 ) ; 
			cmd1.CommandText=strCommand1;
			//获得数据集
			reader = cmd1.ExecuteReader() ;
			//获得符合条件的bool值
			//bool df = reader.HasRows;
			while(reader.Read())
			{
				string strgold;
				strgold = reader["收取金额"].ToString();
				if(strgold == "" || strgold == " ")
				{
					strgold = "0";
				}
				long m_nGold = long.Parse(strgold);
				jinGold+=m_nGold;
			}
			oleDbConnection1.Close();

			textBox1.Text = TimeInfoNum.ToString();
			textBox2.Text = yizu.ToString();
			textBox3.Text = weizu.ToString();
			textBox4.Text = yishou.ToString();
			textBox5.Text = weishou.ToString();
			textBox6.Text = jinGold.ToString();
		}
	}
}

⌨️ 快捷键说明

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