/********************************* * WriteFile(): Json format * ******************************/ private void WriteFile() { deskQuote = new DeskQuote(ClientName, DateTime.Now, DeskWidth, DeskDepth, Drawers, surfMaterials, RushOrderDays, DeskQuotePrice); DeskQuotePrice = deskQuote.CalQuoteTotal(); DeskQuotePrice = Math.Round(DeskQuotePrice, 2); try { string jsonFile = JsonConvert.SerializeObject(deskQuote, Formatting.Indented); string QuoteFile = @"quotes.json"; if (!File.Exists(QuoteFile)) { using (StreamWriter sw = File.CreateText(QuoteFile)) { } } else { using (StreamWriter writer = File.AppendText(QuoteFile)) { writer.WriteLine(jsonFile); } } } catch (Exception ex) { MessageBox.Show(ex.Message + "Error, writing to the file"); } }
/****************************************** * RushOrder: get the * *****************************************/ public void RushOrder() { try { ClientName = clientName.Text; DeskWidth = decimal.Parse(width.Text); DeskDepth = decimal.Parse(depth.Text); Drawers = int.Parse(numOfDrawers.Text); string Material = materialsOutput.Text; Enum.TryParse(Material, out surfMaterials); RushOrderInput = rushOptions.Text; switch (RushOrderInput) { case "3 Days": RushOrderDays = RUSH_DAYS1; break; case "5 Days": RushOrderDays = RUSH_DAYS2; break; case "7 Days": RushOrderDays = RUSH_DAYS3; break; default: RushOrderDays = RUSH_DAYS3; break; } DeskQuote NewOrder = new DeskQuote(ClientName, DateTime.Now, DeskWidth, DeskDepth, Drawers, surfMaterials, RushOrderDays); DeskQuotePrice = NewOrder.CalQuoteTotal(); DeskQuotePrice = Math.Round(DeskQuotePrice, 2); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!"); } }