I just designed the Pm System[a simple rather to say], now i wanted to design a color selector for the system, when viewing all pm's it should be shown with different colors similar to google's approach on gmail. below is my existing database schema
我只是设计了Pm系统[简单而不是说],现在我想为系统设计一个颜色选择器,当查看所有pm时,它应该以不同的颜色显示,类似于google在gmail上的方法。下面是我现有的数据库架构
**Messages:**
Id:int identity 1,1
Message: nvarchar(500)
From:nvarchar(100)
To:nvarchar(100)
IsDeleted: Bit
IsRead: Bit
How can i add a Color field in a way that it does not interfere with existing setup. Ex, color for Read messages, color for Deleted Messages[lol] so that i could show distinction using background color
如何以不干扰现有设置的方式添加“颜色”字段。例如,读取消息的颜色,已删除消息的颜色[lol],以便我可以使用背景颜色显示区别
2 个解决方案
#1
3
I'm assuming (perhaps wrongly) this is being output as HTML.
我假设(可能是错误的)这是以HTML格式输出的。
Databases are for data, the colour of a read message is presentation. Rather then store a colour in the database for every single message, or even once in a table just for that, use HTML to indicate its status.
数据库用于数据,读取消息的颜色是表示。而是在数据库中为每条消息存储一种颜色,或者甚至在表格中存储一次,使用HTML来指示其状态。
When you're outputting the message list in HTML add a class that indicates it's status based on the database value:
当您在HTML中输出消息列表时,添加一个类,该类根据数据库值指示其状态:
<div id="message" class="read"> ... message details ... </div>
<div id="message" class="deleted"> ... message details ... </div>
In your CSS define the style for read, deleted etc however you want:
在CSS中定义读取,删除等样式但是你想要:
.read {
background: #e0e0e0;
}
.deleted {
background: #e0e0e0;
color: #ccc;
}
This keeps your database, your HTML, and your CSS all separate which is the way it should be.
这样可以使您的数据库,HTML和CSS保持独立,这是应该的方式。
#2
0
if you want each user has his own color schema you can create a table name usercolor as userid int deleteColor varchar(6) ReadedColor varchar(6) blah blah blah
如果你希望每个用户都有自己的颜色模式,你可以创建一个表名usercolor as userid int deleteColor varchar(6)ReadedColor varchar(6)blah blah blah
and you can store dat in this table as this
并且您可以将dat存储在此表中
userid deleteColor ReadedColor
1 e0e0e0 e0e0e1
userid deleteColor ReadedColor 1 e0e0e0 e0e0e1
in user interface create a combobox that fill with this colors and allow user to select his own color then store data in database
在用户界面中创建一个用这种颜色填充的组合框,并允许用户选择自己的颜色,然后将数据存储在数据库中
every time user loads page read user color data from usercolor table and set related color
每次用户从usercolor表加载页面读取用户颜色数据并设置相关颜色
#1
3
I'm assuming (perhaps wrongly) this is being output as HTML.
我假设(可能是错误的)这是以HTML格式输出的。
Databases are for data, the colour of a read message is presentation. Rather then store a colour in the database for every single message, or even once in a table just for that, use HTML to indicate its status.
数据库用于数据,读取消息的颜色是表示。而是在数据库中为每条消息存储一种颜色,或者甚至在表格中存储一次,使用HTML来指示其状态。
When you're outputting the message list in HTML add a class that indicates it's status based on the database value:
当您在HTML中输出消息列表时,添加一个类,该类根据数据库值指示其状态:
<div id="message" class="read"> ... message details ... </div>
<div id="message" class="deleted"> ... message details ... </div>
In your CSS define the style for read, deleted etc however you want:
在CSS中定义读取,删除等样式但是你想要:
.read {
background: #e0e0e0;
}
.deleted {
background: #e0e0e0;
color: #ccc;
}
This keeps your database, your HTML, and your CSS all separate which is the way it should be.
这样可以使您的数据库,HTML和CSS保持独立,这是应该的方式。
#2
0
if you want each user has his own color schema you can create a table name usercolor as userid int deleteColor varchar(6) ReadedColor varchar(6) blah blah blah
如果你希望每个用户都有自己的颜色模式,你可以创建一个表名usercolor as userid int deleteColor varchar(6)ReadedColor varchar(6)blah blah blah
and you can store dat in this table as this
并且您可以将dat存储在此表中
userid deleteColor ReadedColor
1 e0e0e0 e0e0e1
userid deleteColor ReadedColor 1 e0e0e0 e0e0e1
in user interface create a combobox that fill with this colors and allow user to select his own color then store data in database
在用户界面中创建一个用这种颜色填充的组合框,并允许用户选择自己的颜色,然后将数据存储在数据库中
every time user loads page read user color data from usercolor table and set related color
每次用户从usercolor表加载页面读取用户颜色数据并设置相关颜色