问题描述
namespace网吧计费系统{publicpartialclassFrmEnd:Form{publicFrmEnd(){InitializeComponent();}privatevoidFrmEnd_Load(objectsender,EventArgse){this.CardNum();}publicvoidCardNum(){stringsql=("selectpcIdfromPCInfowherePCUse=1");SqlCommandcmd=newSqlCommand(sql,DBhelper.con);DBhelper.con.Open();SqlDataReaderreader=cmd.ExecuteReader();this.cboNUM.Items.Clear();while(reader.Read()){this.cboNUM.Items.Add(reader[0].ToString());}DBhelper.con.Close();}privatevoidbtnOk_Click(objectsender,EventArgse){this.CardNum();//.通过机器号,查询上机时间与卡号,用时与费用stringsql1=string.Format("select(selectcardNumberfromcardInfowherecardId=recordInfo.cardId)as卡号,beginTimeas上机时间,DATEDIFF(HOUR,beginTime,GETDATE())+1as用时,(DATEDIFF(HOUR,beginTime,GETDATE())+1)*2as费用fromrecordInfowherePCId='{0}'andfreeisnull",txtKa.Text,txtTimeShang.Text,txtTimexia.Text,cboNUM.Text,txtPrice.Text);intcount1=(int)DBhelper.QuqerySingle(sql1);if(count1!=0){MessageBox.Show("查询成功!");}else{MessageBox.Show("查询失败!");}//.查询当前卡的余额stringsql2=string.Format("selectcardBalancefromcardInfowherecardNumber='{0}'andcardPassword='123456'",txtKa.Text);intcount2=(int)DBhelper.QuqerySingle(sql2);if(count2!=0){MessageBox.Show("查询成功!");}else{MessageBox.Show("查询失败!");}//修改计算机使用状态stringsql3=string.Format("updatePCInfosetPCUse=0wherePCId={0}",cboNUM.Text);intcount3=DBhelper.NotQuery(sql1);if(count3!=0){MessageBox.Show("修改成功!");}else{MessageBox.Show("修改失败!");}//更新卡余额stringsql4=string.Format("updatecardInfosetcardBalance=cardBalance-10wherecardNumber='{0}'",txtKa.Text);intcount4=DBhelper.NotQuery(sql4);if(count4!=0){MessageBox.Show("更新成功!");}else{MessageBox.Show("更新失败!");}stringsql5=string.Format("updaterecordInfosetendTime=GETDATE(),free=10wherePCId={0}andfreeisnull",cboNUM.Text);intcount5=DBhelper.NotQuery(sql5);if(count5!=0){MessageBox.Show("更新成功!");}else{MessageBox.Show("更新失败!");}下机功能怎么做