?? 主界面.cs
字號:
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 + -