Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know how the offline feature of software works as i am not able to understand the implementation?

EXAMPLE
If i am working on a software in offline mode and i am creating a transaction which consists of an invoice number (unique number) which is printed on bill. Then how the invoice number is maintained so that inserting data from multiple source does not clash or in other words invoice number does not clash.



EXAMPLE 2
I have 20 client inserting records when the software is in offline mode and after each client inserts some records if the software comes online, how is the software going to manage the invoice number (as previously the software was offline from the real data so the software cannot fetch real time data) and invoice number cannot be managed internally because the invoice number is printed on the bill



Platform :- .Net Framework 3.5
Database :- SQL Server 2008



Thanks in advance
Posted
Updated 26-Dec-14 0:53am
v2
Comments
BillWoodruff 26-Dec-14 6:13am    
Is the database local (on your machine), or on a network, or in the "Cloud" ? And, what software are you using: code you wrote ? 3rd. party application ?
agent_kruger 26-Dec-14 6:35am    
software database is online. i dont know how to implement it so i cannot post the code

A software is an offline application, you just add a feature in it to work with online directories and databases, such as chat applications which are actually offline, but once using the Internet connection you can download the messages or send messages. Since you're talking about the .NET framework, there is a System.Net[^] namespace present to work with networks (including the Internet), which you can use to connect to the internet to make your offline applications online.

The offline application, as you say, is maintained offline. You create a database, and you assign a few columns to it to store the data in it. Such as, the Invoice table would store all of the data assosiated with the Invoice you create. You create a new record, a new row is created inside the table, which would hold the data for it and all of the data, such as invoice number.

Now the last thing, to maintain this state of the application online, is a tricky thing, but not much. If you're well introduced with databases, you might well know that a Primary key[^] is required to make the data easily query-able (I am really cracking up right now as I am not able to come up with the exact word for non-duplicate data, consistence or uh, I don't know). That is why, in the online database you will create the table, as if to store the client's ID too. This is the part which maintains the state of the InvoiceNumber for different users. You might consider creating a composite key[^], by combining the ClientID and the InvoiceID, so that every client can have every possible integer ID, incrementing by 1.

Remember, this is just my opinion of creating the tables to store the data coming from different clients. So, saying that this is always the only way of doing this would be false.
 
Share this answer
 
Comments
agent_kruger 26-Dec-14 6:34am    
primary key is not the solution as how will the software know the next id as it has to print in bill and it is not connected with the real data
Afzaal Ahmad Zeeshan 26-Dec-14 6:37am    
Software won't store the data itself, you're going to use the SQL Server, aren't you? Then just set the InvoiceID to Identity, and it will automatically increment the fields. You, don't need to write anything yourself. Primary key is just to make sure that there is a unique field in the database to query against.

The data related to that InvoiceID can be accessed through the Database by a single SELECT command. That is why, you specify which field is a unique one.
agent_kruger 26-Dec-14 6:40am    
data is online and on offline mode you do not have access to the database that is online so how can you get the auto generated id?
Afzaal Ahmad Zeeshan 26-Dec-14 6:43am    
In the offline mode, there is no uploading of the data to the server. That is why you just work in your own context, that is your own company's data. The complexity comes when you're going to write the application that is going to get the data from different clients.

The InvoiceID that you're creating, must be set to Identity (Identity field is incremented automatically after each record, 1 2 3 so on). That is, which will find the next ID for the Invoice. Get my point?
agent_kruger 26-Dec-14 6:45am    
i am worried about the INVOICE NUMBER (sorry for caps. letters) as the software will not be able to access the online data (real time data) to fetch last id or anything and cannot manage internally as the invoice number would be printed on bill
generate the invoice number based on user or compute, for example
<yyyymmdd><branchcode><usecode><sequencecode>

then you have unique invoice number which will never duplicated even if all other users work on offline. you need to store invoice data locally and sync with main database when you connect online. next invoice number can be generated by using last inserted invoice number.
 
Share this answer
 
v4
Comments
Afzaal Ahmad Zeeshan 26-Dec-14 6:25am    
Pretty much well written, this is the case which is used by the developers of applications to maintain their data for different users.

Please see my answer for more.
agent_kruger 26-Dec-14 6:36am    
how is that possible in case of invoice number is in increment order?
Afzaal Ahmad Zeeshan 26-Dec-14 6:40am    
Invoice will be incrementing for each of the client, which is why the client don't need to worry about anything, first InvoiceID will be 1, then 2 then 3 and so on.

What actually are you worried about? Can you specify?
agent_kruger 26-Dec-14 6:42am    
i am worried about the INVOICE NUMBER (sorry for caps. letters) as the software will not be able to access the online data (real time data) to fetch last id or anything and cannot manage internally as the invoice number would be printed on bill
DamithSL 26-Dec-14 6:49am    
invoice id will be generated per user or host which you generate invoices. then your application only need to worry about what was the last inserted invoice sequence number. add one to it and generate the next.
May be Software you are using is storing data on your computer for e.g. in XML file or something and later on when system comes online, Software will insert data after checking if Record is not present in database.
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 26-Dec-14 6:24am    
All of the softwares are storing the data on the computer. But the OP wanted to know, how do they maintain this data once sent on the network.

Please see my answer for more.
deepakdynamite 26-Dec-14 6:28am    
There must be combinations of some columns which must be unique in nature and values in those columns can be used to check if record is already inserted in database or not....
agent_kruger 26-Dec-14 6:39am    
row id is unique as it is auto generated but in offline mode how will you get the invoice number that is the question
agent_kruger 26-Dec-14 6:44am    
i am worried about the INVOICE NUMBER (sorry for caps. letters) as the software will not be able to access the online data (real time data) to fetch last id or anything and cannot manage internally as the invoice number would be printed on bill
deepakdynamite 26-Dec-14 6:50am    
There are many ways to generate offline ID's which will not be repeated in nature... like yyyymmddhhmmss.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900