我怎样才能正确present谱写的CheckBoxList到分贝? (理论/逻辑帮助) [英] How can I properly present and write a checkboxlist to a db? (Theory/Logic help)

查看:108
本文介绍了我怎样才能正确present谱写的CheckBoxList到分贝? (理论/逻辑帮助)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意,数据库设计,我现在已经是完全沙盒模式。没有最终确定。一切(这同样是在沙盒模式)是在一个单一的表。另外,我在现在的方式寻找编码的帮助。我在寻找合适的理论/逻辑的方法来这一难题,所以我可以进去和编码自己玩。我学的更好的方式。如果我需要帮助的编码,我会回来这里寻求进一步的帮助。

Please note that the database design I have now is fully in sandbox mode. Nothing is finalized. Everything (again this is in sandbox mode) is in one single table. Also, I'm in now way looking for coding help. I'm looking for the right theoretical/logical approach to this puzzle so I can go in and play with the coding myself. I learn better that way. If I need coding help, I'll come back here for further assistance.

我在创建第几的CheckBoxList用于手动创建的表单提交的过程。我一直在找过多种方式,不仅创造说的CheckBoxList而是将其输入到数据库中。不过,我面临着(主要是因为我还没有遇到过这种情况,我想了解这一点)所面临的挑战是,我不仅需要担心数据库中正确输入的项目,但我最终需要产生一个报告或使这些条目的打印形式。

I'm in the process of creating the first of a few CheckBoxList for a manually created form submittal. I've been looking over multiple ways to not only create said CheckBoxList but to enter it into the database. However, the challenge I'm facing (mainly because I haven't encountered this scenario before and I'd like to learn this) is that I not only need to worry about entering the items correctly in the database but I will eventually need to produce a report or make a printable form from these entries.

比方说,我有一个订单为特定类型的烧烤架的,我需要在全国范围内发出这种形式出来distriution中心。该配送中心将需要拉说,烧烤,如果他们在表格上突出显示。

Let's say I have an order form for a specific type of Barbeque grill and I will need to send this form out to distriution centers across the nation. The distribution centers will need to pull said barbecues if they are highlighted on the form.

下面是为发布包中心的CheckBoxList将是什么样子:

Here's what the CheckBoxList for the distibution centers will look like:


All
Dallas
Miami
Los Angeles
Seattle
New York
Chicago
Phoenix
Montreal

如果特定的城市(或所有城市)进行检查,然后配送中心将拉动装运的烧烤。

If the specific city (or all the cities) are checked, then the distribution center will pull the barbecue grill for shipment.

增加的部分是,我想:


  1. 能够报告指出其配送中心获得订单烧烤和创建该数据库网格视图

  1. be able to create a grid view from this database for reporting to note which distribution center got orders for barbecues and

能够创建报告,告诉在某一个月什么集散中心发送出去烧烤订单(除其他报告)。

be able to create reports to tell what distribution center sent out barbecue orders in a given month (among other reporting).

这里是我与现在玩什么左右。

在我的aspx页面我有所有的配送中心编程的的CheckBoxList输入为列表项,以及一个选项,'ALL'(的配送中心)。

In my aspx page I have a checkboxlist programmed with all the distribution centers entered as a listitem as well as an option for 'ALL' (of the distribution centers).

我也创建了这个表保存在ListItem所有信息的专用柱和编程的sqldataconnection此表与利用该数据库用于此目的的可编程性的发挥。

I also created a dedicated column in this table that holds all the information in the listitem and programmed a sqldataconnection to this table to play with the programmability of leveraging the database for this purpose.

当谈到编写的选择到数据库中,我最初创建一个列每个目的地城市包括全部选项。我玩弄与周围只是把选择到一个单独的列,但与一些我一直在今天阅读有关数据库规范化的信息,前者的选择似乎是一个更好的比后者。对于这个情况的做法正确,如这尤其​​是如果我需要思考的问题报告?难道我把一个单元格中的CheckBoxList数据在一个特定的列?难道我每个配送中心的建立seprate列?我是即使在这里正确的轨道?

When it comes to writing the selections to the database, I originally created a column for each destination city including the 'All' option. I was toying around with just putting the selections into one single column but with some of the information I've been reading today about Database Normalization, the former options seems to be a better one than the latter. Is this correct practice for situations such as this especially if I need to think about reporting? Do I put the CheckBoxList data in one cell in a specific column? Do I create seprate columns for each distribution center? Am I even on the right track here?

推荐答案

根据所要存储的城市的数量,我使用位运算符来存储少量数据。有效地,这将其存储在像这样的表:

Depending on the amount of cities that you want to store, I've used bitwise operators to store small amounts of data. Effectively, it would store it in the table like this:

CityID   Location
2        Dallas
4        Miami
8        New York
16       Chicago
32       Montreal

和保持基地2去为更多的城市。

and keep going in base 2 for additional cities.

当用户的顺序选择多个城市,这被插入到数据库中的城市值是按位或计算。所以,如果他们选择达拉斯,纽约和芝加哥,你会做以下几点:

When your user selects multiple cities for the order, the value that gets inserted into the database for cities is a bitwise OR calculation. So if they select Dallas, New York, and Chicago, you would be doing the following:

2 OR 8 OR 16

这将等于26

现在,你可以使用按位与上所得到的值。因此,如果检查迈阿密下面是评价:

Now, you can use bitwise AND on the resulting value. So if checking for Miami the following is the evaluation:

26 AND 4 = 0

这表明热火没有被选中。这是在评价选择的任何值,它会返回它的ID是这样的:

which indicates that Miami was not selected. Any value that was selected in the evaluation, it would return its ID like this:

26 AND 8 = 8

再次我只用这个数据的小的子集,以及使数据存储尽可能紧凑。计算,它可能是一件小事更贵一些其他的方法,但我不是100%肯定。

Again, I've only used this for small subsets of data, and to make the data storage as compact as possible. Computationally, it may be a trifle more expensive that some other methods, but I'm not 100% certain.

这篇关于我怎样才能正确present谱写的CheckBoxList到分贝? (理论/逻辑帮助)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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