private void btnPrintSelected_Click(object sender, EventArgs e) { if (dgvTransactions.SelectedRows.Count < 1) { MessageBox.Show("Please select the invoice first, thank you!"); return; } // Print to PDF :) // Process.Start("JTS_Invoice_pdf.exe", dgvTransactions.SelectedRows[0].Cells[1].Value.ToString()); Invoices.CreateInvoice(int.Parse(dgvTransactions.SelectedRows[0].Cells[1].Value.ToString())); }
private void btnSave_Click(object sender, EventArgs e) { //Get the Values from PurchaseSales Form First transactionsTable transaction = new transactionsTable(); //Get the ID of Customer Here //Lets get name of the customer first if (cbCustomer.SelectedIndex < 0) { MessageBox.Show("Must select a Customer!"); return; } // string deaCustName = "Frank Shannon"; // FROM combobox // customersBLL dc = // dcDAL.GetDeaCustIDFromName(deaCustName); // DETAILS for transaction transaction.invoice_number = Convert.ToInt32(txtInvNumber.Text); transaction.customer_id = Convert.ToInt32(cbCustomer.SelectedValue.ToString()); // dc.id; transaction.transaction_date = dtpBillDate.Value.Date.Ticks; transaction.due_date = dtpDueDate.Value.Date.Ticks; transaction.terms = txtTerms.Text; transaction.nonTaxableSub = decimal.Parse(txtNonTaxable.Text); transaction.taxableSub = decimal.Parse(txtSubTotal.Text); transaction.tax = decimal.Parse(txtSalesTax.Text); transaction.grandTotal = decimal.Parse(txtGrandTotal.Text); transaction.amtPaid = 0; transaction.datePaid = 0; transaction.status = (int)status.notpaid; // transaction.added_by = u.id; transaction.transactionDetails = transactionDT; //Lets Create a Boolean Variable and set its value to false bool success = false; //Actual Code to Insert Transaction And Transaction Details //Create aboolean value and insert transaction bool w = tDAL.Insert_Transaction(transaction); //Use for loop to insert Transaction Details for (int i = 0; i < transactionDT.Rows.Count; i++) { //Get all the details of the product transactionItemsTable transactionDetail = new transactionItemsTable(); transactionDetail.product_name = transactionDT.Rows[i][0].ToString(); transactionDetail.description = transactionDT.Rows[i][1].ToString(); transactionDetail.price = Math.Round(decimal.Parse(transactionDT.Rows[i][2].ToString()), 2); transactionDetail.qty = decimal.Parse(transactionDT.Rows[i][3].ToString()); transactionDetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][4].ToString()), 2); // transactionDetail.description = txtDescription.Text; transactionDetail.invoice_id = Convert.ToInt32(txtInvNumber.Text); // MessageBox.Show(transactionDT.Rows[i]["Taxable"].ToString()); transactionDetail.isTaxable = Convert.ToInt32(transactionDT.Rows[i]["Taxable"].ToString()); //Insert Transaction Details inside the database bool y = tdDAL.InsertTransactionDetail(transactionDetail); success = w && y; } if (success == true) { gParams.lastinvoice = Convert.ToInt32(txtInvNumber.Text); gParams.saveParams(); } else { //Transaction Failed MessageBox.Show("Transaction Failed"); this.Close(); } if (MessageBox.Show("Print this invoice?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // Print to PDF :) // Process.Start("JTS_Invoice_pdf.exe", gParams.lastinvoice.ToString()); Invoices.CreateInvoice(gParams.lastinvoice); } this.Close(); }