存储客户信息和客户订单 [英] Storing customer info and customer orders

查看:88
本文介绍了存储客户信息和客户订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个跟踪客户订单的应用程序,它通过序列化到一个文件中来存储整个订单(客户信息和订单).创建新订单时,我会再次将客户信息和订单一起添加到此文件中,这会与第二个订单一起创建相同的客户信息,依此类推...使得按名称执行任何类型的订单查找非常困难,除非你知道订单号.

将客户信息与订单分开的逻辑是什么?我可以保留这个序列化的文件吗?如果没有,如何在一个文档中序列化两个文件?还是应该将其设为MDI?生命的意义是什么? ...? :-\

I have written an app that tracks customer orders, it stores the whole order(customer info and order) by using serialization into one file. When creating a new order I add the customer info again along with the order into this file, this creates the same customer info with a second order and so on...making it very difficult to perform any kind of order lookup by name, unless you know the order number.

What would the logic be to keep the customer info separate from the order? Could I keep this single serialized file? If not, how do I serialize two files in one document? OR should I make this an MDI? What''s the meaning of life? ... ? :-\

推荐答案

我认为您不需要多个文档或多个文件.您可能只在一个文件中存储了两种(几乎)独立类型的对象(客户和订单).
In my opinion you don''t need multiple documents or multiple files. You might just have two (almost) independent types of objects (cutomers and orders) stored in a single file.


流程中的下一个逻辑步骤是在数据库.

即使是短期的更改,您也可以为每个客户实现一个SQLite数据库文件,并使将客户及其所有交易的数据序列化到一个文件中变得更加容易.

这样做的一个巨大优势是您的文件格式由SQLite管理,并且您可以继续添加数据/表而不会破坏现有代码或担心更改文件布局.

另一个好处是您可以建立索引/搜索功能.
此外,还有很多免费工具可以访问您的报告和类似数据.
The next logical step in your process is to implement a customers and orders in a database.

With even a short term change, you could implement a SQLite database file for each customer and make it much easier to serialize your data for a customer and all of their transactions in one file.

A huge advantage to this is that your file format is managed by SQLite, and you can keep adding data/tables without breaking existing code or worrying about changes to the file layout.

Another benefit is that you get built in indexing / searching capabilities.
Further, there are quite a few free tools that will be able to access your data for reports and the like.


可能的布局:
-所有客户都被序列化到一个文件中,并将作为映射CustID<->保留在RAM中. CustData
-订单也具有其ID,并且将被序列化,例如,作为ID.odr文件
-可以通过读取odr文件并使用客户地图(首先阅读)对CustID进行可视化来构建已查看的订单文档.
-订单(ID)列表可以从文件系统中扫描或保存在其自己的文件中
-...

为什么不使用MDI? :)
您可以将列表和地图保存在窗格中,
因为只有一次订购很重要
其他数据可以以自己的形式修改...
A possible layout:
- All customers are serialized in a file and will be hold in RAM as a map CustID <-> CustData
- An order has its ID as well and will be serialized, for example, as ID.odr file
- A viewed order document could be build by reading of its odr-file and the visualisation of the CustID using the customer map (read firstly)
- The list of the orders (IDs) could be scanned from the file system or hold in their own file
- ...

Why MDI or not ? :)
You could hold your lists and maps in the panes,
since only the single order viewing is important
and the other data can be modified in its own forms...


这篇关于存储客户信息和客户订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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