/// <summary> /// This is the event handler when the user clicks the save tool menu item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveToolStripMenuItem_Click(object sender, EventArgs e) { // configure the file dialog ProductSaveFileDialog.FileName = "Product.txt"; ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.Filter = "Text Files (*.txt)|*txt|All Files (*.*)|*.*"; //open the file dialog var result = ProductSaveFileDialog.ShowDialog(); if (result != DialogResult.Cancel) { //open the stream for writing using (StreamWriter outputStream = new StreamWriter( File.Open(ProductSaveFileDialog.FileName, FileMode.Create))) { //write content - string type - to the file outputStream.WriteLine(Program.product.productID.ToString()); outputStream.WriteLine(Program.product.cost.ToString()); outputStream.WriteLine(Program.product.manufacturer); outputStream.WriteLine(Program.product.model); outputStream.WriteLine(Program.product.RAM_type); outputStream.WriteLine(Program.product.RAM_size); outputStream.WriteLine(Program.product.displaytype); outputStream.WriteLine(Program.product.screensize); outputStream.WriteLine(Program.product.resolution); outputStream.WriteLine(Program.product.CPU_Class); outputStream.WriteLine(Program.product.CPU_brand); outputStream.WriteLine(Program.product.CPU_type); outputStream.WriteLine(Program.product.CPU_speed); outputStream.WriteLine(Program.product.CPU_number); outputStream.WriteLine(Program.product.condition); outputStream.WriteLine(Program.product.OS); outputStream.WriteLine(Program.product.platform); outputStream.WriteLine(Program.product.HDD_size); outputStream.WriteLine(Program.product.HDD_speed); outputStream.WriteLine(Program.product.GPU_Type); outputStream.WriteLine(Program.product.optical_drive); outputStream.WriteLine(Program.product.Audio_type); outputStream.WriteLine(Program.product.LAN); outputStream.WriteLine(Program.product.WIFI); outputStream.WriteLine(Program.product.width); outputStream.WriteLine(Program.product.height); outputStream.WriteLine(Program.product.depth); outputStream.WriteLine(Program.product.weight); outputStream.WriteLine(Program.product.moust_type); outputStream.WriteLine(Program.product.power); outputStream.WriteLine(Program.product.webcam); //cleanup outputStream.Close(); outputStream.Dispose(); //give feedback to the user that the file has been saved //this is a "modal" form MessageBox.Show("File Saved...", "Saving File...", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void saveToolStripButton_Click(object sender, EventArgs e) { //configure save file dialog box ProductSaveFileDialog.FileName = "Powers.txt"; ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.Filter = "Text Files (*.txt)|*.txt | All Files (*.*)|*.*"; //Open Svae File Dialog var ShowDialog = ProductSaveFileDialog.ShowDialog(); if (ShowDialog != DialogResult.Cancel) { //open Sterem Writer to write using (StreamWriter outputString = new StreamWriter( File.Open("Powers.txt", FileMode.Create))) { //Write strings to File outputString.WriteLine(Program.Power.Fighting); outputString.WriteLine(Program.Power.Agility); outputString.WriteLine(Program.Power.Strength); outputString.WriteLine(Program.Power.Endurance); outputString.WriteLine(Program.Power.Reason); outputString.WriteLine(Program.Power.Inutuition); outputString.WriteLine(Program.Power.Popularity); // close outputString.Close(); outputString.Dispose(); } MessageBox.Show("File Saved Succesfully!", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// this is the event handler for the click event of save tool strip menu item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveToolStripMenuItem_Click(object sender, EventArgs e) { // configure the file dialog ProductSaveFileDialog.FileName = "Product.txt"; ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.Filter = "Text Files (*.txt)|*.txt| All Files (*.*)|*.*"; // open file dialog - Modal Form var result = ProductSaveFileDialog.ShowDialog(); if (result != DialogResult.Cancel) { // open file to write using (StreamWriter outputStream = new StreamWriter( File.Open(ProductSaveFileDialog.FileName, FileMode.Create))) { // write stuff to the file outputStream.WriteLine(Program.product.productID); outputStream.WriteLine(Program.product.cost); outputStream.WriteLine(Program.product.manufacturer); outputStream.WriteLine(Program.product.model); outputStream.WriteLine(Program.product.RAM_type); outputStream.WriteLine(Program.product.RAM_size); outputStream.WriteLine(Program.product.displaytype); outputStream.WriteLine(Program.product.screensize); outputStream.WriteLine(Program.product.resolution); outputStream.WriteLine(Program.product.CPU_Class); outputStream.WriteLine(Program.product.CPU_brand); outputStream.WriteLine(Program.product.CPU_type); outputStream.WriteLine(Program.product.CPU_speed); outputStream.WriteLine(Program.product.CPU_number); outputStream.WriteLine(Program.product.condition); outputStream.WriteLine(Program.product.OS); outputStream.WriteLine(Program.product.platform); outputStream.WriteLine(Program.product.HDD_size); outputStream.WriteLine(Program.product.HDD_speed); outputStream.WriteLine(Program.product.GPU_Type); outputStream.WriteLine(Program.product.optical_drive); outputStream.WriteLine(Program.product.Audio_type); outputStream.WriteLine(Program.product.LAN); outputStream.WriteLine(Program.product.WIFI); outputStream.WriteLine(Program.product.width); outputStream.WriteLine(Program.product.height); outputStream.WriteLine(Program.product.depth); outputStream.WriteLine(Program.product.weight); outputStream.WriteLine(Program.product.moust_type); outputStream.WriteLine(Program.product.power); outputStream.WriteLine(Program.product.webcam); // close the file outputStream.Close(); // dispose of the memory outputStream.Dispose(); } MessageBox.Show("File Saved", "Saving...", MessageBoxButtons.OK, MessageBoxIcon.Information); ReminderLabel.Text = string.Empty; NextButton.Enabled = true; } }
private void saveBinaryFileToolStripMenuItem_Click(object sender, EventArgs e) { //confgure the dile dialog ProductSaveFileDialog.FileName = "Product.dat"; ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.Filter = "Binary Files (*.dat)|*.dat| All Files (*.*)|*.*"; //open the file diolog var result = ProductSaveFileDialog.ShowDialog(); if (result != DialogResult.Cancel) { // open a stream to write using (BinaryWriter outputString = new BinaryWriter(File.Open(ProductSaveFileDialog.FileName, FileMode.Create))) { // write stuff to the file outputString.Write(Program.product.productID.ToString()); outputString.Write(Program.product.cost.ToString()); outputString.Write(Program.product.manufacturer); outputString.Write(Program.product.model); outputString.Write(Program.product.RAM_type); outputString.Write(Program.product.RAM_size); outputString.Write(Program.product.displaytype); outputString.Write(Program.product.screensize); outputString.Write(Program.product.resolution); outputString.Write(Program.product.CPU_Class); outputString.Write(Program.product.CPU_brand); outputString.Write(Program.product.CPU_type); outputString.Write(Program.product.CPU_speed); outputString.Write(Program.product.CPU_number); outputString.Write(Program.product.condition); outputString.Write(Program.product.OS); outputString.Write(Program.product.platform); outputString.Write(Program.product.HDD_size); outputString.Write(Program.product.HDD_speed); outputString.Write(Program.product.GPU_Type); outputString.Write(Program.product.optical_drive); outputString.Write(Program.product.Audio_type); outputString.Write(Program.product.LAN); outputString.Write(Program.product.WIFI); outputString.Write(Program.product.width); outputString.Write(Program.product.height); outputString.Write(Program.product.depth); outputString.Write(Program.product.weight); outputString.Write(Program.product.moust_type); outputString.Write(Program.product.power); outputString.Write(Program.product.webcam); // close file outputString.Flush(); outputString.Close(); outputString.Dispose(); //message alerting user the file has been saved MessageBox.Show("Binary File Saved...", "Saving Binary file...", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { //configuration for SaveFileDialog ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.FileName = "DefaultProduct.dat"; ProductSaveFileDialog.Filter = "Binary Files (*.dat)|*.dat|All Files (*.*)|*.*"; var result = ProductSaveFileDialog.ShowDialog(); if (result != DialogResult.Cancel) { //open binary stream to write using (BinaryWriter outputStream = new BinaryWriter( File.Open(ProductSaveFileDialog.FileName, FileMode.Create))) { //write to file outputStream.Write(Program.product.productID.ToString()); outputStream.Write(Program.product.cost.ToString()); outputStream.Write(Program.product.manufacturer); outputStream.Write(Program.product.model); outputStream.Write(Program.product.RAM_type); outputStream.Write(Program.product.RAM_size); outputStream.Write(Program.product.displaytype); outputStream.Write(Program.product.screensize); outputStream.Write(Program.product.resolution); outputStream.Write(Program.product.CPU_Class); outputStream.Write(Program.product.CPU_brand); outputStream.Write(Program.product.CPU_type); outputStream.Write(Program.product.CPU_speed); outputStream.Write(Program.product.CPU_number); outputStream.Write(Program.product.condition); outputStream.Write(Program.product.OS); outputStream.Write(Program.product.platform); outputStream.Write(Program.product.HDD_size); outputStream.Write(Program.product.HDD_speed); outputStream.Write(Program.product.GPU_Type); outputStream.Write(Program.product.optical_drive); outputStream.Write(Program.product.Audio_type); outputStream.Write(Program.product.LAN); outputStream.Write(Program.product.WIFI); outputStream.Write(Program.product.width); outputStream.Write(Program.product.height); outputStream.Write(Program.product.depth); outputStream.Write(Program.product.weight); outputStream.Write(Program.product.moust_type); outputStream.Write(Program.product.power); outputStream.Write(Program.product.webcam); //cleanup outputStream.Close(); outputStream.Dispose(); } } }
/// <summary> /// Save order /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveToolStripMenuItem_Click(object sender, EventArgs e) { ProductSaveFileDialog.FileName = "Product.txt"; ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.Filter = "Text Files (*.txt)|*.txt| All Files (*.*)|*.*"; var result = ProductSaveFileDialog.ShowDialog(); if (result != DialogResult.Cancel) { using (StreamWriter outputString = new StreamWriter( File.Open(ProductSaveFileDialog.FileName, FileMode.Create))) { outputString.WriteLine(Program.product.productID); outputString.WriteLine(Program.product.cost); outputString.WriteLine(Program.product.manufacturer); outputString.WriteLine(Program.product.model); outputString.WriteLine(Program.product.RAM_type); outputString.WriteLine(Program.product.RAM_size); outputString.WriteLine(Program.product.displaytype); outputString.WriteLine(Program.product.screensize); outputString.WriteLine(Program.product.resolution); outputString.WriteLine(Program.product.CPU_Class); outputString.WriteLine(Program.product.CPU_brand); outputString.WriteLine(Program.product.CPU_type); outputString.WriteLine(Program.product.CPU_speed); outputString.WriteLine(Program.product.CPU_number); outputString.WriteLine(Program.product.condition); outputString.WriteLine(Program.product.OS); outputString.WriteLine(Program.product.platform); outputString.WriteLine(Program.product.HDD_size); outputString.WriteLine(Program.product.HDD_speed); outputString.WriteLine(Program.product.GPU_Type); outputString.WriteLine(Program.product.optical_drive); outputString.WriteLine(Program.product.Audio_type); outputString.WriteLine(Program.product.LAN); outputString.WriteLine(Program.product.weight); outputString.Close(); outputString.Dispose(); } MessageBox.Show("File saved succesfully", "Saving", MessageBoxButtons.OK); } }
/// <summary> /// this method handles the Save file from Product Info Form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveStripMenuItem_Click(object sender, EventArgs e) { //configuring the dialog ProductSaveFileDialog.FileName = "Product.txt"; ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.Filter = "Text Files (*.txt)|*.txt| All Files (*.*)|*.*"; //open file dialog - Modal Form var result = ProductSaveFileDialog.ShowDialog(); if (result != DialogResult.Cancel) { //open file using (StreamWriter outputString = new StreamWriter( File.Open(ProductSaveFileDialog.FileName, FileMode.Create))) { //write file outputString.WriteLine(Program.computers.ProductID); outputString.WriteLine(Program.computers.Cost.ToString()); outputString.WriteLine(Program.computers.Condition); outputString.WriteLine(Program.computers.Platform); outputString.WriteLine(Program.computers.OS); outputString.WriteLine(Program.computers.Manufacturer); outputString.WriteLine(Program.computers.Model); outputString.WriteLine(Program.computers.RAMSize); outputString.WriteLine(Program.computers.ScreenSize); outputString.WriteLine(Program.computers.HDDSize); outputString.WriteLine(Program.computers.CPUBrand); outputString.WriteLine(Program.computers.CPUNumber); outputString.WriteLine(Program.computers.GPUType); outputString.WriteLine(Program.computers.CPUType); outputString.WriteLine(Program.computers.CPUSpeed); outputString.WriteLine(Program.computers.WebCam); //close file outputString.Close(); //dispose of the memory outputString.Dispose(); } MessageBox.Show("File Saved", "Saving...", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); var productSaveFileDialogResult = ProductSaveFileDialog.ShowDialog(); if (productSaveFileDialogResult != DialogResult.Cancel) { StreamWriter streamWriter = new StreamWriter(ProductSaveFileDialog.FileName); streamWriter.WriteLine(Program.selectedProduct.ProductID); streamWriter.WriteLine(Program.selectedProduct.Cost); streamWriter.WriteLine(Program.selectedProduct.Manufacturer); streamWriter.WriteLine(Program.selectedProduct.Model); streamWriter.WriteLine(Program.selectedProduct.RAM_type); streamWriter.WriteLine(Program.selectedProduct.RAM_size); streamWriter.WriteLine(Program.selectedProduct.Displaytype); streamWriter.WriteLine(Program.selectedProduct.Screensize); streamWriter.WriteLine(Program.selectedProduct.Resolution); streamWriter.WriteLine(Program.selectedProduct.CPU_Class); streamWriter.WriteLine(Program.selectedProduct.CPU_brand); streamWriter.WriteLine(Program.selectedProduct.CPU_type); streamWriter.WriteLine(Program.selectedProduct.CPU_speed); streamWriter.WriteLine(Program.selectedProduct.CPU_number); streamWriter.WriteLine(Program.selectedProduct.Condition); streamWriter.WriteLine(Program.selectedProduct.OS); streamWriter.WriteLine(Program.selectedProduct.Platform); streamWriter.WriteLine(Program.selectedProduct.HDD_size); streamWriter.WriteLine(Program.selectedProduct.HDD_speed); streamWriter.WriteLine(Program.selectedProduct.GPU_Type); streamWriter.WriteLine(Program.selectedProduct.Optical_drive); streamWriter.WriteLine(Program.selectedProduct.Audio_type); streamWriter.WriteLine(Program.selectedProduct.LAN); streamWriter.WriteLine(Program.selectedProduct.WIFI); streamWriter.WriteLine(Program.selectedProduct.Width); streamWriter.WriteLine(Program.selectedProduct.Height); streamWriter.WriteLine(Program.selectedProduct.Depth); streamWriter.WriteLine(Program.selectedProduct.Weight); streamWriter.WriteLine(Program.selectedProduct.Mouse_type); streamWriter.WriteLine(Program.selectedProduct.Power); streamWriter.WriteLine(Program.selectedProduct.Webcam); streamWriter.Flush(); streamWriter.Close(); } }
/// <summary> /// This is event handler for saveToolStripMenuItem Click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveToolStripMenuItem_Click(object sender, EventArgs e) { // Configure the file dialog ProductSaveFileDialog.FileName = "Hardware.txt"; ProductSaveFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); ProductSaveFileDialog.Filter = "Text Files (*.txt)|*.txt| All Files (*.*)|*.*"; var resultFile = ProductSaveFileDialog.ShowDialog(); if (resultFile != DialogResult.Cancel) { // This will open up the file dialog using (StreamWriter output = new StreamWriter(File.Open(ProductSaveFileDialog.FileName, FileMode.Create))) { // writing up data to the file output.WriteLine(Program.product.productID.ToString()); output.WriteLine(Program.product.cost); output.WriteLine(Program.product.manufacturer); output.WriteLine(Program.product.model); output.WriteLine(Program.product.condition); output.WriteLine(Program.product.platform); output.WriteLine(Program.product.OS); output.WriteLine(Program.product.RAM_size); output.WriteLine(Program.product.screensize); output.WriteLine(Program.product.HDD_size); output.WriteLine(Program.product.CPU_brand); output.WriteLine(Program.product.CPU_number); output.WriteLine(Program.product.GPU_Type); output.WriteLine(Program.product.CPU_type); output.WriteLine(Program.product.CPU_speed); output.WriteLine(Program.product.webcam); // cleaning up! output.Close(); output.Dispose(); MessageBox.Show("File Have Been Saved Successfully!", "Saving...", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }