コード例 #1
0
        /// <summary>
        /// Delete item from database
        /// </summary>
        protected override void DeleteItem(Order item)
        {
            try
            {
                // need warning for confirmation
                // ...
                if (this.MessageBoxService.ShowYesNo(
                        "Would you like to remove order on table \"" + item.Table.Name + "\" from list?",
                        CustomDialogIcons.Question) == CustomDialogResults.Yes)
                {
                    bool result = ModelManager.Delete(item);
                    if (result)
                    {
                        this.MessageBoxService.ShowInformation("Successfully deleted order");
                    }

                    // refresh item list
                    this.ExecuteRefreshCommand();
                    // refresh table list
                    RefreshTablesCommand.Execute(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
 private void MainWindowRequestRefreshingDataSink(Boolean dummy)
 {
     // refresh item list
     this.ExecuteRefreshCommand();
     // refresh table list
     RefreshTablesCommand.Execute(null);
 }
コード例 #3
0
        /// <summary>
        /// Execute CancelCommand
        /// </summary>
        /// <param name="item">Selected item to be processed.</param>
        private void ExecuteCancelCommand(Order item)
        {
            try
            {
                (ModelManager as IOrderManager).CancelOrder(GlobalObjects.SystemUser, item);
                SelectedItem = this.Items[0];

                // refresh item list
                this.ExecuteRefreshCommand();
                // refresh table list
                RefreshTablesCommand.Execute(null);
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
コード例 #4
0
        /// <summary>
        /// Edit an existing item and update in database
        /// </summary>
        protected override void EditItem(Order item)
        {
            try
            {
                OrderViewModel viewModel = new OrderViewModel(this.MessageBoxService, item, (IOrderManager)ModelManager, _tableManager);

                // open dialog and return result when it is closed
                bool?result = this.UIVisualizerService.ShowDialog("OrderPopup", viewModel);

                // code to check result
                if (result == true)
                {
                    // refresh item list
                    RefreshTablesCommand.Execute(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        /// <summary>
        /// Execute BillCommand
        /// </summary>
        /// <param name="item">Selected item to be processed.</param>
        private void ExecuteBillCommand(Order item)
        {
            try
            {
                if (this.MessageBoxService.ShowYesNo(
                        "Would you like to bill order \"" + item.Code + "\"?",
                        CustomDialogIcons.Question) == CustomDialogResults.Yes)
                {
                    KeyPadViewModel viewModel = new KeyPadViewModel("Cash");

                    bool?result = this.UIVisualizerService.ShowDialog("KeyPadPopup", viewModel);

                    if (result.HasValue && result.Value)
                    {
                        item.Cash = Convert.ToInt64(viewModel.ReturnedValue);

                        if (item.Change < 0)
                        {
                            MessageBoxService.ShowInformation(
                                "Payment for order " + item.Code + " is not enough !!! Please pay greater amount! Thank you.");
                        }
                        else
                        {
                            (ModelManager as IOrderManager).BillOrder(GlobalObjects.SystemUser, item);
                            //SelectedItem = this.Items[0];
                        }

                        // refresh item list
                        this.ExecuteRefreshCommand();
                        // refresh table list
                        RefreshTablesCommand.Execute(null);
                    }
                }
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
コード例 #6
0
        /// <summary>
        /// Execute ServiceChargeCommand
        /// </summary>
        /// <param name="item">Selected item to be processed.</param>
        private void ExecuteServiceChargeCommand(Order item)
        {
            try
            {
                KeyPadViewModel viewModel = new KeyPadViewModel("Service Charge");
                bool?           result    = UIVisualizerService.ShowDialog("KeyPadPopup", viewModel);

                if (result.HasValue && result.Value)
                {
                    item.ServiceCharge = Convert.ToInt64(viewModel.ReturnedValue);
                    (ModelManager as IOrderManager).UpdateServiceCharge(item);

                    // refresh item list
                    this.ExecuteRefreshCommand();
                    // refresh table list
                    RefreshTablesCommand.Execute(null);
                }
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
コード例 #7
0
        /// <summary>
        /// Execute PrintCommand
        /// </summary>
        /// <param name="item">Selected item to be processed.</param>
        private void ExecutePrintCommand(Order item)
        {
            try
            {
                DataTable _orderItemDataTable = new DataTable();
                //Make OrderItem DataTable
                _orderItemDataTable.Columns.Add("Sequence", typeof(byte));
                _orderItemDataTable.Columns.Add("Item", typeof(string));
                _orderItemDataTable.Columns.Add("Unit", typeof(string));
                _orderItemDataTable.Columns.Add("UnitPrice", typeof(decimal));
                _orderItemDataTable.Columns.Add("Quantity", typeof(Int32));
                _orderItemDataTable.Columns.Add("ItemPrice", typeof(decimal));

                byte             sequence = 1;
                List <OrderItem> list     = item.OrderItems.Where(o => o.IsCancelled == false).ToList();

                foreach (OrderItem orderItem in list)
                {
                    DataRow dr = _orderItemDataTable.NewRow();
                    dr["Item"]      = orderItem.ProductInfo.Name;
                    dr["Unit"]      = orderItem.ProductInfo.Unit.Name;
                    dr["UnitPrice"] = orderItem.ProductInfo.Price;
                    dr["Quantity"]  = orderItem.Quantity;
                    dr["ItemPrice"] = orderItem.ItemPrice;
                    dr["Sequence"]  = sequence++;

                    _orderItemDataTable.Rows.Add(dr);
                }

                Restaurant CurrentRestaurant = GlobalObjects.RestaurantInfo;

                string name        = "";
                string address     = "";
                string phoneNumber = "";
                if (CurrentRestaurant != null)
                {
                    name        = CurrentRestaurant.Name;
                    address     = CurrentRestaurant.Address;
                    phoneNumber = CurrentRestaurant.PhoneNumber1 + " - " + CurrentRestaurant.PhoneNumber2;
                }

                List <CrystalReportParameter> arrParams = new List <CrystalReportParameter>();
                arrParams.Add(new CrystalReportParameter("rpm_Date", GlobalObjects.CurrentDateTime.ToString("MM/dd/yyyy HH:mm")));
                arrParams.Add(new CrystalReportParameter("rpm_CashierName", GlobalObjects.SystemUser.Fullname));
                arrParams.Add(new CrystalReportParameter("rpm_OrderNo", item.Code));
                arrParams.Add(new CrystalReportParameter("rpm_TableNo", item.Table.Name));
                arrParams.Add(new CrystalReportParameter("rpm_VAT", item.VatPrice));
                arrParams.Add(new CrystalReportParameter("rpm_ServiceCharge", item.ServiceCharge));
                arrParams.Add(new CrystalReportParameter("rpm_Discount", item.DiscountPrice));
                arrParams.Add(new CrystalReportParameter("rpm_TotalPrice", item.TotalPrice));
                arrParams.Add(new CrystalReportParameter("rpm_SubTotalPrice", item.SubTotalPrice));
                arrParams.Add(new CrystalReportParameter("rpm_RestaurantName", name));
                arrParams.Add(new CrystalReportParameter("rpm_Address", address));
                arrParams.Add(new CrystalReportParameter("rpm_PhoneNumber", phoneNumber));
                arrParams.Add(new CrystalReportParameter("rpm_PrintCount", item.PrintCount + 1));

                string reportPath = Environment.CurrentDirectory + "\\ReportSrc";
                //ReportPrintClass objReportPrintClass = new ReportPrintClass("PublicDataSet_OrderItems", _orderItemDataTable, reportPath + "\\Report_Receipt.rdlc", arrParams, 8.27, 11.69, 0.5, 0.5, 0.2, 0.2);
                CrystalReportPrintClass objReportPrintClass = new CrystalReportPrintClass("ReportDataSet_OrderItems", _orderItemDataTable, reportPath + "\\ReportReceipt.rpt", arrParams, 8.27, 11.69, 0, 0, 0, 0);

                PrinterViewModel viewModel = new PrinterViewModel(this.MessageBoxService);
                bool?            result    = this.UIVisualizerService.ShowDialog("PrinterPopup", viewModel);

                if (result.HasValue && result.Value)
                {
                    objReportPrintClass.Print(viewModel.SelectedPrinter, 1);
                    (ModelManager as IOrderManager).UpdatePrintCount(GlobalObjects.SystemUser, item);
                    //SelectedItem = this.Items[0];

                    // refresh item list
                    this.ExecuteRefreshCommand();
                    // refresh table list
                    RefreshTablesCommand.Execute(null);
                }
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }