编码以检查未读消息的状态 [英] coding to check the status of Unread message

查看:83
本文介绍了编码以检查未读消息的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了对未读消息及其来自DB的计数的编码。我不知道如何检查用户是否已阅读该消息。如何在c#中编写代码。建议我....

I have done coding for unread messages and its count from DB. I dont know how to check whether the user has read that message or not. How to code for that in c#. Suggest me....

推荐答案

您必须先向Table_Messages添加一个新位(布尔)列,您可以将其命名为readStatus。将默认值设置为false(未完成),并在消息变为readed时将其chagne为true。然后你可以使用命令来显示Status == false的消息。

你可以这样做:

You must first add a new bit(boolean) column to your Table_Messages, you can name it readStatus. Make the default value to false(unreaded), and chagne it to true when the message become readed. Then you can use a command to show the messages that have Status==false.
You can do something like this:
using (SqlConnection conn = new SqlConnection(connString))
{
      SqlCommand cmd = new SqlCommand("SELECT * FROM messages 
                                       WHERE Status = false", conn);
        try
        {
            conn.Open();
            //code to show result of the command
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
 }



希望这可以帮到你!祝你好运。


Wish this can help you! Good luck.


用户的消息几乎出现在网格视图中吗?!

有一个事件,点击gridview的选定行可以更新表格中的状态是的,这意味着已经阅读了消息。
Message for users almost appears in grid view right ?!
There are an event when click of selected row of gridview you can update status in table to be true that means message has been read.


这篇关于编码以检查未读消息的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆