Beispiel #1
0
        public ActionResult PrintBill()
        {
            GetListPaymentPrinter();
            OrderDateModel bill = new OrderDateModel();

            bill = OrderService.GetOrderByTable(Class.FloorID, 0);
            if (bill.ListOrderDetail.Count > 0)
            {
                int result = OrderService.UpdateOrder(bill);
                if (result == 1)
                {
                    bill.PrintType = 3;
                    PrinterServer print = new PrinterServer();
                    print.PrintData(bill, PrintData);
                }
            }
            return(Json("Y", JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult SendOrder(string lstOrderItem, string lstModifierItem, string lstSeat)
        {
            var session = Session["User"] as StaffModel;

            if (session != null)
            {
                GetListPrinter();
                try
                {
                    int                  KeyItem       = 0;
                    string               FloorID       = Class.FloorID;
                    List <OrderItem>     listOrderItem = new JavaScriptSerializer().Deserialize <List <OrderItem> >(lstOrderItem);
                    List <ModifierModel> listModifier  = new JavaScriptSerializer().Deserialize <List <ModifierModel> >(lstModifierItem);
                    List <SeatModel>     listSeat      = new JavaScriptSerializer().Deserialize <List <SeatModel> >(lstSeat);
                    OrderDateModel       OrderTemp     = OrderService.GetOrderByTable(FloorID, 0);
                    if (OrderTemp.Status != 2)
                    {
                        if (OrderTemp.ListOrderDetail.Count > 0)
                        {
                            OrderMain.OrderNumber    = OrderTemp.OrderNumber;
                            OrderMain.OrderID        = OrderTemp.OrderID;
                            OrderMain.IsLoadFromData = true;
                            OrderMain.SubTotalVoid();
                        }
                        else
                        {
                            OrderMain.IsLoadFromData = false;
                        }
                        OrderMain.UserName  = session.UserName;
                        OrderMain.FloorID   = FloorID;
                        OrderMain.PrintType = 1;
                        OrderMain.PDA       = 99;
                        foreach (OrderItem item in listOrderItem)
                        {
                            if (OrderMain.IsLoadFromData == false)
                            {
                                if (item.ChangeStatus != 2)
                                {
                                    OrderDetailModel detailModel = new OrderDetailModel();
                                    detailModel.ProductID    = Convert.ToInt32(item.ProductID);
                                    detailModel.Price        = Convert.ToDouble(item.Price);
                                    detailModel.ProductName  = item.ProductName;
                                    detailModel.Qty          = Convert.ToInt32(item.Qty);
                                    detailModel.Total        = Convert.ToDouble(item.Price);
                                    detailModel.ChangeStatus = Convert.ToInt32(item.ChangeStatus);
                                    detailModel.KeyItem      = KeyItem;
                                    detailModel.Seat         = Convert.ToInt32(item.Seat);
                                    detailModel.DynID        = Convert.ToInt32(item.DynID);
                                    detailModel.CategoryID   = Convert.ToInt32(item.CategoryID);
                                    detailModel.KeyItem      = Convert.ToInt32(item.KeyIndex);
                                    var dataPrint = ProductService.GetListPrintJob(detailModel.ProductID, detailModel.CategoryID);
                                    foreach (PrinteJobDetailModel itemPrint in dataPrint)
                                    {
                                        PrinteJobDetailModel p = new PrinteJobDetailModel();
                                        p.ProductID = itemPrint.ProductID;
                                        p.PrinterID = itemPrint.PrinterID;
                                        detailModel.ListPrintJob.Add(p);
                                    }
                                    if (detailModel.ProductID == 0)
                                    {
                                        var dataPrintOpenItem = ProductService.GetListPrintJobOpenItem(detailModel.DynID);
                                        foreach (PrinteJobDetailModel itemPrint in dataPrintOpenItem)
                                        {
                                            PrinteJobDetailModel p = new PrinteJobDetailModel();
                                            p.PrinterID = Convert.ToInt32(itemPrint.PrinterID);
                                            detailModel.ListPrintJob.Add(p);
                                        }
                                    }
                                    OrderMain.addItemToList(detailModel);
                                    foreach (ModifierModel modifi in listModifier)
                                    {
                                        if (Convert.ToInt32(modifi.ProdutcID) == Convert.ToInt32(item.ProductID) && modifi.KeyModi == item.KeyIndex)
                                        {
                                            OrderDetailModifireModel modifiDetail = new OrderDetailModifireModel();
                                            modifiDetail.ProductID    = Convert.ToInt32(modifi.ProdutcID);
                                            modifiDetail.ModifireName = modifi.ModifiName;
                                            modifiDetail.Qty          = Convert.ToInt32(modifi.Qty);
                                            modifiDetail.ModifireID   = Convert.ToInt32(modifi.ModifiID);
                                            modifiDetail.ChangeStatus = Convert.ToInt32(modifi.ChangeStatusM);
                                            modifiDetail.DynID        = Convert.ToInt32(modifi.DynID);
                                            modifiDetail.Price        = Convert.ToDouble(modifi.ModifiPrice);
                                            OrderMain.addModifierToList(modifiDetail, KeyItem + 1);
                                        }
                                    }
                                    KeyItem++;
                                }
                            }
                            else
                            {
                                OrderDetailModel detailModel = new OrderDetailModel();
                                detailModel.ProductID    = Convert.ToInt32(item.ProductID);
                                detailModel.Price        = Convert.ToDouble(item.Price);
                                detailModel.ProductName  = item.ProductName;
                                detailModel.Qty          = Convert.ToInt32(item.Qty);
                                detailModel.Total        = Convert.ToDouble(item.Price);
                                detailModel.ChangeStatus = Convert.ToInt32(item.ChangeStatus);
                                detailModel.KeyItem      = KeyItem;
                                detailModel.Seat         = Convert.ToInt32(item.Seat);
                                detailModel.DynID        = Convert.ToInt32(item.DynID);
                                detailModel.CategoryID   = Convert.ToInt32(item.CategoryID);
                                detailModel.KeyItem      = Convert.ToInt32(item.KeyIndex);
                                var dataPrint = ProductService.GetListPrintJob(detailModel.ProductID, detailModel.CategoryID);
                                foreach (PrinteJobDetailModel itemPrint in dataPrint)
                                {
                                    PrinteJobDetailModel p = new PrinteJobDetailModel();
                                    p.ProductID = itemPrint.ProductID;
                                    p.PrinterID = itemPrint.PrinterID;
                                    detailModel.ListPrintJob.Add(p);
                                }
                                if (detailModel.ProductID == 0)
                                {
                                    var dataPrintOpenItem = ProductService.GetListPrintJobOpenItem(detailModel.DynID);
                                    foreach (PrinteJobDetailModel itemPrint in dataPrintOpenItem)
                                    {
                                        PrinteJobDetailModel p = new PrinteJobDetailModel();
                                        p.PrinterID = Convert.ToInt32(itemPrint.PrinterID);
                                        detailModel.ListPrintJob.Add(p);
                                    }
                                }
                                OrderMain.addItemToList(detailModel);
                                foreach (ModifierModel modifi in listModifier)
                                {
                                    if (Convert.ToInt32(modifi.ProdutcID) == Convert.ToInt32(item.ProductID) && modifi.KeyModi == item.KeyIndex)
                                    {
                                        OrderDetailModifireModel modifiDetail = new OrderDetailModifireModel();
                                        modifiDetail.ProductID    = Convert.ToInt32(modifi.ProdutcID);
                                        modifiDetail.ModifireName = modifi.ModifiName;
                                        modifiDetail.Qty          = Convert.ToInt32(modifi.ModifieQty);
                                        modifiDetail.ModifireID   = Convert.ToInt32(modifi.ModifiID);
                                        modifiDetail.ChangeStatus = Convert.ToInt32(modifi.ChangeStatusM);
                                        modifiDetail.DynID        = Convert.ToInt32(modifi.DynID);
                                        modifiDetail.Price        = Convert.ToDouble(modifi.ModifiPrice);
                                        OrderMain.addModifierToList(modifiDetail, KeyItem + 1);
                                    }
                                }
                                KeyItem++;
                            }
                        }
                        foreach (SeatModel seatItem in listSeat)
                        {
                            OrderMain.ListSeatOfOrder.Add(seatItem);
                        }
                        if (OrderMain.ListOrderDetail.Count() > 0)
                        {
                            if (checkOrderSended(OrderMain) == false)
                            {
                                return(Json("NoSend", JsonRequestBehavior.AllowGet));
                            }
                            else
                            {
                                OrderMain.SubTotalVoid();
                                if (OrderService.InsertOrder(OrderMain) == 1)
                                {
                                    if (!OrderMain.IsLoadFromData)
                                    {
                                        OrderMain.OrderID = OrderService.GetOrderID();
                                    }
                                    PrinterServer printServer = new PrinterServer();
                                    printServer.PrintData(OrderMain, PrintData);
                                    return(Json("1", JsonRequestBehavior.AllowGet));
                                }
                            }
                        }
                    }
                    else
                    {
                        return(Json("BILL", JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception ex)
                {
                    SystemLog.LogPOS.WriteLog("OrderController::::::::::::::::::::SendOrder::::::::::::::::::" + ex.Message);
                    return(null);
                }
            }
            else
            {
                return(RedirectToAction("Index", "Login"));
            }
            return(null);
        }
Beispiel #3
0
        private void Payment(Boolean isPrinte)
        {
            if (CheckTotal() == 1)
            {
                OrderMain.ListPayment       = lstPayment;
                OrderMain.ListInvoiceByCard = lstInvoiceByCard;

                int  result           = 0;
                bool checkHaveNewItem = false;
                int  resullInsert     = 0;
                for (int i = 0; i < OrderMain.ListOrderDetail.Count; i++)
                {
                    if (OrderMain.ListOrderDetail[i].ChangeStatus == 1)
                    {
                        checkHaveNewItem = true;
                    }
                }
                if (OrderMain.SendOrderOrNot == "NEW" || checkHaveNewItem)
                {
                    resullInsert = OrderService.InsertOrder(OrderMain);
                    if (resullInsert == 1)
                    {
                        GetListPrinter();
                        OrderMain.PrintType      = 1;
                        OrderMain.IsLoadFromData = false;
                        OrderMain.OrderID        = OrderService.GetOrderID();
                        if (!ProgramType.isStore)
                        {
                            OrderMain.OrderNumber = OrderService.GetOrderNumber();
                            PrinterServer printServer = new PrinterServer();
                            printServer.PrintData(OrderMain, PrintData);
                        }
                    }
                }
                GetListPaymentPrinter();
                OrderMain.PrintType = 2;
                result = InvoiceService.InsertInvoice(OrderMain);
                if (result == 1)
                {
                    if (isPrinte)
                    {
                        PrinterServer printServer = new PrinterServer();
                        printServer.PrintData(OrderMain, PrintData);
                    }
                    foreach (PrinterModel item in PrintData)
                    {
                        if (item.PrinterType == 4)
                        {
                            SystemLog.LogPOS.WriteLog("frmPayment::::::::::::::::ucOpenTill1_Click:::::::::::::::::" + item.PrinterName);
                            Class.RawPrinterHelper.openCashDrawer(item.PrinterName);
                        }
                    }
                    string Total    = "$" + money.Format2(OrderMain.SubTotal());
                    string Tendered = "";
                    if (OrderMain.Change > 0)
                    {
                        Double temp = OrderMain.Change + OrderMain.SubTotal();
                        Tendered = "$" + money.Format2(temp);
                    }
                    else
                    {
                        Tendered = "$" + money.Format2(OrderMain.SubTotal());
                    }
                    string          Change      = "$" + money.Format2(OrderMain.Change);
                    frmTranComplete frmComplete = new frmTranComplete(Total, Tendered, Change);
                    if (frmComplete.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        this.Close();
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                }
            }
            else
            {
                frmMessager frm = new frmMessager("Payment", "Insufficient Amount");
                frmOpacity.ShowDialog(this, frm);
            }
        }