• 大小: 1.13MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-13
  • 语言: C#
  • 标签: c#  winform  充值系统  电话  

资源简介

C#winform电话充值系统-合适C#初学者! DBHelper的增删改查使用方式 和 datagridview等控件的使用!

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;


namespace phoneRecharge
{
    class DBHelper
    {
        private static string connstr = “server=.;database=phoneInfo;uid=sa;pwd=123456;“;
        private static SqlConnection connect;
        private static SqlDataAdapter ada;
        private static DBHelper dbHelper;
        private static SqlCommand cmd;

        public DBHelper()
        {
            connect = new SqlConnection(connstr);
        }

        /// 
        /// 初始化DBhelper实例
        /// 

        /// 
        public static DBHelper instance()
        {
            if (dbHelper == null)
            {
                dbHelper = new DBHelper();
            }
            return dbHelper; 
        }

        /// 
        /// 打开连接
        /// 

        public void DBOpen()
        {
            if (connect.State == ConnectionState.Closed)
            {
                connect.Open();
            }
        }

        /// 
        /// 关闭连接
        /// 

        public void DBClose()
        {
            if (connect.State == ConnectionState.Open)
            {
                connect.Close();
            }
        }


        /// 
        /// 执行SQL语句返回DataSet
        /// 

        /// 
        /// 
        public DataSet GetDataSetBySql(string sql)
        {
            DBOpen();
            DataSet ds = new DataSet();
            ada = new SqlDataAdapter(sqlconnect); 
            ada.Fill(ds);
            return ds;
        }

        /// 
        /// SQL语句执行增删改
        /// 

        /// 
        /// 
        public bool ExecuteSql(string sql) 
        {
            DBOpen();
            cmd = new SqlCommand(sqlconnect);

            try
            {
                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return false;
            }
            finally
            {
                DBClose();
            }
        }

        /// 
        /// 执行SQL语句 返回datareader结果集
        /// 

        /// 
        /// 
        public SqlDataReader ExecuteReaderBySql(string sql)
        {
            DBOpen();
            SqlCommand commond = new SqlCommand(sql connect);

            return commond.ExecuteReader();
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    5242880  2015-08-13 08:22  C#Winform电话充值系统\Database\PhoneInfo.mdf

     文件    2097152  2015-08-13 08:22  C#Winform电话充值系统\Database\PhoneInfo_log.ldf

     文件      16669  2009-04-03 14:37  C#Winform电话充值系统\phoneRecharge\phoneRecharge\bin\Debug\DiamondGreen.ssk

     文件     516096  2009-04-03 14:37  C#Winform电话充值系统\phoneRecharge\phoneRecharge\bin\Debug\IrisSkin2.dll

     文件      16292  2009-04-03 14:37  C#Winform电话充值系统\phoneRecharge\phoneRecharge\bin\Debug\MSN.SSK

     文件     192000  2015-08-12 22:37  C#Winform电话充值系统\phoneRecharge\phoneRecharge\bin\Debug\phoneRecharge.exe

     文件      21464  2016-09-12 10:58  C#Winform电话充值系统\phoneRecharge\phoneRecharge\bin\Debug\phoneRecharge.vshost.exe

     文件        490  2013-06-18 20:28  C#Winform电话充值系统\phoneRecharge\phoneRecharge\bin\Debug\phoneRecharge.vshost.exe.manifest

     文件       2850  2015-08-12 22:30  C#Winform电话充值系统\phoneRecharge\phoneRecharge\DBHelper.cs

     文件       8122  2015-08-12 22:37  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneManager.cs

     文件      27497  2015-08-12 20:00  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneManager.Designer.cs

     文件       8224  2015-08-12 22:37  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneManager.resx

     文件       2083  2015-08-12 22:34  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneOpen.cs

     文件      13100  2015-08-12 22:23  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneOpen.Designer.cs

     文件       6189  2015-08-12 22:23  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneOpen.resx

     文件       3569  2015-08-12 22:30  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneRecharge.cs

     文件      15464  2015-08-12 22:24  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneRecharge.Designer.cs

     文件       6211  2015-08-12 22:24  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneRecharge.resx

     文件       2084  2015-08-12 22:30  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneRecord.cs

     文件       8211  2015-08-12 08:31  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneRecord.Designer.cs

     文件       7498  2015-08-12 08:31  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneRecord.resx

     文件       3376  2015-08-12 08:26  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneSimulate.cs

     文件      10977  2015-08-12 08:16  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneSimulate.Designer.cs

     文件       6211  2015-08-12 08:16  C#Winform电话充值系统\phoneRecharge\phoneRecharge\FromPhoneSimulate.resx

     文件       3964  2015-08-12 07:58  C#Winform电话充值系统\phoneRecharge\phoneRecharge\main.cs

     文件      15906  2015-08-12 07:56  C#Winform电话充值系统\phoneRecharge\phoneRecharge\main.Designer.cs

     文件       6589  2015-08-12 07:56  C#Winform电话充值系统\phoneRecharge\phoneRecharge\main.resx

     文件      12311  2016-09-09 14:47  C#Winform电话充值系统\phoneRecharge\phoneRecharge\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7545  2016-09-09 14:47  C#Winform电话充值系统\phoneRecharge\phoneRecharge\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1311  2016-09-12 10:58  C#Winform电话充值系统\phoneRecharge\phoneRecharge\obj\Debug\phoneRecharge.csproj.FileListAbsolute.txt

............此处省略44个文件信息

评论

共有 条评论