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

📄 主界面.cs

📁 管理学院机房计费系统,VISUAL STUDIO .NET 2003 c# 语言实现,SQL SERVER 2000数据库. 现运行正常.
💻 CS
📖 第 1 页 / 共 5 页
字号:
		public int SjNum(string room)//返回机房的上机人数
		{
			string strSql="select count(*) from 流水帐表 where 上机状态='1' and 上机区域='"+ room +"'";
			SqlCommand cmdSjrs=new SqlCommand(strSql,this.sqlConnection2);
			this.sqlConnection2.Open();
			SqlDataReader rdSjrs=cmdSjrs.ExecuteReader();
			rdSjrs.Read();
			int intReturn = rdSjrs.GetInt32(0);
			rdSjrs.Close();
			this.sqlConnection2.Close();
			return intReturn;
		}

		private void menuItem6_Click(object sender, System.EventArgs e)
		{
			Form 登录;
			登录=new frmLogin();
			登录.ShowDialog();
			this.label13.Text=strTeacher;
			this.menuItem12.Enabled=true;
			this.menuItem13.Enabled=true;
			this.menuItem4.Enabled=true;
			if(frmMain.strTeacherPower=="操作员")
			{
				this.menuItem12.Enabled=false;
				this.menuItem13.Enabled=false;
				this.menuItem4.Enabled=false;
			}
		}

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

		private void menuItem17_Click(object sender, System.EventArgs e)
		{
			this.textBox1.Focus();
			DialogResult result=MessageBox.Show("确定要全部下机吗?","集体下机",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
			if(result==DialogResult.Cancel)
			{
				goto finish;
			}
			//取操作时间,以此时间为下机时间
			string strJtxjMsg="%下机统计%\n";
			//打开上机流水表
			string sqlJtxj="select 条形码 from 流水帐表 where 上机状态=1 and 上机区域='"+ this.comboBox1.Text +"'";
			SqlCommand cmdJtxj=new SqlCommand(sqlJtxj,this.sqlConnection2);
			this.sqlConnection2.Open();
			SqlDataReader rdJtxj=cmdJtxj.ExecuteReader();
			try
			{
				while(rdJtxj.Read())
				{
					//对每一条记录实施下机操作
					DateTime dtNow=DateTime.Now;
					string stuBarcode=rdJtxj.GetString(0);
					strJtxjMsg+=this.Jtxj(dtNow,stuBarcode);
					strJtxjMsg+="\n";
					
				}
				if(strJtxjMsg=="%下机统计%\n")
					strJtxjMsg="机房已空!";
			}
			catch(SqlException exe)
			{
				MessageBox.Show("意外中断,请管理员处理!");
				this.sqlConnection2.Close();
			}
			finally
			{
				rdJtxj.Close();
				this.sqlConnection2.Close();
				MessageBox.Show(strJtxjMsg,"计费系统",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
			finish:
				this.label15.Text=numDqrs(this.comboBox1.Text);

		}

		private void menuItem9_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form 添加用户;
			添加用户=new frmAddUser();
			添加用户.ShowDialog();
		}

		private void menuItem10_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form 充值;
			充值=new frmAddMoney();
			充值.ShowDialog();
		}

		private void menuItem14_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form 统计信息;
			统计信息=new frmStatistic();
			统计信息.Show();
		}
	
		private string numDqrs(string s)//返回当前上机人数
		{
			string sql1="select count(*) from 流水帐表 where 上机状态='1' and 上机区域='"+ s +"'";
			SqlCommand cmd1=new SqlCommand(sql1,this.sqlConnection1);
			this.sqlConnection1.Open();

			SqlDataReader reader1=cmd1.ExecuteReader();
			try
			{	
				reader1.Read();
				string ss="";
				return ss=reader1.GetSqlInt32(0).ToString();
				
			}

			catch(SqlException exe)
			{
				reader1.Close();
				this.sqlConnection1.Close();
				return "error";
			
			}
			finally
			{
				reader1.Close();
				this.sqlConnection1.Close();
			}
		}
		private string numLjrs(string s)//返回当日累计上机人数
		{
			DateTime dtNow=DateTime.Now;
			string strDate=dtNow.Date.ToString();
			string sql1="select count(*) from 流水帐表 where 上机区域='"+ s +"' and 上机时间>'"+ strDate +"'";
			SqlCommand cmd1=new SqlCommand(sql1,this.sqlConnection1);
			this.sqlConnection1.Open();

			SqlDataReader reader1=cmd1.ExecuteReader();
			try
			{	
				reader1.Read();
				string ss="";
				return ss=reader1.GetSqlInt32(0).ToString();
				
			}

			catch(SqlException exe)
			{
				reader1.Close();
				this.sqlConnection1.Close();
				return "error";
			
			}
			finally
			{
				reader1.Close();
				this.sqlConnection1.Close();
			}
		}

		private string monDqcz()//返回当前充值额
		{
			DateTime dtNow=DateTime.Now;
			string strDate=dtNow.Date.ToString();
			string strSql="select sum(收费) from 收费流水表 where 时间>'"+ strDate +"' and 值班教师='"+ frmMain.strTeacher +"'";
			SqlCommand cmdSf=new SqlCommand(strSql,this.sqlConnection2);
			this.sqlConnection2.Open();
			SqlDataReader sdaSf=cmdSf.ExecuteReader();
			try
			{
				if(sdaSf.Read())
				{
					return sdaSf.GetDecimal(0).ToString();
				}
				else 
				{
					return "0";
				}
			}
			
			catch(SqlException exe)
			{
				return "error";
			}
			catch(SqlNullValueException exe)
			{
				return "0";
			}
			finally
			{
				sdaSf.Close();
				this.sqlConnection2.Close();
			}
		}

		private void frmMain_Activated(object sender, System.EventArgs e)
		{
			this.label19.Text=monDqcz();
		}

		private void groupBox3_Enter(object sender, System.EventArgs e)
		{
			//this.groupBox3.Visible=!(this.groupBox3.Visible);
		}

		private void menuItem11_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form 账户管理;
			账户管理=new 账户管理();
			账户管理.ShowDialog();
		}

		private void menuItem16_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form 用户管理;
			用户管理=new 用户管理();
			用户管理.ShowDialog();
		}

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

		private void menuItem12_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form 机房管理;
			机房管理=new 机房管理();
			机房管理.ShowDialog();
		}

		private void menuItem13_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form 收费管理;
			收费管理=new 收费管理();
			收费管理.ShowDialog();
		}

		private void groupBox3_MouseHover(object sender, System.EventArgs e)
		{
			//this.groupBox3.Visible=!(this.groupBox3.Visible);
		}

		private void menuItem18_Click(object sender, System.EventArgs e)
		{
			if(this.groupBox3.Location.X==512)
			{
				this.groupBox2.Width=600;
				this.groupBox3.Location=new Point(640, 64);
				this.groupBox3.Width=128;
			}
			else
			{
				this.groupBox3.Location=new Point(512, 64);
				this.groupBox2.Width=472;
				this.groupBox3.Width=256;
			}
		}

		private void menuItem20_Click(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Form about;
			about=new about();
			about.ShowDialog();
		}











		/// <summary>
		/// /////////////////////forlx
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// 
		public string JtxjForLx(DateTime dt,string StuBarcode)//forlx
		{
			DateTime timeXj=dt;
			String strPrice;
			float floPrice;
			strPrice=this.comboBox1.SelectedValue.ToString();
			floPrice=float.Parse(strPrice);
			String strMsg=StuBarcode+" ";
			String barCode=StuBarcode;
			Decimal bal=0; //余额
			Decimal cost=0;//花费

			//读出帐户余额
			String sql1="select 余额,姓名 from 帐户表 where 条形码='"+ barCode +"'";
			SqlCommand cmd0=new SqlCommand(sql1,this.sqlConnection5);
			try
			{
				if(this.sqlConnection5.State==ConnectionState.Closed)
				{
					this.sqlConnection5.Open();
				}
			}
		
			catch(SqlException exe)
			{
				MessageBox.Show("连接中断,请管理员处理!");
				
			}


			SqlDataReader reader05=cmd0.ExecuteReader();
			reader05.Read();
			bal=(Decimal)reader05.GetSqlDecimal(0);
			strMsg+=reader05.GetString(1);
			reader05.Close();
			this.sqlConnection5.Close();
		
			//读出上机时间,计算时间差
			sql1="select * from 流水帐表 where 条形码='"+ barCode +"' and 上机状态='1'";
			SqlCommand cmd=new SqlCommand(sql1,this.sqlConnection5);
			try
			{
				if(this.sqlConnection5.State==ConnectionState.Closed)
				{
					this.sqlConnection5.Open();
				}
			}
		
			catch(SqlException exe)
			{
				MessageBox.Show("连接中断,请管理员处理!");
				
			}
		
			SqlDataReader reader15=cmd.ExecuteReader();
			if(reader15.Read())
			{
				timeSj=reader15.GetDateTime(2);
				//MessageBox.Show(timeSj.ToString());
			}
			reader15.Close();
			this.sqlConnection5.Close();
			TimeSpan ts=timeXj-timeSj;
			
			//计算花费
			float cost1=float.Parse(ts.Minutes.ToString())*floPrice/60+float.Parse(ts.Hours.ToString())*floPrice+float.Parse(ts.Days.ToString())*floPrice*24;
			cost=(Decimal)cost1;  
			
			int intSjHour=ts.Days*

⌨️ 快捷键说明

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