So I have a GUI using MSVS 2010 and I am creating many forms.
My main form opens up my text file "database" and concats the proper data to a different opened file. If the opened file has data that does not match in the database file then I would like to add that data to the database file.
With that being said, when a button "dataBaseSaveButton_Click" is clicked a new form will pop up that has textboxes reading: Machine, Name, PTP Name, CMP Name, T-Width, Feeder Pitch. Most of the fields will be auto-populated and others the user will have to enter in.
Also in the form there is another "save" button. Now, on this form, the save button will actually take the data in the textboxes and open up the proper file (the database file) and save it (update the database) in a certain format.
The "Save To Data Base" form looks like this:
My code from the main form looks like this (when the button is clicked):
private void dataBaseSaveButton_Click(object sender, EventArgs e)
{
int unknownCP4Counter = theCP4UnknownList.Distinct().Count();
foreach (var line in theCP4UnknownList.Distinct())
{
var splitUnknowns = line.Split(' ');
KTS_Save saveForm = new KTS_Save("CP4", splitUnknowns[0], splitUnknowns[1], splitUnknowns[3], splitUnknowns[4], openDataBase2File.FileName, unknownCP4Counter);
saveForm.ShowDialog();
unknownCP4Counter--;
}
}
The code for the Save To Data Base form looks like:
private string _Machine;
private string _Name;
private string _PtpName;
private string _TapeWidth;
private string _FeederPitch;
private string _DataBaseFileName;
public KTS_Save()
{
InitializeComponent();
}
public KTS_Save(string Machine, string Name, string PtpName, string TapeWidth, string FeederPitch, string DBFileName, int Counter)
{
InitializeComponent();
_Machine = Machine;
_Name = Name;
_PtpName = PtpName;
_TapeWidth = TapeWidth;
_FeederPitch = FeederPitch;
_DataBaseFileName = DBFileName;
machineTextBox.Text = _Machine;
nameTextBox.Text = _Name;
ptpNameTextBox.Text = _PtpName;
tapeWidthTextBox.Text = _TapeWidth;
feederPitchTextBox.Text = _FeederPitch;
counterLabel.Text = Counter.ToString();
}
private void dataBaseSaveButton_Click(object sender, EventArgs e)
{
//This is where I need help.
}
What I need help with is actually printing out all of the textbox data into the file that already exists.
I know this is probably not the most efficient way to do things, so if you have any recommendations please let me know! :)
(Oh yeah..)
I would like the program to run like so (or similar):
- From the main form, click on the button and the Save To Data Base form will pop up.
- The user will enter in the appropriate fields (textboxes).
- The user will click the "Save To Data Base" button and the data will be written the the textfile that is passed in through the main form.
- Or else, the user will click the upper right "X" (close) to not save to the data base.