RentHouseDAL/TopupService.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RentHouseModel;
using System.Data.SqlClient;
using System.Data;

namespace RentHouseDAL
{
    public static class TopupService
    {
        public static void AddTopup(Topup t)
        {
            string sql = "insert into Topups values(@UserName,@Amount,@TopupDate)";
            SqlParameter[] para = new SqlParameter[] { 
                new SqlParameter("@UserName",t.UserName),
                new SqlParameter("@Amount",t.Amount),
                new SqlParameter("@TopupDate",t.TopupDate)
            };
            DBHelper.ExecuteCommand(sql,CommandType.Text,para);
        }

        public static int GetTotalByYear(string year)
        {
            string sql = "select SUM(Amount) from Topups where TopupDate like '" + year + "%'";
            return Convert.ToInt32(DBHelper.GetScalar(sql, CommandType.Text, null));
        }

        public static int GetTotalByYearMonth(string year,int month)
        {
            string sql = "select SUM(Amount) from Topups where TopupDate like '"+year+"/" + month.ToString().Trim() + "/%'";
            object obj= DBHelper.GetScalar(sql, CommandType.Text, null);
            if (obj.Equals(System.DBNull.Value))//当obj类型为DBNull时不能转换
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }          
        }

        public static DataTable GetAllYears()
        {
            string sql = "select distinct SUBSTRING(TopupDate,0,5) as Year from Topups";
            return DBHelper.GetTable(sql,CommandType.Text,null);
        }


        public static int GetAllTotal()
        {
            string sql = "select SUM(Amount) from Topups ";
            return Convert.ToInt32(DBHelper.GetScalar(sql, CommandType.Text, null));
        }

        public static int GetTotalByUserName(string username)
        {
            string sql = "select SUM(Amount) from Topups where UserName=@UserName ";
            SqlParameter[] para = new SqlParameter[] { 
后面还有 43 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。