private void BtnSaveFileAs_Click(object sender, EventArgs e) { //Save file with dialog if (this.saveFileDialog.ShowDialog() == DialogResult.OK) { FileMethods.SaveFile(this.saveFileDialog.FileName, RentalManager.Companies); //Update inital save & open directory this.UpdateIntitalDirectory(); //Update filename in program title and change file options this.UpdateFileName(true); } }
private void BtnCloseFile_Click(object sender, EventArgs e) { //Check they want to close file DialogResult result = MessageBox.Show(this, string.Format("Are you sure you want to close file {0}?", FileMethods.FileName), "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.No) { return; } //Clear companies and bind it to update amount RentalManager.Companies.Clear(); this.BindCompaniesToList(RentalManager.Companies); //Clear cars this.BindCarsToList(null); //Update name at top of form and change file options FileMethods.CloseFile(); this.UpdateFileName(false); }
private void BtnLoadFile_Click(object sender, EventArgs e) { //Open dialog for opening a file and wait for a response if (this.openFileDialog.ShowDialog() == DialogResult.OK) { //If user clicks ok then proceed to read the file BindingList <Company> companies = FileMethods.OpenFile(this.openFileDialog.FileName); if (companies == null) { return; } //Set companies to the new opened file and bind to listbox RentalManager.Companies = companies; this.BindCompaniesToList(RentalManager.Companies); //Update inital open directory this.UpdateIntitalDirectory(); //Update filename in program header and change file options this.UpdateFileName(true); } }
private void BtnSaveCurrentFile_Click(object sender, EventArgs e) { //Save file quickly FileMethods.SaveFile(FileMethods.CurrentFileLocation, RentalManager.Companies); }