private void CheckOut_btn_Click(object sender, EventArgs e) { double invoice =0; try { Member member = account_Bo.getMember(userName); if (member.type == "A") { if (clientNametextbox.Text != "" && clientMobileNo.Text != "" && clientAddresstextbox.Text != "") { if (nettotalmetroTextBox.Text != "") { if (due_metroTextBox.Text != "Negetive balance") { if (MessageBox.Show("Are you sure?", "Check Out", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { CheckOut_btn.Enabled = false; try { double dis = Convert.ToDouble(discountmetroTextBox.Text); dis = dis / shoppingCartMetroGrid.Rows.Count; for (int i = 0; i < shoppingCartMetroGrid.Rows.Count; i++) { product.productSerialNo = shoppingCartMetroGrid.Rows[i].Cells[0].Value.ToString(); product.productName = shoppingCartMetroGrid.Rows[i].Cells[1].Value.ToString(); product.productModel = shoppingCartMetroGrid.Rows[i].Cells[2].Value.ToString(); product.productBrand = shoppingCartMetroGrid.Rows[i].Cells[3].Value.ToString(); product.importerInvoiceNo = shoppingCartMetroGrid.Rows[i].Cells[4].Value.ToString(); product.importerID = shoppingCartMetroGrid.Rows[i].Cells[5].Value.ToString(); product.importerName = shoppingCartMetroGrid.Rows[i].Cells[6].Value.ToString(); product.productAvailableWarrenty = shoppingCartMetroGrid.Rows[i].Cells[7].Value.ToString(); product.productShortDescription = shoppingCartMetroGrid.Rows[i].Cells[8].Value.ToString(); product.productLongDescription = shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString(); product.productEntryDate = shoppingCartMetroGrid.Rows[i].Cells[10].Value.ToString(); product.productBarcode = shoppingCartMetroGrid.Rows[i].Cells[11].Value.ToString(); product.productEntrier = shoppingCartMetroGrid.Rows[i].Cells[12].Value.ToString(); product.productUnitPrice = shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString(); product.productBatchNo = shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString(); product.soldDate = firstdateTimePicker.Text; //dis = dis / 100; double s = Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString()); s = (s - dis); product.soldPrice = s.ToString(); product.profit = (Convert.ToDouble(s.ToString()) - Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString())).ToString(); account_Bo.setSoldProduct(product,userName); //creditHistorySet invoice = Convert.ToDouble(account_Bo.getInvoice()); double temp = invoice; invoice++; CreditHistory creditHistory = new CreditHistory(); creditHistory.invoiceNo = invoice.ToString(); creditHistory.name = clientNametextbox.Text; creditHistory.address = clientAddresstextbox.Text; creditHistory.mobileNo = clientMobileNo.Text; creditHistory.cash = cash_metroTextBox.Text; creditHistory.due = due_metroTextBox.Text; creditHistory.date = productEntryDTP.Text; creditHistory.reference = userName; account_Bo.setCreditHistory(creditHistory); account_Bo.setCreditHistoryBalance(creditHistory); account_Bo.setInvoice(invoice.ToString(),temp.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } Home_Admin_PrintBill hp = new Home_Admin_PrintBill(); hp.getTotal(nettotalmetroTextBox.Text, clientNametextbox.Text, clientMobileNo.Text, clientAddresstextbox.Text, discountmetroTextBox.Text, totalmetroTextBox.Text,invoice.ToString(),userName); hp.Show(); CheckOut_btn.Enabled = true; totalmetroTextBox.Clear(); returnBarcode_txt.Clear(); soldPrice_txt.Clear(); nettotalmetroTextBox.Clear(); discountmetroTextBox.Clear(); purchasePrice_txt.Clear(); returnSerial_txt.Clear(); due_metroTextBox.Clear(); cash_metroTextBox.Clear(); account_Bo.deleteAllTempProduct(); reloadshoppingCartDataGridview(); } } else { MessageBox.Show("Negative balance!! Please enter the amount in correct format"); } } else { MessageBox.Show("Please fill the discount text"); } } else { MessageBox.Show("Please enter the client details"); } } else { if (clientNametextbox.Text != "" && clientMobileNo.Text != "" && clientAddresstextbox.Text != "") { if (nettotalmetroTextBox.Text != "") { if (due_metroTextBox.Text != "Negetive balance") { if (MessageBox.Show("Are you sure?", "Check Out", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { CheckOut_btn.Enabled = false; try { if (discountmetroTextBox.Text == "0" && nettotalmetroTextBox.Text == cash_metroTextBox.Text) { double dis = 0; dis = dis / shoppingCartMetroGrid.Rows.Count; for (int i = 0; i < shoppingCartMetroGrid.Rows.Count; i++) { product.productSerialNo = shoppingCartMetroGrid.Rows[i].Cells[0].Value.ToString(); product.productName = shoppingCartMetroGrid.Rows[i].Cells[1].Value.ToString(); product.productModel = shoppingCartMetroGrid.Rows[i].Cells[2].Value.ToString(); product.productBrand = shoppingCartMetroGrid.Rows[i].Cells[3].Value.ToString(); product.importerInvoiceNo = shoppingCartMetroGrid.Rows[i].Cells[4].Value.ToString(); product.importerID = shoppingCartMetroGrid.Rows[i].Cells[5].Value.ToString(); product.importerName = shoppingCartMetroGrid.Rows[i].Cells[6].Value.ToString(); product.productAvailableWarrenty = shoppingCartMetroGrid.Rows[i].Cells[7].Value.ToString(); product.productShortDescription = shoppingCartMetroGrid.Rows[i].Cells[8].Value.ToString(); product.productLongDescription = shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString(); product.productEntryDate = shoppingCartMetroGrid.Rows[i].Cells[10].Value.ToString(); product.productBarcode = shoppingCartMetroGrid.Rows[i].Cells[11].Value.ToString(); product.productEntrier = shoppingCartMetroGrid.Rows[i].Cells[12].Value.ToString(); product.productUnitPrice = shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString(); product.productBatchNo = shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString(); product.soldDate = firstdateTimePicker.Text; //dis = dis / 100; double s = Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString()); s = (s - dis); product.soldPrice = s.ToString(); product.profit = (Convert.ToDouble(s.ToString()) - Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString())).ToString(); account_Bo.setSoldProduct(product,userName); //creditHistorySet invoice = Convert.ToDouble(account_Bo.getInvoice()); double temp = invoice; invoice++; CreditHistory creditHistory = new CreditHistory(); creditHistory.invoiceNo = invoice.ToString(); creditHistory.name = clientNametextbox.Text; creditHistory.address = clientAddresstextbox.Text; creditHistory.mobileNo = clientMobileNo.Text; creditHistory.cash = cash_metroTextBox.Text; creditHistory.due = due_metroTextBox.Text; creditHistory.date = productEntryDTP.Text; creditHistory.reference = userName; account_Bo.setCreditHistory(creditHistory); account_Bo.setCreditHistoryBalance(creditHistory); account_Bo.setInvoice(invoice.ToString(),temp.ToString()); Home_Admin_PrintBill hp = new Home_Admin_PrintBill(); hp.getTotal(nettotalmetroTextBox.Text, clientNametextbox.Text, clientMobileNo.Text, clientAddresstextbox.Text, discountmetroTextBox.Text, totalmetroTextBox.Text, invoice.ToString(),userName); hp.Show(); CheckOut_btn.Enabled = true; totalmetroTextBox.Clear(); returnBarcode_txt.Clear(); soldPrice_txt.Clear(); nettotalmetroTextBox.Clear(); discountmetroTextBox.Clear(); purchasePrice_txt.Clear(); returnSerial_txt.Clear(); due_metroTextBox.Clear(); cash_metroTextBox.Clear(); account_Bo.deleteAllTempProduct(); reloadshoppingCartDataGridview(); } } else { MessageBox.Show("Please fill the discount box with '0' and fill cash with NetTotal amount"); cash_metroTextBox.Clear(); discountmetroTextBox.Clear(); CheckOut_btn.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { MessageBox.Show("Negative balance!! Please enter the amount in correct format"); } } else { MessageBox.Show("Please fill the discount text"); } } else { MessageBox.Show("Please enter the client details"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void CheckOut_btn_Click(object sender, EventArgs e) { try { if (clientNametextbox.Text != "" && clienCardNo.Text != "" && clientAddresstextbox.Text != "") { if (nettotalmetroTextBox.Text != "" ) { if (due_metroTextBox.Text != "Negetive balance") { if (MessageBox.Show("Are you sure?", "Check Out", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { CheckOut_btn.Enabled = false; try { double dis = Convert.ToDouble(discountmetroTextBox.Text); //dis = dis / shoppingCartMetroGrid.Rows.Count; for (int i = 0; i < shoppingCartMetroGrid.Rows.Count; i++) { //product.productSerialNo = shoppingCartMetroGrid.Rows[i].Cells[0].Value.ToString(); //product.productName = shoppingCartMetroGrid.Rows[i].Cells[1].Value.ToString(); //product.productModel = shoppingCartMetroGrid.Rows[i].Cells[2].Value.ToString(); //product.productBrand = shoppingCartMetroGrid.Rows[i].Cells[3].Value.ToString(); //product.importerInvoiceNo = shoppingCartMetroGrid.Rows[i].Cells[4].Value.ToString(); //product.importerID = shoppingCartMetroGrid.Rows[i].Cells[5].Value.ToString(); //product.importerName = shoppingCartMetroGrid.Rows[i].Cells[6].Value.ToString(); //product.productAvailableWarrenty = shoppingCartMetroGrid.Rows[i].Cells[7].Value.ToString(); //product.productShortDescription = shoppingCartMetroGrid.Rows[i].Cells[8].Value.ToString(); //product.productLongDescription = shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString(); //product.productEntryDate = shoppingCartMetroGrid.Rows[i].Cells[10].Value.ToString(); //product.productBarcode = shoppingCartMetroGrid.Rows[i].Cells[11].Value.ToString(); //product.productEntrier = shoppingCartMetroGrid.Rows[i].Cells[12].Value.ToString(); //product.productUnitPrice = shoppingCartMetroGrid.Rows[i].Cells[13].Value.ToString(); //product.productBatchNo = shoppingCartMetroGrid.Rows[i].Cells[14].Value.ToString(); //product.soldDate = firstdateTimePicker.Text; ////dis = dis / 100; product.productName = shoppingCartMetroGrid.Rows[i].Cells[0].Value.ToString(); product.productBrand = shoppingCartMetroGrid.Rows[i].Cells[1].Value.ToString(); product.productUnitPrice = shoppingCartMetroGrid.Rows[i].Cells[8].Value.ToString(); product.productShortDescription = shoppingCartMetroGrid.Rows[i].Cells[4].Value.ToString(); product.productEntryDate = shoppingCartMetroGrid.Rows[i].Cells[5].Value.ToString(); product.productBarcode = shoppingCartMetroGrid.Rows[i].Cells[6].Value.ToString(); product.importerName = shoppingCartMetroGrid.Rows[i].Cells[3].Value.ToString(); product.importerInvoiceNo = shoppingCartMetroGrid.Rows[i].Cells[2].Value.ToString(); product.soldPrice = shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString(); product.productEntrier = shoppingCartMetroGrid.Rows[i].Cells[7].Value.ToString(); product.soldDate = firstdateTimePicker.Text; product.refrence = userName; //product.profit = (Convert.ToDouble(soldPrice_txt.Text) - Convert.ToDouble(purchasePrice_txt.Text)).ToString(); double s = Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString()); s = (s - (s*(dis/100))); product.soldPrice = s.ToString(); product.profit = (Convert.ToDouble(s.ToString()) - Convert.ToDouble(shoppingCartMetroGrid.Rows[i].Cells[8].Value.ToString())).ToString(); ////creditHistorySet StreamReader reader = new StreamReader(@"C:\DB\Invoice.txt"); double invoice = Convert.ToDouble(reader.ReadLine()); reader.Close(); invoice++; string invoice2 = "COZY66-" + Convert.ToString(invoice); //CreditHistory creditHistory = new CreditHistory(); //creditHistory.invoiceNo = invoice2; //creditHistory.name = clientNametextbox.Text; //creditHistory.address = clientAddresstextbox.Text; //creditHistory.mobileNo = clienCardNo.Text; //creditHistory.cash = cash_metroTextBox.Text; //creditHistory.due = due_metroTextBox.Text; //creditHistory.date = productEntryDTP.Text; //creditHistory.reference = userName; //account_Bo.setCreditHistory(creditHistory); //account_Bo.setCreditHistoryBalance(creditHistory); StreamWriter writer = new StreamWriter(@"C:\DB\Invoice.txt"); writer.Write(invoice.ToString()); writer.Close(); product.importerID = invoice2; account_Bo.setSoldProduct(product, discountmetroTextBox.Text, shoppingCartMetroGrid.Rows[i].Cells[9].Value.ToString()); } } catch (Exception ex) { MessageBox.Show("!"+ex.Message); } Home_Admin_PrintBill hp = new Home_Admin_PrintBill(); hp.getTotal(nettotalmetroTextBox.Text, clientNametextbox.Text, clienCardNo.Text, clientAddresstextbox.Text, discountmetroTextBox.Text, totalmetroTextBox.Text); hp.Show(); CheckOut_btn.Enabled = true; totalmetroTextBox.Clear(); returnBarcode_txt.Clear(); soldPrice_txt.Clear(); nettotalmetroTextBox.Clear(); discountmetroTextBox.Clear(); purchasePrice_txt.Clear(); returnName_txt.Clear(); due_metroTextBox.Clear(); cash_metroTextBox.Clear(); account_Bo.deleteAllTempProduct(); reloadshoppingCartDataGridview(); } } else { MessageBox.Show("Negative balance!! Please enter the amount in correct format"); } } else { MessageBox.Show("Please fill the discount text"); } } else { MessageBox.Show("Please enter the client details"); } //MessageBox.Show("Your system doesn't fullfill the requirment error code: 0x6DG*"); } catch(Exception ex) { MessageBox.Show("@"+ex.Message); } }