public ActionResult Pay(long Id, decimal PaidAmount, string Seats, OrderedProduct[] newItems, OrderedProduct[] oldItems, int Status = 0) { LogAdapter.Info("Id" + Id.ToString() + "PaidAmount : " + PaidAmount.ToString() + "Seats: " + Seats, "BillConntroller", "Pay"); LogAdapter.Info("Cash drawer start initialise: orderId" + Id.ToString(), "BillConntroller", "Pay"); RTCashDrawer cd = new RTCashDrawer(); LogAdapter.Info("Cash drawer stop initialise: orderId" + Id.ToString(), "BillConntroller", "Pay"); LogAdapter.Info("Cash drawer start open orderid : " + Id.ToString(), "BillConntroller", "Pay"); cd.OpenDrawer(); LogAdapter.Info("Cash drawer stop open orderid : " + Id.ToString(), "BillConntroller", "Pay"); cd.Dispose(); LogAdapter.Info("Cash drawer disposed" + Id.ToString(), "BillConntroller", "Pay"); Order orderToUpdate = null; if (Id == 0) { MembershipUser user = Membership.GetUser(HttpContext.User.Identity.Name); orderToUpdate = new Order() { CreatedBy = (Guid)user.ProviderUserKey, CreatedDate = DateTime.Now }; } else { orderToUpdate = db.Orders.Where(i => i.Id == Id).Single(); } decimal TotalAmount = orderToUpdate.OrderedProducts.Where(op => op.Status == 1).Sum(op => (op.Quantity * op.Price)).Value; decimal BalanceAmount = PaidAmount - TotalAmount; PoleDisplay pole = new PoleDisplay(); //pole.ClearDisplay(); pole.DisplayPaid(string.Format("{0,20}", "Paid: " + string.Format(PaidAmount.ToString("0.00"))), string.Format("{0,20}", "Bal: " + string.Format(BalanceAmount.ToString("0.00")))); pole.Dispose(); bool needPrint = false; if (orderToUpdate.Status != (byte)StatusType.Bill) { needPrint = true; } UpdateBillForOrder(newItems, TotalAmount, PaidAmount, BalanceAmount, ref orderToUpdate); long newId = Save(Id, ref orderToUpdate, StatusType.Paid, newItems, Seats, oldItems, ref needPrint, Status); if (needPrint) { PrintBill(newId); } PushToClient(newId); ModelState.Clear(); return(View("OrderedProducts", new Order())); }
private void ExecuteUndo(object obj) { FocusedElement = (short)Focusable.Barcode; TaxInvoice = false; InvoiceNo = string.Empty; CanChangeInvoiceType = true; PIN = new ParkingIn(); InDate = DateTime.Today.Date; InTime = DateTime.Now; POUT = new ParkingOut(); SetAction(ButtonAction.Init); OnPropertyChanged("IsEntryMode"); PoleDisplay.WriteToDisplay(POUT.ChargedAmount, PoleDisplayType.AMOUNT); }
public ActionResult OrderedProducts(Nullable <int> id) { Order order = null; if (id == null || id == 0) { order = new Order(); } else { order = db.Orders.Where(x => x.Id == id && (x.Status == (byte)StatusType.New || x.Status == (byte)StatusType.Bill)).SingleOrDefault <Order>(); if (order == null) { order = db.Orders.Where(x => x.Id == id).SingleOrDefault <Order>(); if (order != null && order.Status == (byte)StatusType.Paid) { throw new Exception("Custom : Paid already - Could not order/bill again"); } else { string strId = string.Empty; strId = id.ToString(); throw new Exception("Custom : Invalid order Id" + strId); } } else { PoleDisplay pole = new PoleDisplay(); //pole.ClearDisplay(); Nullable <decimal> Total = order.OrderedProducts.Where(op => op.Status == 1).Sum(op => (op.Quantity * op.Price)); pole.DisplayTotal(string.Format("{0,20}", "Total: " + string.Format(Total.Value.ToString("0.00")))); pole.Dispose(); } } ModelState.Clear(); return(View("OrderedProducts", order)); }
private void ExecuteLoad(object obj) { try { using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString)) { PIN.InDate = InDate; PIN.InTime = InTime.ToString("hh:mm tt"); PIN.InMiti = nepDate.CBSDate(PIN.InDate); PIN.VType = VTypeList.First(x => x.VTypeID == PIN.VehicleType); POUT.Rate_ID = (int)conn.ExecuteScalar("SELECT RATE_ID FROM RATEMASTER WHERE IsDefault = 1"); POUT.OutDate = _CurDate; POUT.OutTime = _CurTime; POUT.OutMiti = nepDate.CBSDate(POUT.OutDate); POUT.Interval = GetInterval(PIN.InDate, POUT.OutDate, PIN.InTime, POUT.OutTime); POUT.PID = PIN.PID; CalculateParkingCharge(conn, PIN.InDate.Add(DateTime.Parse(PIN.InTime).TimeOfDay), POUT.OutDate.Add(DateTime.Parse(POUT.OutTime).TimeOfDay), POUT.Rate_ID, PIN.VehicleType); POUT.CashAmount = POUT.ChargedAmount; if (POUT.CashAmount > GlobalClass.AbbTaxInvoiceLimit) { TaxInvoice = true; CanChangeInvoiceType = false; } else { CanChangeInvoiceType = true; } FocusedElement = (short)Focusable.CashAmount; PoleDisplay.WriteToDisplay(POUT.ChargedAmount, PoleDisplayType.AMOUNT); } } catch (Exception ex) { MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }