private void Done_Click(object sender, EventArgs e) { Salessystem s1 = new Salessystem(); s1.Invoice_create(subtotal, gst, totalpr, Confirmprodlist); this.Close(); //form is closed and invoice text file generated }
private void CO_Payconfirmbtn_Click(object sender, EventArgs e) { this.Close(); if (Salesprodlist.Rows.Count == 0) { MessageBox.Show("No item added", "Oops", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; }//If there is no registered item in the sales product list, the corresponding message is displayed. Salessystem sy1 = new Salessystem(); for (int i = 0; i < Salesprodlist.Rows.Count; i++) { sy1.Confirmitem(Convert.ToString(Salesprodlist.Rows[i].Cells[1].Value), Convert.ToString(Salesprodlist.Rows[i].Cells[2].Value), Convert.ToString(Convert.ToDecimal(Salesprodlist.Rows[i].Cells[3].Value) / Convert.ToDecimal(Salesprodlist.Rows[i].Cells[2].Value)), Convert.ToString(Salesprodlist.Rows[i].Cells[3].Value), Convert.ToString(Salesprodlist.Rows[i].Cells[5].Value)); } sy1.Gettotalprice(totalpr); sy1.Openinvoice(); //Hand over the contents of the list and corrsponding information to the Salessystem. try { StreamWriter IW = new StreamWriter(@".\InventoryList.txt"); for (int i = 0; i < sic.Count; i++) { IW.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", sic[i].Name, sic[i].ItemCode, sic[i].Quantity, sic[i].Color, sic[i].Price, sic[i].Discount); } IW.Close(); }//Updates the changed items information to Itemlist text file catch (Exception h) { MessageBox.Show("Exception: " + h.Message); //creates an exception if file creation ended up getting corrupted } }