在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → 网吧系统

网吧系统

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:2.22M
  • 下载次数:41
  • 浏览次数:348
  • 发布时间:2021-06-07
  • 实例类别:C#语言基础
  • 发 布 人:fengge111
  • 文件格式:.rar
  • 所需积分:2
 相关标签: 网吧 系统

实例介绍

【实例简介】网吧基础系统

【实例截图】

from clipboard

【核心代码】

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WB
{
    public partial class huiyuanxiaji : Form
    {
        public huiyuanxiaji()
        {
            InitializeComponent();
        }

        private void huiyuanxiaji_Load(object sender, EventArgs e)
        {
            this.xiaji.Items.Clear();

            SqlConnection conn = DBwangba.getConn();
            conn.Open();
            if (conn.State == ConnectionState.Open)
            {
                string sql = "select * from pcInfo where PCUse=1";
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataReader rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    string pcid = rd[0].ToString();
                    this.xiaji.Items.Add(pcid);

                }

                if (xiaji.Items.Count > 0)
                {
                    this.xiaji.SelectedIndex = this.xiaji.Items.Count - 1;
                }
                rd.Close();
                conn.Close();
            }
            else
            {
                MessageBox.Show("连接失败", "连接提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            DateTime dt = DateTime.Now;
            this.downtime.Text = dt.ToString();
        }
        
        private void btn_quxiao_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void xiaji_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str = this.xiaji.Text;


            SqlConnection conn = DBwangba.getConn();
            conn.Open();
            if (conn.State == ConnectionState.Open)
            {

                string sql = "select recordId,cardNumber,a.PCId,a.beginTime from recordInfo as a join cardInfo as b on a.cardId = b.cardId where endTime is null and pcid=" str;
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    string cardNumber = reader[1].ToString();
                    string beginTime = reader[3].ToString();
                    this.name.Text = cardNumber;
                    this.time.Text = beginTime;
                    reader.Close();
                    conn.Close();
                    DateTime bt = Convert.ToDateTime(this.time.Text);   //获取上机时间
                    DateTime et = DateTime.Now;                             // 获取下机时间 当前系统时间
                    TimeSpan ts = Convert.ToDateTime(et).Subtract(bt);      // 系统时间减去上机时间
                    int seconds = (int)ts.TotalSeconds;
                    // 得到连个时间间隔的总秒数(将时间转换为秒)
                    int minutes = seconds / 60;                             // 得到分钟数
                    if (seconds % 60 > 0)
                    {
                        minutes = 1;                                       // 如果描述不能被60整数,则分钟数加1
                    }
                    int hours = minutes / 60;                               // 得到小时数
                    if (minutes % 60 > 0)
                    {
                        hours = 1;                                         // 如果分钟数不能被60整除,则小时数加1
                    }
                    int i = hours * 15;
                    string a = string.Format("{0}", hours);
                    this.shangjiyongshi.Text = a;
                    string b = string.Format("{0}", i);
                    this.feiyong.Text = b;
                }
                else
                {
                    MessageBox.Show("查找不到结果", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;

                }
            }
        }

        private void btn_xiaji_Click(object sender, EventArgs e)
        {
            string str1 = this.xiaji.Text;
            string str2 = this.name.Text;
            string str3 = this.time.Text;
            string str4 = this.downtime.Text;
            string str5 = this.shangjiyongshi.Text;
            string str6 = this.feiyong.Text;
            SqlConnection conn = DBwangba.getConn();
            conn.Open();
            if (conn.State == ConnectionState.Open)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                cmd.CommandText = string.Format("select cardBalance from cardInfo where cardNumber = '{0}'", str2);
                SqlDataReader rd = cmd.ExecuteReader();
                if (rd.Read())
                {
                    string cardBalance = rd[0].ToString();
                    rd.Close();
                    if (int.Parse(cardBalance) < int.Parse(str6))
                    {
                        MessageBox.Show("您的余额不足,请充值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        chongzhi cz = new chongzhi();
                        cz.Show();

                    }
                    else
                    {

                        string sql = string.Format("update recordInfo set endTime ='{0}',free='{1}' where pcid ={2} and endtime is null", str4, str6,str1);
                        int rz = DBwangba.BaseExec(sql);
                        string sql2 = string.Format("update PCInfo set PCUse = 0 where PCId = '{0}'", str1);
                        int rx = DBwangba.BaseExec(sql2);
                        string sql3 = string.Format("update cardInfo set cardBalance = cardBalance - '{0}' where cardNumber= '{1}'", str6, str2);
                        int rc = DBwangba.BaseExec(sql3);
                        if (rz > 0 && rx > 0 && rc > 0)
                        {
                            MessageBox.Show("下机成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("下机失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }

                    }

                }
                conn.Close();

            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            this.downtime.Text = dt.ToString();
        }

        private void time_TextChanged(object sender, EventArgs e)
        {

        }

        private void downtime_TextChanged(object sender, EventArgs e)
        {

        }
    }
}


标签: 网吧 系统

实例下载地址

网吧系统

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警