基本信息
源码名称:C# 地铁一卡通系统源码(含数据库)
源码大小:9.50M
文件格式:.zip
开发语言:C#
更新时间:2018-06-11
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

初学者

请先附加数据库,否则无法进入系统(默认账户1234,密码1234)





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 登录界面
{
    public partial class xiaofeijilucx : Form
    {
        public xiaofeijilucx()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //读取数据库里面的内容
            string stQuery = @"select name 姓名,kahao 卡号,sex 性别,age 年龄 from Type where kahao='"   this.txt_yhkahao.Text   "'";
            DataTable dt = new DataTable();
            dt = DBHelper.ExcuteQuery(stQuery);
            //进行赋值
            txt_yhxm.Text = dt.Rows[0][0].ToString();
            txt_yhxb.Text = dt.Rows[0][2].ToString();
            txt_yhnianlin.Text = dt.Rows[0][3].ToString();
            
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //接收用户输入的信息
            string yhkahao = this.txt_yonghukahao.Text;
            if (yhkahao == "")
            {
                MessageBox.Show("请输入您需要查询用户卡号!");
                return;
            }
            else
            {
                yhkahao = txt_yonghukahao.Text;
                //用户输入信息进行数据库查询
                SqlConnection conn = new SqlConnection(DBHelper.ConnString);
                DataSet ds = new DataSet();
                SqlDataAdapter dap;
                string sqlstr = string.Format("select * from Type where kahao='{0}'", yhkahao);
                dap = new SqlDataAdapter(sqlstr, conn);
                dap.Fill(ds, "XiaoFei");
                SqlCommandBuilder builder = new SqlCommandBuilder(dap);
                this.datavie.AutoGenerateColumns = false;
                this.datavie.DataSource = ds.Tables["XiaoFei"];

                string sql = string.Format("select jine from type where kahao='{0}'", yhkahao);

                SqlDataReader reader= DBHelper.GetDataReader(sql);
                while (reader.Read())
                {
                    zhanghuyue.Text = reader["jine"].ToString();
                }
                reader.Close();

            }
            

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string jine=txt_yhczje.Text;
            int je=int.Parse(jine);

            if (je % 100 == 0)
            {
                string kahao = txt_yhkahao.Text;
                string sqlstr = string.Format("update Type set jine ={0} where kahao={1}", jine, kahao);
                bool i = DBHelper.ExecuteNonQuery(sqlstr);
                if (i == true)
                {
                    MessageBox.Show("充值成功!");
                }
            }
            else
            {
                MessageBox.Show("请充值整100数的金额!");
            }
            

        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {

        }
    }
}