• 大小: 0.35M
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2024-04-30
  • 语言: C#
  • 标签: 软件  记账  

资源简介

一个简单的记账小软件,学习阶段,大神勿喷

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace WindowsFormsApp1
{
  public  class DBHelper
    {
        public static string constring = “server=127.0.0.1\\MSSQLSERVER2;database=accountBook;uid=sa;pwd=1625862412“;
        public static SqlConnection con = null;
        public static SqlCommand cmd = null;
        public static bool sqlOpen(string sql) 
        {
            try
            {
                con = new SqlConnection(constring);
                cmd = new SqlCommand(sql con);
                con.Open();
                int count = 0;
                if (sql.Contains(“insert“) == true && sql.Contains(“update“) == true && sql.Contains(“delete“) == true)
                {
                    count = cmd.ExecuteNonQuery();
                    if (count > 0)
                    {
                        return true;
                    }
                    else 
                    {
                        return false;
                    }
                }
                else if(sql.Contains(“COUNT“))
                {
                    count =Convert.ToInt32( cmd.ExecuteScalar());
                    if (count > 0)
                    {
                        return true;
                    }
                    else 
                    {
                        return false;
                    }
                }
                else
                {
                 SqlDataReader hehe  = cmd.ExecuteReader();
                    if (hehe != null)
                    {
                        return true;
                    }
                    else 
                    {
                        return false;
                    }
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}

评论

共有 条评论