Is a database or a file more suitable to store varying user input and then retrieve values to find average or sum? c#
-
Hello, I have created Windows form application, in which the user inputs data into a form, however the amount of forms each user will have will be different. My initial solution was to have my forms on tabs, and the user can add as many tabs as they want, and a new form gets renderred on each new tab. However I then need to sum and average some of the values from each form, which I struggled to do. It was suggested to me that it would be a better idea to have a single form, and a button which once clicked stores the input data, and refreshes the form, when the user proceeds to the next stage, I would then need to retrieve those values and average or sum them. The stored user input will need to be organised and I will need to recall the values later on. Would it be better to store the user input in a file or to create a database for this sort of thing? I've never done either, so I'm not sure which applies better to the situation. Appreciate any help, thank you.
-
Hello, I have created Windows form application, in which the user inputs data into a form, however the amount of forms each user will have will be different. My initial solution was to have my forms on tabs, and the user can add as many tabs as they want, and a new form gets renderred on each new tab. However I then need to sum and average some of the values from each form, which I struggled to do. It was suggested to me that it would be a better idea to have a single form, and a button which once clicked stores the input data, and refreshes the form, when the user proceeds to the next stage, I would then need to retrieve those values and average or sum them. The stored user input will need to be organised and I will need to recall the values later on. Would it be better to store the user input in a file or to create a database for this sort of thing? I've never done either, so I'm not sure which applies better to the situation. Appreciate any help, thank you.
It is not clear what sort of information is being entered onto the form, or how much. Once the user has entered all the information do you need to save it for a later time? Is this a stand-alone application or will the data be stored among multiple users? You need to address those questions first to decide how much data you will need to manage. For example if the user enters up to twenty transactions and just needs a display or printout with some totals then you should not need to store anything, just perform the calculations. If, however the data will be cumulative over a period of days, weeks or months, then a file or small database is probably necessary.
-
It is not clear what sort of information is being entered onto the form, or how much. Once the user has entered all the information do you need to save it for a later time? Is this a stand-alone application or will the data be stored among multiple users? You need to address those questions first to decide how much data you will need to manage. For example if the user enters up to twenty transactions and just needs a display or printout with some totals then you should not need to store anything, just perform the calculations. If, however the data will be cumulative over a period of days, weeks or months, then a file or small database is probably necessary.
Hello, thank you for your reply, and apologies for the lack of details in my initial question. This is a stand alone application, and the data doesn't need to be saved for a later time, and data will not be shared between users, it's for one user to input their data and carry out an assessment, the user can then note down the results, but none of this needs to be stored into the app for a later time. It's a 2 stage assessment, the first stage requires the user to fill out a number of forms with structural details of columns, depending on how many columns they have, and the second stage needs to sum some of those column values and some will need to be averaged, to then display the final values of the assessment, onto a final form. Only numbers are entered into each form, and results will also be in the form of numbers which are then displayed on a graph. There are around 30 text boxes of user input, which are input into a input form that pops of from a button from the parent form, stage one of the assessment is then carried out for each column on each parent form. Each parent form renderred onto a new tab using this EasyTabs solution Creating a C# Application with Chrome-Style Tabs using EasyTabs in WinForms - YouTube[^] that I found online. I'm an absolute beginner on C# , so I couldn't figure out how I would take a value from each form and display the sum or average onto the final form, if I don't know how many forms there will be for each user during run time, as each user will have a different amount, I was thinking it's maybe some sort of loop during run time, but I'm just not sure what that would look like. After speaking to a friend, they recommended a single form, with a save and refresh button, where the data gets saved onto a file, and then gets retrieved would be better, but there are say 10 different user input values that need to be picked up from each form, and then averaged or summed, I started learning about StreamReader and StreamWriter and how files work in C#, but it was really difficult to figure out how to lay out the data in the file, how to get C# to sum the correct values together etc etc. Thank you for your help.
-
Hello, thank you for your reply, and apologies for the lack of details in my initial question. This is a stand alone application, and the data doesn't need to be saved for a later time, and data will not be shared between users, it's for one user to input their data and carry out an assessment, the user can then note down the results, but none of this needs to be stored into the app for a later time. It's a 2 stage assessment, the first stage requires the user to fill out a number of forms with structural details of columns, depending on how many columns they have, and the second stage needs to sum some of those column values and some will need to be averaged, to then display the final values of the assessment, onto a final form. Only numbers are entered into each form, and results will also be in the form of numbers which are then displayed on a graph. There are around 30 text boxes of user input, which are input into a input form that pops of from a button from the parent form, stage one of the assessment is then carried out for each column on each parent form. Each parent form renderred onto a new tab using this EasyTabs solution Creating a C# Application with Chrome-Style Tabs using EasyTabs in WinForms - YouTube[^] that I found online. I'm an absolute beginner on C# , so I couldn't figure out how I would take a value from each form and display the sum or average onto the final form, if I don't know how many forms there will be for each user during run time, as each user will have a different amount, I was thinking it's maybe some sort of loop during run time, but I'm just not sure what that would look like. After speaking to a friend, they recommended a single form, with a save and refresh button, where the data gets saved onto a file, and then gets retrieved would be better, but there are say 10 different user input values that need to be picked up from each form, and then averaged or summed, I started learning about StreamReader and StreamWriter and how files work in C#, but it was really difficult to figure out how to lay out the data in the file, how to get C# to sum the correct values together etc etc. Thank you for your help.
To be honest, as an absolute beginner I would suggest you forget C# and use a ready made system like Excel. If you are determined to use C# then using some ready made controls such as DataGridView Class (System.Windows.Forms) | Microsoft Docs[^] would probably be better than 30 textboxes. You can then easily iterate the rows and columns to sum or average the numbers.
-
To be honest, as an absolute beginner I would suggest you forget C# and use a ready made system like Excel. If you are determined to use C# then using some ready made controls such as DataGridView Class (System.Windows.Forms) | Microsoft Docs[^] would probably be better than 30 textboxes. You can then easily iterate the rows and columns to sum or average the numbers.
Well that's the thing, I already have it on Excel, and would like to convert it into an application, and although on DataGridView it may not be as separated, and as clear for the user, it probably is the better approach, and like you said it would be a lot easier to obtain the final values. Thank you for your suggestions.
-
Hello, I have created Windows form application, in which the user inputs data into a form, however the amount of forms each user will have will be different. My initial solution was to have my forms on tabs, and the user can add as many tabs as they want, and a new form gets renderred on each new tab. However I then need to sum and average some of the values from each form, which I struggled to do. It was suggested to me that it would be a better idea to have a single form, and a button which once clicked stores the input data, and refreshes the form, when the user proceeds to the next stage, I would then need to retrieve those values and average or sum them. The stored user input will need to be organised and I will need to recall the values later on. Would it be better to store the user input in a file or to create a database for this sort of thing? I've never done either, so I'm not sure which applies better to the situation. Appreciate any help, thank you.
Member 14192597 wrote:
The stored user input will need to be organised and I will need to recall the values later on.
If you put everything in a file of your own format, you'll have to parse all the data to get the information you need. You'll run into problems like keeping the data valid and correct. That's what a database is for, and SQL makes it easy to calculate with the data you have.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
Hello, I have created Windows form application, in which the user inputs data into a form, however the amount of forms each user will have will be different. My initial solution was to have my forms on tabs, and the user can add as many tabs as they want, and a new form gets renderred on each new tab. However I then need to sum and average some of the values from each form, which I struggled to do. It was suggested to me that it would be a better idea to have a single form, and a button which once clicked stores the input data, and refreshes the form, when the user proceeds to the next stage, I would then need to retrieve those values and average or sum them. The stored user input will need to be organised and I will need to recall the values later on. Would it be better to store the user input in a file or to create a database for this sort of thing? I've never done either, so I'm not sure which applies better to the situation. Appreciate any help, thank you.
[A Quiz Application using Windows Form](https://www.c-sharpcorner.com/article/a-quiz-application-using-windows-form/)
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Member 14192597 wrote:
The stored user input will need to be organised and I will need to recall the values later on.
If you put everything in a file of your own format, you'll have to parse all the data to get the information you need. You'll run into problems like keeping the data valid and correct. That's what a database is for, and SQL makes it easy to calculate with the data you have.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
Thank you for your reply, I was wondering if I could have a gridlayout file for each user, rather than a database because I don't need to store the data for a later time (after the user is finished with the app) or I don't need the data to be shared among all users, I just need it to store input from the current user (while the app is still in use) and then retrieve that input in a textbox on a final form, as a sum or average of values inputted into each previous window. However because the number of windows "forms" for each user will be different, and so the number of values added to the list/database/file is not a set amount, I'm trying to figure out how to tell C# to go through each window, pick out the value from that window, add it to the list/database/file, find the average, and display that to a textbox on the a final window. If I was to store the input from each window to a file, then I would need to tell C# to read the file and only pick up the value that I need, add it to a list , find the sum/average and display that to a textbox, however I think it would be difficult to tell C# exactly what to read from the file unless it's in a column/row layout and each cell has a reference.. so I'm not sure how to do this, I have got quite far with the application, and this is the only thing holding me back from completing it, so I would really like to try and make it happen..
-
Thank you for your reply, I was wondering if I could have a gridlayout file for each user, rather than a database because I don't need to store the data for a later time (after the user is finished with the app) or I don't need the data to be shared among all users, I just need it to store input from the current user (while the app is still in use) and then retrieve that input in a textbox on a final form, as a sum or average of values inputted into each previous window. However because the number of windows "forms" for each user will be different, and so the number of values added to the list/database/file is not a set amount, I'm trying to figure out how to tell C# to go through each window, pick out the value from that window, add it to the list/database/file, find the average, and display that to a textbox on the a final window. If I was to store the input from each window to a file, then I would need to tell C# to read the file and only pick up the value that I need, add it to a list , find the sum/average and display that to a textbox, however I think it would be difficult to tell C# exactly what to read from the file unless it's in a column/row layout and each cell has a reference.. so I'm not sure how to do this, I have got quite far with the application, and this is the only thing holding me back from completing it, so I would really like to try and make it happen..
Member 14192597 wrote:
I was wondering if I could have a gridlayout file for each user, rather than a database because I don't need to store the data for a later time (after the user is finished with the app)
You can have a grid, regardless of the source of the data. You might also want to persist the data anyway - if it crashes and the user has to enter it all over again, they will not be very happy. Also, what if I want to make a small change to see the impact on the result? Do I have to enter all data again?
Member 14192597 wrote:
However because the number of windows "forms" for each user will be different, and so the number of values added to the list/database/file is not a set amount, I'm trying to figure out how to tell C# to go through each window, pick out the value from that window, add it to the list/database/file, find the average, and display that to a textbox on the a final window.
Ehr.. first you decide how to store that data in memory. Make it a list, you can add options to save/fetch that list later. To go through each form, you could use a list of forms that you loop. Each form should make its data available through public properties. Add data from form to datalist (not formlist), and at end use in-memory linq to get an average. Good luck :thumbsup:
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.