what would an Expert do?
Posted on 2011-09-30
i'm writing a customer support app (vs 2010\vb.net\mysql) for my company. it's very straightforward, get customer details and populate a bunch of controls - txt fields, listboxes, etc. there's also a bunch of transactional functionality through buttons. never having written, or worked with, a customer support app before, i made the mistake of having the app work only with a single customer at a time. but now there's a need to work with more than one customer - identical data (but for diff customers), identical functionality.
my question is this: what is the best way to manage this kind of identical duplication of data\functionality? basically, i simply created a tab control and put all the original controls on tab page one, and then made a copy of them on tab page two and renamed them from txtCustomerName --> txtCustomerName2, txtCustomerID --> txtCustomerID2, etc. then, i just set a flag recording what tab page i'm on, and all the code behind behaves according to the flag. The problem with this is that i've basically doubled the amount of code i have,
if i'm on tab page 1 then
elseif i'm on tab page 2 then
is there a better way to manage these types of more-or-less identical collections of controls\functionality? for example, i'd like to put even a couple more tab pages on my tab control and let them have 3 or 4 different customers open at the same time, but i'm sure i'm not handling this problem in the best way.
any advice is greatly appreciated...