RentHouseDAL/AdviceService.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 AdviceService
    {
        public static int AddAdvice(Advice advice)
        {
            string sql = "insert into Advices(Title,Details,ADate,Status) values(@Title,@Details,@ADate,@Status)";
            SqlParameter[] para = new SqlParameter[] { 
                new SqlParameter("@Title",advice.Title),
                new SqlParameter("@Details",advice.Details),
                new SqlParameter("@ADate",advice.ADate),
                new SqlParameter("@Status",advice.Status)
            };
            return DBHelper.ExecuteCommand(sql,CommandType.Text,para);
        }

        public static int DeleteAdviceByID(int id)
        {
            string sql = "delete from Advices where ID=@ID";
            SqlParameter[] para = new SqlParameter[] {
                new SqlParameter("@ID",id)
            };
            return DBHelper.ExecuteCommand(sql, CommandType.Text, para);
        }

        public static int GetAllCount()
        {
            string sql = "select count(*) from Advices";
            return Convert.ToInt32(DBHelper.GetScalar(sql,CommandType.Text,null));
        }

        public static int GetHuiCount()
        {
            string sql = "select count(*) from Advices where Status=N'已回复'";
            return Convert.ToInt32(DBHelper.GetScalar(sql, CommandType.Text, null));
        }

        private static IList<Advice> GetAdvicesBySql(string sql)
        {
            List<Advice> list = new List<Advice>();
            using (DataTable dt = DBHelper.GetTable(sql, CommandType.Text, null))
            {
                if (dt.Rows.Count!=0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Advice a = new Advice();
                        a.ID = Convert.ToInt32(dr["ID"]);
                        a.Title = dr["Title"].ToString();
                        a.Details = dr["Details"].ToString();
                        a.ADate = dr["ADate"].ToString();
                        a.Status = dr["Status"].ToString();
后面还有 36 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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