private void btn_Confirm_Click(object sender, EventArgs e) { //reducing the stock //variables declaration int stockDesired = Form1.sentStockDesired; int prodStock = Form1.sentProdStock; int indexCount = Form1.currentInvoice; SalesInvoice invoiceGrab = new SalesInvoice(); bigSpender bigBigWinner = new bigSpender(); //reducing the stock Form1.sentProdStock = prodStock - stockDesired; invoiceGrab = Form1.storeData(Form1.invoiceNum, Form1.sentProductName, Form1.sentProductPrice, Form1.sentStockDesired, Form1.sentTotalPrice, Form1.sentProdStock, Form1.sentCurrentItemIndex, invoiceGrab, Form1.sentProdNum); if (invoiceGrab.orderTotalValue >= 20) { bigBigWinner.customerName = Microsoft.VisualBasic.Interaction.InputBox("What is the customer's name?", "Customer's Name", "", 0, 0); bigBigWinner.customerEmail = Microsoft.VisualBasic.Interaction.InputBox("What is the customer's email address?", "Customer's Email", "", 0, 0); Form1.spenderStore = bigBigWinner; Form1.isCusBigSpender = true; } Form1.invoiceGrab = invoiceGrab; Form1.salesInvoiceArray[indexCount] = invoiceGrab; Form1.saleSuccessfulOpen = false; this.Close(); }
private void btn_closeOfBusiness_Click(object sender, EventArgs e) { DateTime currentDateTime = DateTime.Now; int daysStock = 0; double daysValue = 0; int count = 0; SalesInvoice cobFinalInvoice = new SalesInvoice(); cobFinalInvoice.InvoiceNumber = 999; cobFinalInvoice.prodName = "Total Sales for: " + currentDateTime; cobFinalInvoice.prodPrice = 0; cobFinalInvoice.prodStockDesired = daysStock; cobFinalInvoice.orderTotalValue = daysValue; StreamWriter overWriteProducts = new StreamWriter("../../Resources/Products.txt"); //getting in the date time for the date review sheet DateTime todaysDate = DateTime.Now; //turning that date into a string string todaysDateString = todaysDate.ToLongDateString(); StreamWriter writeDaysReview = new StreamWriter("../../Resources/salesReviews/salesReview" + todaysDateString + ".txt"); //string for the contents of final COB salesInvoice string COBfinalStringInvoice = String.Format("{0},{1},{2},{3},{4}", cobFinalInvoice.ToString(), cobFinalInvoice.prodName, cobFinalInvoice.prodPrice, cobFinalInvoice.prodStockDesired, cobFinalInvoice.orderTotalValue); for (int counter = 0; counter < prodNameArray.Length; counter++) { //overwriting to the products.txt file string newLine; newLine = String.Format("{0},{1},{2},{3},{4}", prodNumArray[counter], prodNameArray[counter], prodStockArray[counter], prodPriceArray[counter], prodPicArray[counter]); overWriteProducts.WriteLine(newLine); } overWriteProducts.Close(); for (int counter2 = 0; counter2 < salesInvoiceArray.Length; counter2++) { if (salesInvoiceArray[counter2] != null) { daysStock = daysStock + int.Parse(salesInvoiceArray[count].prodStockDesired.ToString()); daysValue = daysValue + salesInvoiceArray[count].orderTotalValue; string newLine2; newLine2 = String.Format("{0},{1},{2},{3},{4}", salesInvoiceArray[counter2].InvoiceNumber, salesInvoiceArray[counter2].prodName, salesInvoiceArray[counter2].prodPrice, salesInvoiceArray[counter2].prodStockDesired, salesInvoiceArray[counter2].orderTotalValue); writeDaysReview.WriteLine(newLine2); } } writeDaysReview.WriteLine(COBfinalStringInvoice); writeDaysReview.Close(); //streamwriter for printing to the bigSpender sheet StreamWriter printBigSpenders = new StreamWriter("../../Resources/bigSpendersFiles/bigSpenders" + todaysDateString + ".txt"); for (int counter3 = 0; counter3 < bigSpenderArray.Length; counter3++) { if (bigSpenderArray[counter3] != null) { string printToBigSpenders; printToBigSpenders = String.Format("{0},{1},{2},{3}", bigSpenderArray[counter3].customerName, bigSpenderArray[counter3].customerPhoneNum, bigSpenderArray[counter3].customerAddress1, bigSpenderArray[counter3].customerEmail); printBigSpenders.WriteLine(printToBigSpenders); } } printBigSpenders.Close(); MessageBox.Show("Thank you for using this application! \n Your files have been generated. \n \n See you tomorrow!"); this.Close(); }
public static SalesInvoice storeData(int invoiceNumber, string productName, double productPrice, int stockDesired, double totalPrice, int remainderStock, int selectedItemIndex, SalesInvoice salesInvoice, string prodNum) { selectedItemIndex = sentCurrentItemIndex; salesInvoice.InvoiceNumber = invoiceNumber; salesInvoice.prodName = productName; salesInvoice.prodPrice = productPrice; salesInvoice.prodStockDesired = stockDesired; salesInvoice.orderTotalValue = totalPrice; prodStockArray[selectedItemIndex] = remainderStock; //putting InvoiceGrab into the salesInvoice Array salesInvoiceArray[currentInvoice] = salesInvoice; currentInvoice++; //incrementing currentOrder up by one currentOrder++; return(salesInvoice); }