Beispiel #1
0
    public static string statisticsReplyLine(string articleID)
    {
        string sql = "select COUNT(*) as line from dbo.commentinfo where dbo.commentinfo.particleID='" + articleID + "'";

        try
        {
            DbMybbsEntities       entit    = new DbMybbsEntities();
            List <statisticsinfo> listLine = entit.ExecuteStoreQuery <statisticsinfo>(sql).ToList();
            if (listLine.Count <= 0)
            {
                return("N");//没有回复
            }
            else
            {
                int    coun = Convert.ToInt32(listLine[0].line);
                string sql2 = "UPDATE dbo.articleinfo SET wcommentsnum = '" + coun + "' WHERE ID = '" + articleID + "' ";
                int    yud  = entit.ExecuteStoreCommand(sql2);
                if (yud <= 0)
                {
                    return("F");//更新失败
                }
                else
                {
                    return("Y");//更新成功
                }
            }
        }
        catch (Exception e)
        {
            return("E" + e.ToString());//未知错误

            throw;
        }
    }
Beispiel #2
0
 public static string UserRegister(string userName, string email, string phone, string password)
 {
     //INSERT INTO dbo.userinfo VALUES ('中火锅', '123', '*****@*****.**', '110011','','')
     if (!isRegister(userName))
     {
         return("-1");//重复
     }
     else
     {
         publicFunction func  = new publicFunction();
         string         passw = func.Md5encryption(password);
         string         sql   = "INSERT INTO dbo.userinfo VALUES ('" + userName + "', '"
                                + passw + "', '" + email + "', '" + phone + "','','')";
         DbMybbsEntities entit = new DbMybbsEntities();
         int             cont  = entit.ExecuteStoreCommand(sql);
         if (cont >= 1)
         {
             return("1");// 成功
         }
         else
         {
             return("0");//失败
         }
     }
 }
Beispiel #3
0
    public static string setAriEditor(string clasID, string ID, string wTitle, string wContext)
    {
        string wtime = DateTime.Now.ToLocalTime().ToString();
        string sql   = "UPDATE articleinfo SET classID = '" + clasID
                       + "' ,wtitle='" + wTitle + "',wpostedtime ='" + wtime + "' ,wcontent='"
                       + wContext + "' WHERE ID='" + ID + "'";
        DbMybbsEntities entit = new DbMybbsEntities();

        try
        {
            int Cou = entit.ExecuteStoreCommand(sql);
            if (Cou == 1)
            {
                return("1");//成功
            }
            else
            {
                return("-1");//失败
            }
        }
        catch (Exception e)
        {
            return("-2");//服务器错误

            throw;
        }
    }
Beispiel #4
0
    public static string addComment(string particleID, string pcontent, string PIp)
    {
        //insert into dbo.commentinfo VALUES ('da火锅','111111','2','不错不错','2019-05-05 20:56:00','192.168.0.0')
        string sql = "";

        if (useVerifier() != "-1")
        {
            string pusername = useVerifier();
            var    puserID   = (slectUserinfoByusername(pusername).Select(s => s.UID).ToList())[0].ToString();


            string ptime = DateTime.Now.ToLocalTime().ToString();
            sql = "insert into dbo.commentinfo VALUES ('" + pusername + "','"
                  + puserID + "','" + particleID + "','" + pcontent + "','" + ptime + "','" + PIp + "')";
        }
        else
        {
            return("0");//没有登录
        }
        try
        {
            DbMybbsEntities entit = new DbMybbsEntities();
            int             s     = entit.ExecuteStoreCommand(sql);
            if (s == 1)
            {
                return("1");//成功
            }
            else
            {
                return("-1");//失败
            }
        }
        catch (Exception e)
        {
            return("Err" + e.ToString());

            throw;
        }
    }
Beispiel #5
0
    public static string upReading(string articleID)
    {
        //查询阅量
        string sql = "select  dbo.articleinfo.wpviews as line from dbo.articleinfo  where ID='" + articleID + "' ";

        try
        {
            DbMybbsEntities       entit  = new DbMybbsEntities();
            List <statisticsinfo> listSt = entit.ExecuteStoreQuery <statisticsinfo>(sql).ToList();
            if (listSt.Count <= 0)
            {
                return("N");//不存在
            }
            else
            {
                int    numb   = listSt[0].line;//阅读量
                int    newNub = numb + 1;
                string sql1   = "UPDATE dbo.articleinfo SET wpviews = '"
                                + newNub.ToString() + "' WHERE ID = '" + articleID + "' "; //更新访问量

                int yxH = entit.ExecuteStoreCommand(sql1);                                 //受影响行数
                if (yxH <= 0)
                {
                    return("F");//失败
                }
                else
                {
                    return("Y");//成功
                }
            }
        }
        catch (Exception e)
        {
            throw;
        }
    }
Beispiel #6
0
    public static string deleteAriByID(string ID)
    {
        string sqlisSeleingFil = "select * from dbo.fileinfo where articleID in ("
                                 + ID + ") and fType = 'img'";//查询文章是否有图片附件

        string sqlisSeleothFil = "select * from dbo.fileinfo where articleID in ("
                                 + ID + ") and fType = 'other'";//查询文章是否有其他附件

        string sqlSeleFill = "select * from dbo.fileinfo where articleID in ("
                             + ID + ")";//查询是否有附件

        string sqldelFile = "DELETE FROM dbo.fileinfo  WHERE articleID in ("
                            + ID + ")";//删除附件表数据

        string sqlArit = "DELETE FROM dbo.articleinfo WHERE ID in ("
                         + ID + ")";//删除文章表数据

        try
        {
            int             Cou         = 0;
            DbMybbsEntities entit       = new DbMybbsEntities();
            List <fileinfo> allFileList = entit.ExecuteStoreQuery <fileinfo>(sqlSeleFill).ToList();
            if (allFileList.Count > 0)
            {
                List <fileinfo> imgfileList = entit.ExecuteStoreQuery <fileinfo>(sqlisSeleingFil).ToList();
                List <fileinfo> othfileList = entit.ExecuteStoreQuery <fileinfo>(sqlisSeleothFil).ToList();
                if (imgfileList.Count > 0)
                {
                    //删除图片数据及其文件
                    for (int i = 0; i < imgfileList.Count; i++)
                    {
                        string imgurlTemp = imgfileList[i].url;
                        string imgurl     = imgurlTemp.Replace(@"\", @"/");
                        var    path       = HttpContext.Current.Server.MapPath("~" + imgurl);
                        File.Delete(path);
                    }
                }
                if (othfileList.Count > 0)
                {
                    //删除其他文件数据及其文件
                    for (int i = 0; i < othfileList.Count; i++)
                    {
                        string othurl = othfileList[i].url;
                        var    path   = HttpContext.Current.Server.MapPath("~" + othurl);
                        File.Delete(path);
                    }
                }
                int FilCou = entit.ExecuteStoreCommand(sqldelFile);
            }
            int ArCou = entit.ExecuteStoreCommand(sqlArit);
            Cou = ArCou;
            if (ArCou <= 0)
            {
                return("0");//操作数据库失败
            }

            return(Cou.ToString());
        }
        catch (Exception e)
        {
            return("-2");

            throw;
        }
    }