private void ExecutePrint(object obj) { try { using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString)) { string BillNo = InvoicePrefix + InvoiceNo; string DuplicateCaption = GlobalClass.GetReprintCaption(BillNo); POutVMTouch.PrintBill(BillNo, conn, (TaxInvoice) ? "INVOICE" : "ABBREVIATED TAX INVOCE", DuplicateCaption); GlobalClass.SavePrintLog(BillNo, null, DuplicateCaption); GlobalClass.SetUserActivityLog("Exit", "Re-Print", WorkDetail: string.Empty, VCRHNO: BillNo, Remarks: "Reprinted : " + DuplicateCaption); } ExecuteUndo(null); } catch (Exception ex) { MessageBox.Show(GlobalClass.GetRootException(ex).Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ExecuteSave(object obj) { string strSQL; decimal Taxable, VAT, Amount, Discount, NonTaxable, Rate, Quantity; string BillNo = string.Empty; try { using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString)) { conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { //PIN.PID = conn.ExecuteScalar<int>("SELECT CurNo FROM tblSequence WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran); PIN.PID = Convert.ToInt32(GetInvoiceNo("PID", tran)); PIN.Barcode = string.Empty; PIN.Save(tran); POUT.PID = PIN.PID; POUT.Save(tran); if (POUT.CashAmount > 0) { BillNo = InvoicePrefix + GetInvoiceNo(InvoicePrefix, tran); Quantity = POUT.ChargedHours; Amount = POUT.CashAmount / (1 + (GlobalClass.VAT / 100)); Rate = Amount / Quantity; Discount = 0; NonTaxable = 0; Taxable = Amount - (NonTaxable + Discount); VAT = Taxable * GlobalClass.VAT / 100; TParkingSales PSales = new TParkingSales { BillNo = BillNo, TDate = POUT.OutDate, TMiti = POUT.OutMiti, TTime = POUT.OutTime, BillTo = POUT.BILLTO, BILLTOADD = POUT.BILLTOADD, BILLTOPAN = POUT.BILLTOPAN, Amount = Amount, Discount = Discount, NonTaxable = NonTaxable, Taxable = Taxable, VAT = VAT, GrossAmount = POUT.CashAmount, PID = POUT.PID, UID = POUT.UID, SESSION_ID = POUT.SESSION_ID, FYID = GlobalClass.FYID, TaxInvoice = TaxInvoice }; PSales.Save(tran); TParkingSalesDetails PSalesDetails = new TParkingSalesDetails { BillNo = BillNo, FYID = GlobalClass.FYID, Quantity = Quantity, Rate = Rate, Amount = Amount, Discount = Discount, NonTaxable = NonTaxable, Taxable = Taxable, VAT = VAT, NetAmount = POUT.CashAmount, ProdId = 0, Description = "Parking Charge", PType = 'P' }; PSalesDetails.Save(tran); conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = 'PID' AND FYID = " + GlobalClass.FYID, transaction: tran); conn.Execute("UPDATE tblSequence SET CurNo = CurNo + 1 WHERE VNAME = @VNAME AND FYID = @FYID", new { VNAME = InvoicePrefix, FYID = GlobalClass.FYID }, transaction: tran); GlobalClass.SetUserActivityLog("Exit", "New", VCRHNO: BillNo, WorkDetail: "PID : " + PIN.PID); SyncFunctions.LogSyncStatus(tran, BillNo, GlobalClass.FYNAME); } tran.Commit(); if (!string.IsNullOrEmpty(SyncFunctions.username)) { SyncFunctions.SyncSalesData(SyncFunctions.getBillObject(BillNo), 1); } } if (!string.IsNullOrEmpty(BillNo)) { if (!GlobalClass.NoRawPrinter) { RawPrinterHelper.SendStringToPrinter(GlobalClass.PrinterName, ((char)27).ToString() + ((char)112).ToString() + ((char)0).ToString() + ((char)64).ToString() + ((char)240).ToString(), "Receipt"); //Open Cash Drawer } POutVMTouch.PrintBill(BillNo.ToString(), conn, (TaxInvoice) ? "TAX INVOICE" : "ABBREVIATED TAX INVOCE"); if (TaxInvoice) { POutVMTouch.PrintBill(BillNo.ToString(), conn, "INVOICE"); } } ExecuteUndo(null); } } catch (Exception ex) { MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }