Click here to Skip to main content
14,421,922 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am currently working on a C# windows form project that would be used to calculate personal income tax for employee, i am having issue with my client weird requirement of creating allowances dynamically on the form, companies have different policies concerning which allowance would be given to thier employee, i have tried to captured the popular allowances in the application, and also provided a textbox for other allowances, so could enter the sum value of other allowances that is not included in the application form since the application is not going to be used for only one company, the issue now is: my client does not want the others allowances texbox that i included on the form, he wants to be able to click on somthing on the form and that should open where he can type in any other allowances that was not included on the form fields, i have tried the approach of putting a label for allowance name and allowance amount on the form, but this didn't seem to work since enteries could only be done once for each employee very month and thier allowances could up to ten sometimes depending on the company. I dont know whether any of our senior colleadgues here had done anything similar to this, i will appreciate if they could share thier knowledge with me. Thanks

What I have tried:

I have tried the approach of putting a label for allowance name and allowance amount on the form, but this didn't seem to work since enteries could only be done once for each employee very month and thier allowances could up to ten sometimes depending on the company.
Posted
Updated 6-Apr-17 2:12am
Comments
Prifti Constantine 6-Apr-17 2:50am
   
One Solution would be to create a string builder with the appropriate string that would create the markup in the client and then return that string so that it would be created upon demand. If you would like, i could provide some examples, but i am not sure if thats what youre asking . Best regards!
Uwakpeter 6-Apr-17 4:57am
   
this is windows from application, not sure of markup, also, if i use string builder to create the markup that will allow users to enter multiple allowances for a particular employee at once, how will i save them to database and display same in different report columns on the report? seeing i will be saving into only two fields (Allowance name, and Allowance Amount) I will appreciate some examples as you said , thanks.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

It sounds like your "client" wants a pop-up Dialog (modal) for the Allowances.

I would suggest displaying the list of allowances per individual employee in a listbox on the form - make it scrollable so that it doesn't matter how many there are. You could also consider using a ComboBox to enter any allowances that aren't "standard" - but you might run into problems with the Revenue if you go too far away from standard terms.
Reference: Drop-down Lists & Combo Boxes (Windows)[^]

If you do use a modal dialog then you might find this article useful (there are further article links in the article itself)
Transferring information between two forms, Part 1: Parent to Child[^]

Finally on the UI side of things it would be better to use a Button than a label to trigger the dialog.

As to the database side of things, do NOT, I really mean DO NOT store these allowances as a single string. It is a real pain to manage them, a real pain to use them and eventually you will run out of column space to store them. It is the WORST possible design you could choose. (Have you guessed I really don't like the idea? :-) )
A better solution is to have a linking table...e.g.
Table Employee (EmpId, FirstName, LastName, etc)
Table Allowances (AllowId, Description, etc)

A table like this can link allowances to specific employees:
Create table AllowEmpl
(
    EmpId int,   -- Foreign Key to Employee table
    AllowId int  -- Foreign Key to Allowances table
)
By using this construction you can have unlimited allowances per employee, they are easily inserted, searched for, deleted and you won't have to change the database schema when more Allowances are added.
   
Comments
Uwakpeter 6-Apr-17 10:58am
   
if i am using a listbox or drop downlist, what would be the content of the drop down items or list items, seeing that those allowances that are not standard are not known at the time of development, and he wants to be able to enter as many allowances that are available for a particular employee before submitting the form. It's really weird, i am a bit confused.
CHill60 6-Apr-17 13:12pm
   
The comboBox will start to populate when the user types items in. The listbox would be empty the first time. When reopened the listbox would be populated from the database. I would suggest that you add these "non-standard allowances" to the database so they become the "standard" for that client and available to be "picked" from the ComboBox for any employee (otherwise the client will have a lot of retyping to do and will not be happy)

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100