Example #1
0
        private DataTable GetDataTable(List <GenericTreeViewColumnProperty> pColumnProperties)
        {
            //Init Local Vars
            DataTable              resultDataTable = new DataTable();
            Type                   dataTableColumnType;
            FIN_Article            article;
            OrderMain              orderMain  = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
            ArticleBag             articleBag = ArticleBag.TicketOrderToArticleBag(orderMain);
            POS_ConfigurationPlace configurationPlace;

            //Add Columns with specific Types From Column Properties
            foreach (GenericTreeViewColumnProperty column in pColumnProperties)
            {
                dataTableColumnType = (column.Type != null) ? column.Type : typeof(String);
                resultDataTable.Columns.Add(column.Name, dataTableColumnType);
            }

            //Init DataRow
            System.Object[] dataRow = new System.Object[pColumnProperties.Count];

            //Start Loop
            foreach (var item in articleBag)
            {
                article = (FIN_Article)FrameworkUtils.GetXPGuidObject(typeof(FIN_Article), item.Key.ArticleOid);
                if (article.Type.HavePrice)
                {
                    configurationPlace = (POS_ConfigurationPlace)FrameworkUtils.GetXPGuidObject(typeof(POS_ConfigurationPlace), item.Value.PlaceOid);

                    for (int i = 0; i < item.Value.Quantity; i++)
                    {
                        //Column Fields
                        dataRow[0]  = item.Key.ArticleOid;
                        dataRow[1]  = item.Value.Code;
                        dataRow[2]  = item.Key.Designation;
                        dataRow[3]  = item.Value.PriceFinal;
                        dataRow[4]  = item.Key.Vat;
                        dataRow[5]  = item.Key.Discount;
                        dataRow[6]  = configurationPlace.Designation;
                        dataRow[7]  = item.Key.Price;
                        dataRow[8]  = 1;
                        dataRow[9]  = item.Value.UnitMeasure;
                        dataRow[10] = item.Value.PlaceOid;
                        dataRow[11] = item.Value.TableOid;
                        dataRow[12] = item.Value.PriceType;
                        dataRow[13] = item.Value.Token1;
                        dataRow[14] = item.Value.Token2;
                        dataRow[15] = string.Empty;

                        //Add Row
                        resultDataTable.Rows.Add(dataRow);
                    }
                }
            }
            return(resultDataTable);
        }
Example #2
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //OrderMain/Document Conferences

        //Works in Dual Mode based on pGenerateNewIfDiferentFromArticleBag, sometimes passes 2 times, on for get last document and other to create new one
        //Mode1 : GenerateNewIfDiferentFromArticleBag = false : Returns Last Conference Document for Current Working Order Main
        //Mode2 : GenerateNewIfDiferentFromArticleBag = true : Returns Last or New Conference Document if Current Working Order Main is Diferent from working currente Working OrderMain ArticleBag
        //Returns Last|New DocumentConference, for table current OrderMain
        //GenerateNewIfDiferentFromArticleBag : Used to generate a new Document if latest Document has been changed (Compare it to current ArticleBag),
        //else if false use the latest on Database ignoring Diferences, Used to Get latest DocumentConference to use in Generate DocumentConference PosOrdersDialog.buttonTableConsult_Clicked
        public static FIN_DocumentFinanceMaster GetOrderMainLastDocumentConference(bool pGenerateNewIfDiferentFromArticleBag = false)
        {
            //Declare local Variables
            FIN_DocumentFinanceMaster lastDocument = null;
            FIN_DocumentFinanceMaster newDocument  = null;
            FIN_DocumentFinanceMaster result       = null;
            FIN_DocumentOrderMain     orderMain    = null;
            Guid      currentOrderMainOid          = GlobalFramework.SessionApp.CurrentOrderMainOid;
            OrderMain currentOrderMain             = GlobalFramework.SessionApp.OrdersMain[currentOrderMainOid];

            try
            {
                string sql = string.Format(@"
                    SELECT 
	                    Oid
                    FROM 
	                    FIN_documentfinancemaster 
                    WHERE 
	                    DocumentType = '{0}' AND 
	                    SourceOrderMain = '{1}'
                    ORDER BY 
	                    CreatedAt DESC;
                    "
                                           , SettingsApp.XpoOidDocumentFinanceTypeConferenceDocument
                                           , currentOrderMain.PersistentOid
                                           );

                var sqlResult = GlobalFramework.SessionXpo.ExecuteScalar(sql);

                //Get LastDocument Object
                if (sqlResult != null)
                {
                    lastDocument = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), new Guid(Convert.ToString(sqlResult)));
                }

                //If GenerateNewIfDiferentFromArticleBag Enabled compare ArticleBag with Document and If is diferent Generate a New One
                if (pGenerateNewIfDiferentFromArticleBag)
                {
                    //Initialize ArticleBag to Compare with Order Detail and use in ProcessFinanceDocuments
                    ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(currentOrderMain);
                    //Check if Total is Not Equal and Generate New DocumentConference, This way it will be Equal to Invoice
                    if (
                        lastDocument == null ||
                        (!lastDocument.TotalFinal.Equals(articleBag.TotalFinal) || !lastDocument.DocumentDetail.Count.Equals(articleBag.Count))
                        )
                    {
                        //Prepare ProcessFinanceDocumentParameter
                        ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(SettingsApp.XpoOidDocumentFinanceTypeConferenceDocument, articleBag)
                        {
                            Customer = SettingsApp.XpoOidDocumentFinanceMasterFinalConsumerEntity
                        };

                        orderMain = (FIN_DocumentOrderMain)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentOrderMain), currentOrderMain.PersistentOid);
                        processFinanceDocumentParameter.SourceOrderMain = orderMain;
                        if (lastDocument != null)
                        {
                            processFinanceDocumentParameter.DocumentParent  = lastDocument.Oid;
                            processFinanceDocumentParameter.OrderReferences = new List <FIN_DocumentFinanceMaster>();
                            processFinanceDocumentParameter.OrderReferences.Add(lastDocument);
                        }

                        //Generate New Document
                        newDocument = ProcessFinanceDocument.PersistFinanceDocument(processFinanceDocumentParameter, false);

                        //Assign DocumentStatus and OrderReferences
                        if (newDocument != null)
                        {
                            //Assign Result Document to New Document
                            //Get Object outside UOW else we have a problem with "A first chance exception of type 'System.ObjectDisposedException'"
                            result = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), newDocument.Oid);

                            ////Old Code that changes last Conference Document to Status "A", it is not Required, Confirmed with Carlos Bento, we must Leave it without status changes
                            //if (lastDocument != null)
                            //{
                            //    lastDocument.DocumentStatusStatus = "A";
                            //    lastDocument.DocumentStatusDate = newDocument.DocumentStatusDate;
                            //    lastDocument.DocumentStatusUser = newDocument.DocumentStatusUser;
                            //    lastDocument.SystemEntryDate = newDocument.SystemEntryDate;
                            //    lastDocument.Save();
                            //}
                        }
                    }
                }
                else
                {
                    result = lastDocument;
                }
            }
            catch (Exception ex)
            {
                // Send Exception to logicpos, must treat exception in ui, to Show Alert to User
                throw ex;
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// Get Total of All Persistent Tickets (Without PartialPayments), Used to Update StatusBar, And Update OrderMain main Object
        /// </summary>
        public void UpdateTotals()
        {
            try
            {
                /* METHOD #2 : From Article Bag
                 * //OrderMain orderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                 */
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(this);
                articleBag.UpdateTotals();
                //sqlTotalTickets
                string sqlTotalTickets = string.Format(@"
                    SELECT 
                        COUNT(*) AS TotalTickets    
                    FROM 
                        fin_documentorderticket
                    WHERE 
                        OrderMain = '{0}'
                ;"
                                                       , this.PersistentOid
                                                       );
                var totalTickets = GlobalFramework.SessionXpo.ExecuteScalar(sqlTotalTickets);

                //Assign Totals
                _globalTotalTickets  = (totalTickets != null) ? Convert.ToInt32(totalTickets) : 0;
                _globalTotalGross    = articleBag.TotalFinal;
                _globalTotalDiscount = articleBag.TotalDiscount;
                _globalTotalTax      = articleBag.TotalTax;
                _globalTotalFinal    = articleBag.TotalFinal;
                _globalTotalQuantity = articleBag.TotalQuantity;
                //Persist Final TotalOpen
                pos_configurationplacetable currentTable = (pos_configurationplacetable)FrameworkUtils.GetXPGuidObject(typeof(pos_configurationplacetable), _table.Oid);

                if (currentTable != null)
                {
                    //Required Reload, after ProcessFinanceDocument uowSession, else we get cached object, and apply changes to old object, ex we get a OpenedTable vs a ClosedTable by uowSession
                    currentTable.Reload();
                    currentTable.TotalOpen = _globalTotalFinal;
                    currentTable.Save();
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            /* METHOD 3 : When we Change table it dont Update GlobalDiscounts
             * //Get Total Order (Payed/Invoiced and NonPayed)
             * string sqlTotalViewOrders = string.Format(@"
             * SELECT
             *  SUM(ddTotalGross) AS TotalGross,
             *  SUM(ddTotalDiscount) AS TotalDiscount,
             *  SUM(ddTotalTax) AS TotalTax,
             *  SUM(ddTotalFinal) AS TotalFinal,
             *  SUM(ddQuantity) AS TotalQuantity
             * FROM
             *  view_orders
             * WHERE
             *  dmOid = '{0}'
             * ORDER BY
             *  dtTicketId,ddOrd;
             * ;"
             * , this.PersistentOid
             * );
             *
             * string sqlTotalViewDocumentFinance = string.Format(@"
             * SELECT
             *    SUM(fdTotalGross) AS TotalGross,
             *  SUM(fdTotalDiscount) AS TotalDiscount,
             *  SUM(fdTotalTax) AS TotalTax,
             *  SUM(fdTotalFinal) AS TotalFinal,
             *  SUM(fdQuantity) AS TotalQuantity
             * FROM
             *    view_documentfinance
             * WHERE
             *    fmSourceOrderMain = '{0}'
             * ;"
             * , this.PersistentOid
             * );
             *
             * string sqlTotalTickets = string.Format(@"
             * SELECT
             *  COUNT(*) AS TotalTickets
             * FROM
             *  fin_documentorderticket
             * WHERE
             *  OrderMain = '{0}'
             * ;"
             * , this.PersistentOid
             * );
             *
             * try
             * {
             * XPSelectData sdTotalViewOrders = FrameworkUtils.GetSelectedDataFromQuery(sqlTotalViewOrders);
             * XPSelectData sdTotalViewDocumentFinance = FrameworkUtils.GetSelectedDataFromQuery(sqlTotalViewDocumentFinance);
             *
             * if (sdTotalViewOrders.Data.Length > 0 && sdTotalViewDocumentFinance.Data.Length > 0)
             * {
             *  //TotalGross
             *  _globalTotalGross =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalGross")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalGross")]);
             *  //TotalDiscount
             *  _globalTotalDiscount =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalDiscount")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalDiscount")]);
             *  //TotalTax
             *  _globalTotalTax =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalTax")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalTax")]);
             *  //TotalFinal
             *  _globalTotalFinal =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalFinal")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalFinal")]);
             *  //TotalQuantity
             *  _globalTotalQuantity =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalQuantity")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalQuantity")]);
             * }
             *
             * //sqlTotalTickets
             * var totalTickets = GlobalFramework.SessionXpo.ExecuteScalar(sqlTotalTickets);
             * _globalTotalTickets = (totalTickets != null) ? Convert.ToInt32(totalTickets) : 0;
             *
             * //Persist Final TotalOpen
             * ConfigurationPlaceTable currentTable = (ConfigurationPlaceTable)FrameworkUtils.GetXPGuidObjectFromSession(typeof(ConfigurationPlaceTable), _table.Oid);
             * currentTable.TotalOpen = _globalTotalFinal;
             * currentTable.Save();
             * }
             * catch (Exception ex)
             * {
             * _log.Error(ex.Message, ex);
             * }
             */

            /* OLD DEPRECATED METHOD #1 : Bugged In Orders with PartialPayments
             * bool debug = false;
             *
             * //Settings
             *
             * //Always Reset Totals, With Persistent and Non Persistent Orders
             * _globalNumOfTickets = 0;
             * _globalTotalGross = 0;
             * _globalTotalDiscount = 0;
             * _globalTotalTax = 0;
             * _globalTotalFinal = 0;
             *
             * //Get Current _persistentOid and _orderStatus from Database
             * _persistentOid = GetOpenTableFieldValueGuid(_table.Oid, "Oid");
             * _orderStatus = (OrderStatus)GetOpenTableFieldValue(_table.Oid, "OrderStatus");
             *
             * if (_persistentOid != Guid.Empty)
             * {
             * CriteriaOperator binaryOperator = new BinaryOperator("OrderMain", _persistentOid, BinaryOperatorType.Equal);
             * XPCollection _xpcDocumentOrderTicket = new XPCollection(GlobalFramework.SessionXpo, typeof(DocumentOrderTicket), binaryOperator);
             *
             * //Required to ByPass Cache
             * _xpcDocumentOrderTicket.Reload();
             *
             * //Process DocumentOrderTickets Totals
             * if (_xpcDocumentOrderTicket.Count > 0)
             * {
             *  foreach (DocumentOrderTicket ticket in _xpcDocumentOrderTicket)
             *  {
             *    //Required to ByPass Cache
             *    ticket.OrderDetail.Reload();
             *
             *    //Increase Ticket
             *    _globalNumOfTickets++;
             *
             *    foreach (DocumentOrderDetail line in ticket.OrderDetail)
             *    {
             *      _globalTotalGross += line.TotalGross;
             *      _globalTotalDiscount += line.TotalDiscount;
             *      _globalTotalTax += line.TotalTax;
             *      _globalTotalFinal += line.TotalFinal;
             *      if (debug) _log.Debug(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", line.Article.Oid, line.Designation, line.Price, line.Quantity, line.Discount, line.Vat));
             *    }
             *    _globalLastUser = ticket.UpdatedBy;
             *    _globalLastTerminal = ticket.UpdatedWhere;
             *  }
             * }
             *
             * //Process PartialPayed Items and Discount its Totals
             * CriteriaOperator binaryOperatorDocumentFinanceMaster = new BinaryOperator("SourceOrderMain", _persistentOid, BinaryOperatorType.Equal);
             * XPCollection _xpcDocumentFinanceMaster = new XPCollection(GlobalFramework.SessionXpo, typeof(DocumentFinanceMaster), binaryOperatorDocumentFinanceMaster);
             * if (_xpcDocumentFinanceMaster.Count > 0)
             * {
             *  foreach (DocumentFinanceMaster master in _xpcDocumentFinanceMaster)
             *  {
             *    //SEARCH#001 - Change here and in Other Search, to SYNC RESULTS
             *    //Only Discount items from ArticleBag if is NOT a TableConsult, in TableConsult keep Full ArticleBag From OrderMain
             *    if (master.DocumentType.Oid != new Guid(xpoOidDocumentFinanceTypeConferenceDocument))
             *    {
             *      foreach (DocumentFinanceDetail line in master.DocumentDetail)
             *      {
             *        _globalTotalGross -= line.TotalGross;
             *        _globalTotalDiscount -= line.TotalDiscount;
             *        _globalTotalTax -= line.TotalTax;
             *        _globalTotalFinal -= line.TotalFinal;
             *      }
             *    }
             *  }
             * }
             *
             * //Persist Final TotalOpen
             * ConfigurationPlaceTable currentTable = (ConfigurationPlaceTable)FrameworkUtils.GetXPGuidObjectFromSession(typeof(ConfigurationPlaceTable), _table.Oid);
             * currentTable.TotalOpen = _globalTotalFinal;
             * currentTable.Save();
             *
             * //Debug
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _table.Id:[{0}], _table.Name:[{1}]", _table.Id, _table.Name));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalGross [{0}]", _globalTotalGross));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalTax [{0}]", _globalTotalTax));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalDiscount [{0}]", _globalTotalDiscount));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalFinal [{0}]", _globalTotalFinal));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalNumOfTickets [{0}]", _globalNumOfTickets));
             * //if (_globalLastUser != null) _log.Debug(string.Format("GetGlobalOrderSummary(): _globalLastUser.Name [{0}]", _globalLastUser.Name));
             * //if (_globalLastTerminal != null) _log.Debug(string.Format("GetGlobalOrderSummary(): _globalLastTerminal.Designation [{0}]", _globalLastTerminal.Designation));
             * }
             */
        }
Example #4
0
        void buttonTableConsult_Clicked(object sender, EventArgs e)
        {
            try
            {
                //Get Current OrderMain
                OrderMain currentOrderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                //Initialize ArticleBag to Send to ProcessFinanceDocuments or Compare
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(currentOrderMain);

                //Get Latest DocumentConference Document without Recreate it if Diference, compare it in Above Line
                FIN_DocumentFinanceMaster lastDocument = FrameworkUtils.GetOrderMainLastDocumentConference(false);

                //Reprint Existing Document After compare with current ArticleBag
                if (
                    lastDocument != null && articleBag != null &&
                    lastDocument.TotalFinal.Equals(articleBag.TotalFinal) && lastDocument.DocumentDetail.Count.Equals(articleBag.Count)
                    )
                {
                    FrameworkCalls.PrintFinanceDocument(this, lastDocument);
                }
                //Else Create new DocumentConference recalling FrameworkUtils.GetOrderMainLastDocumentConference with true to Create New One
                else
                {
                    try
                    {
                        //Call Recreate New Document
                        FIN_DocumentFinanceMaster newDocument = FrameworkUtils.GetOrderMainLastDocumentConference(true);

                        //Call Print New Document
                        FrameworkCalls.PrintFinanceDocument(this, newDocument);
                    }
                    catch (Exception ex)
                    {
                        string errorMessage = string.Empty;

                        switch (ex.Message)
                        {
                        case "ERROR_MISSING_SERIE":
                            errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_missing_series);
                            break;

                        case "ERROR_COMMIT_FINANCE_DOCUMENT_PAYMENT":
                        default:
                            errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, ex.Message);
                            break;
                        }
                        Utils.ShowMessageTouch(
                            _sourceWindow,
                            DialogFlags.Modal,
                            new Size(600, 400),
                            MessageType.Error,
                            ButtonsType.Close,
                            Resx.global_error,
                            errorMessage
                            );

                        this.Run();
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
            finally
            {
                this.Destroy();
            }
        }
Example #5
0
        //Payments and SplitAccount (Shared for Both Actions)
        void _buttonKeyPayments_Clicked(object sender, EventArgs e)
        {
            TouchButtonIconWithText button = (sender as TouchButtonIconWithText);

            try
            {
                //Used when we pay without FinishOrder, to Skip print Ticket
                bool printTicket = false;

                //Request Finish Open Ticket
                if (_listStoreModelTotalItemsTicketListMode > 0)
                {
                    ResponseType dialogResponse = Utils.ShowMessageTouch(_sourceWindow, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel, Resx.window_title_dialog_message_dialog, Resx.dialog_message_request_close_open_ticket);
                    if (dialogResponse != ResponseType.Ok)
                    {
                        return;
                    }
                    ;
                }
                ;

                //Get Reference to current OrderMain
                OrderMain orderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];

                //Finish Order, if Has Ticket Details
                if (orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails.Lines.Count > 0)
                {
                    //Before Use FrameworkCall
                    orderMain.FinishOrder(GlobalFramework.SessionXpo, printTicket);
                    //TODO: Continue to implement FrameworkCall here
                    //DocumentOrderTicket documentOrderTicket = orderMain.FinishOrder(GlobalFramework.SessionXpo, printTicket);
                    //if (printTicket) FrameworkCalls.PrintTableTicket(_sourceWindow, GlobalFramework.LoggedTerminal.Printer, GlobalFramework.LoggedTerminal.TemplateTicket, orderMain, documentOrderTicket.Oid);

                    //Reset TicketList TotalItems Counter
                    _listStoreModelTotalItemsTicketListMode = 0;
                }

                //Always Change to OrderMain ListMode before Update Model
                _listMode = TicketListMode.OrderMain;

                //Update Model and Gui
                UpdateModel();
                UpdateOrderStatusBar();
                UpdateTicketListOrderButtons();

                //Initialize ArticleBag to Send to Payment Dialog
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(orderMain);

                // Shared Referencesfor Dialog
                PosBaseDialog dialog = null;

                // Get Dialog Reference
                if (button.Name.Equals("touchButtonPosTicketPadPayments_Green"))
                {
                    dialog = new PosPaymentsDialog(_sourceWindow, DialogFlags.DestroyWithParent, articleBag);
                }
                else
                if (button.Name.Equals("touchButtonPosTicketPadSplitAccount_Green"))
                {
                    dialog = new PosSplitPaymentsDialog(_sourceWindow, DialogFlags.DestroyWithParent, _articleBag, this);
                }

                // Shared code to call Both Dialogs
                ResponseType response = (ResponseType)dialog.Run();

                if (response == ResponseType.Ok)
                {
                    //Update Cleaned TreeView Model
                    UpdateModel();
                    UpdateOrderStatusBar();
                    UpdateTicketListOrderButtons();
                    //IMPORTANT & REQUIRED: Assign Current Order Details from New CurrentTicketId, ELSE we cant add items to OrderMain
                    CurrentOrderDetails = orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails;
                    //Valid Result Destroy Dialog
                    dialog.Destroy();
                }
                ;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
        public DocumentFinanceDialogPage7(Window pSourceWindow, String pPageName, String pPageIcon, Widget pWidget, bool pEnabled = true)
            : base(pSourceWindow, pPageName, pPageIcon, pWidget, pEnabled)
        {
            _vboxButtons  = new VBox(true, 0);
            _hboxButtons1 = new HBox(true, 0);
            _hboxButtons2 = new HBox(true, 0);

            //Print Invoice
            Button buttonPrintInvoice = new Button("Print Invoice")
            {
                Sensitive = false
            };

            buttonPrintInvoice.Clicked += buttonPrintInvoice_Clicked;

            //Cancel Invoice
            Button buttonCancelInvoice = new Button("Cancel Invoice");

            buttonCancelInvoice.Clicked += buttonCancelInvoice_Clicked;

            //OrderReferences
            Button buttonOrderReferences = new Button("Order References");

            buttonOrderReferences.Clicked += buttonOrderReferences_Clicked;

            //Credit Note
            Button buttonCreditNote = new Button("Credit Note");

            buttonCreditNote.Clicked += buttonCreditNote_Clicked;

            //Print Invoice With Diferent Vat's
            Button buttonPrintInvoiceVat = new Button("Print Invoice Vat");

            buttonPrintInvoiceVat.Clicked += buttonPrintInvoiceVat_Clicked;

            //Print Invoice With Discounts
            Button buttonPrintInvoiceDiscount = new Button("Print Invoice Discount");

            buttonPrintInvoiceDiscount.Clicked += buttonPrintInvoiceDiscount_Clicked;

            //Print Invoice With ExchangeRate
            Button buttonPrintInvoiceExchangeRate = new Button("Print Invoice ExchangeRate");

            buttonPrintInvoiceExchangeRate.Clicked += buttonPrintInvoiceExchangeRate_Clicked;

            //Print Invoice With JohnDoe1
            Button buttonPrintInvoiceJohnDoe1 = new Button("Print Invoice JohnDoe1");

            buttonPrintInvoiceJohnDoe1.Clicked += buttonPrintInvoiceJohnDoe1_Clicked;

            //Print Invoice With JohnDoe2
            Button buttonPrintInvoiceJohnDoe2 = new Button("Print Invoice JohnDoe2");

            buttonPrintInvoiceJohnDoe2.Clicked += buttonPrintInvoiceJohnDoe2_Clicked;

            //Print Invoice Transportation Guide With Totals
            Button buttonPrintTransportationGuideWithTotals = new Button("Print Transportation Guide With Totals");

            buttonPrintTransportationGuideWithTotals.Clicked += buttonPrintTransportationGuideWithTotals_Clicked;

            //Print Invoice Transportation Guide Without Totals
            Button buttonPrintTransportationGuideWithoutTotals = new Button("Print Transportation Guide Without Totals");

            buttonPrintTransportationGuideWithoutTotals.Clicked += buttonPrintTransportationGuideWithoutTotals_Clicked;

            //Pack hboxButtons1
            _hboxButtons1.PackStart(buttonPrintInvoice, true, true, 2);
            _hboxButtons1.PackStart(buttonCancelInvoice, true, true, 2);
            _hboxButtons1.PackStart(buttonOrderReferences, true, true, 2);
            _hboxButtons1.PackStart(buttonCreditNote, true, true, 2);
            _hboxButtons1.PackStart(buttonPrintInvoiceVat, true, true, 2);
            _hboxButtons1.PackStart(buttonPrintInvoiceDiscount, true, true, 2);
            //Pack hboxButtons2
            _hboxButtons2.PackStart(buttonPrintInvoiceExchangeRate, true, true, 2);
            _hboxButtons2.PackStart(buttonPrintInvoiceJohnDoe1, true, true, 2);
            _hboxButtons2.PackStart(buttonPrintInvoiceJohnDoe2, true, true, 2);
            _hboxButtons2.PackStart(buttonPrintTransportationGuideWithTotals, true, true, 2);
            _hboxButtons2.PackStart(buttonPrintTransportationGuideWithoutTotals, true, true, 2);

            //Shared : Prepare ArticleBag
            if (GlobalFramework.SessionApp.OrdersMain.ContainsKey(GlobalFramework.SessionApp.CurrentOrderMainOid))
            {
                _orderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                if (_orderMain != null)
                {
                    _articleBag = ArticleBag.TicketOrderToArticleBag(_orderMain);
                }
                if (_articleBag != null && _articleBag.Count > 0)
                {
                    buttonPrintInvoice.Sensitive = true;
                }
            }

            _vboxButtons.PackStart(_hboxButtons1, true, true, 2);
            _vboxButtons.PackStart(_hboxButtons2, true, true, 2);

            PackStart(_vboxButtons);
        }
Example #7
0
        private DataTable GetDataTable(List <GenericTreeViewColumnProperty> pColumnProperties, bool pGetArticlesFromCurrentOrderMain)
        {
            //Get a New DataTable Scheme Ready to Fill with Rows
            DataTable resultDataTable = GenericTreeViewColumnProperty.ColumnPropertiesToDataTableScheme(pColumnProperties);

            //Usefull to Tests
            if (pGetArticlesFromCurrentOrderMain)
            {
                //Check if we have a Valid Session Order
                if (GlobalFramework.SessionApp.OrdersMain.ContainsKey(GlobalFramework.SessionApp.CurrentOrderMainOid))
                {
                    //Init Local Vars
                    FIN_Article article;
                    FIN_ConfigurationVatRate configurationVatRate;
                    //WIP: ConfigurationUnitMeasure configurationUnitMeasure;
                    OrderMain  orderMain  = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                    ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(orderMain);

                    //Init DataRow
                    System.Object[] dataRow = new System.Object[pColumnProperties.Count];

                    //Start Loop
                    foreach (var item in articleBag)
                    {
                        //Get XPGuidObjects to Assign to Columns
                        article = (FIN_Article)FrameworkUtils.GetXPGuidObject(typeof(FIN_Article), item.Key.ArticleOid);
                        configurationVatRate = (FIN_ConfigurationVatRate)FrameworkUtils.GetXPGuidObject(typeof(FIN_ConfigurationVatRate),
                                                                                                        FrameworkUtils.GetGuidFromQuery(string.Format(@"SELECT Oid FROM fin_configurationvatrate WHERE (Disabled IS NULL OR Disabled  <> 1) AND Value = '{0}';", item.Key.Vat))
                                                                                                        );
                        //WIP: configurationUnitMeasure = (ConfigurationUnitMeasure)FrameworkUtils.GetXPGuidObjectFromSession(typeof(ConfigurationUnitMeasure),
                        //  FrameworkUtils.GetGuidFromQuery(string.Format(@"SELECT Oid FROM cfg_configurationunitmeasure WHERE (Disabled IS NULL OR Disabled  <> 1) AND Acronym = '{0}';", item.Value.UnitMeasure))
                        //);

                        //Column Fields
                        dataRow[0] = item.Key.ArticleOid;
                        dataRow[1] = article;                   //Article.Code
                        dataRow[2] = article;                   //Article.Designation
                        dataRow[3] = item.Value.Quantity;
                        //dataRow[4] = configurationUnitMeasure;// ConfigurationUnitMeasure.Acronym
                        dataRow[4] = item.Key.Price;
                        dataRow[5] = null;                      //PriceDisplay: Show/Work in Currency ex USD
                        dataRow[6] = configurationVatRate;      // ConfigurationVatRate.Value
                        //To Store VatExemptionReason : Get Value From ArticleBag, When Used in Tickets
                        dataRow[7] = null;                      // VatExemptionReason.Designation
                        dataRow[8] = item.Key.Discount;
                        //dataRow[9] = item.Value.TotalGross;
                        dataRow[9]  = item.Value.TotalNet;
                        dataRow[10] = item.Value.TotalFinal;
                        //Invisible Fields
                        dataRow[11] = item.Value.PriceFinal;
                        dataRow[12] = item.Value.PriceType;
                        dataRow[13] = string.Empty;             //Token1
                        dataRow[14] = string.Empty;             //Token2
                        dataRow[15] = string.Empty;             //Notes
                        //Add Row
                        resultDataTable.Rows.Add(dataRow);
                    }
                }
            }
            return(resultDataTable);
        }
Example #8
0
        //Delete
        void _buttonKeyDelete_Clicked(object sender, EventArgs e)
        {
            if (_listMode == TicketListMode.OrderMain)
            {
                ResponseType responseType = Utils.ShowMessageTouch(_sourceWindow, DialogFlags.Modal, new System.Drawing.Size(400, 280), MessageType.Question, ButtonsType.YesNo, string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_warning"), GlobalFramework.ServerVersion), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message__pos_order_cancel"));

                if (responseType == ResponseType.Yes)
                {
                    try
                    {
                        _listStoreModel.Clear();
                        _listStoreModelSelectedIndex = -1;
                        _listStoreModelTotalItems    = 0;
                        //Get Reference to current OrderMain
                        OrderMain             orderMain         = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                        fin_documentordermain documentOrderMain = null;
                        //Get current OrderMain Article Bag, After Process Payment/PartialPayment to check if current OrderMain has Items, or is Empty
                        ArticleBag pParameters = ArticleBag.TicketOrderToArticleBag(orderMain);
                        //Start UnitOfWork
                        using (UnitOfWork uowSession = new UnitOfWork())
                        {
                            if (pParameters.Count > 0)
                            {
                                // Warning required to check if (documentOrderMain != null), when we work with SplitPayments and work only one product,
                                // the 2,3,4....orders are null, this is because first FinanceDocument Closes Order

                                //Close OrderMain
                                //if (documentOrderMain != null) documentOrderMain.OrderStatus = OrderStatus.Close;

                                //Required to Update and Sync Terminals
                                //if (documentOrderMain != null) documentOrderMain.UpdatedAt = documentDateTime;

                                //Change Table Status to Free
                                pos_configurationplacetable placeTable;
                                placeTable        = (pos_configurationplacetable)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(pos_configurationplacetable), orderMain.Table.Oid);
                                documentOrderMain = (fin_documentordermain)uowSession.GetObjectByKey(typeof(fin_documentordermain), orderMain.PersistentOid);

                                placeTable.TableStatus = TableStatus.Free;
                                FrameworkUtils.Audit("TABLE_OPEN", string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_table_open"), placeTable.Designation));
                                placeTable.DateTableClosed = DateTime.Now;
                                placeTable.TotalOpen       = 0;
                                placeTable.Save();
                                //Required to Reload Objects after has been changed in Another Session(uowSession)
                                if (documentOrderMain != null)
                                {
                                    documentOrderMain             = (fin_documentordermain)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(fin_documentordermain), orderMain.PersistentOid);
                                    documentOrderMain.OrderStatus = OrderStatus.Close;
                                    documentOrderMain.Save();
                                }

                                if (documentOrderMain != null)
                                {
                                    documentOrderMain.Reload();
                                }
                                //aceTable = (pos_configurationplacetable)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(pos_configurationplacetable), orderMain.Table.Oid);
                                //placeTable.Reload();
                                ArticleBag.TicketOrderToArticleBag(orderMain).Clear();
                                //Clean Session if Commited without problems
                                orderMain.OrderStatus = OrderStatus.Close;
                                orderMain.CleanSessionOrder();
                                GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid] = orderMain;
                                GlobalFramework.SessionApp.DeleteEmptyTickets();
                                //obalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid].CleanSessionOrder();
                                uowSession.CommitChanges();
                            }
                        }
                        //PartialPayment Detected
                        //else
                        //{
                        //    //Required to Update and Sync Terminals
                        //    if (documentOrderMain != null) documentOrderMain.UpdatedAt = documentDateTime;
                        //}


                        //Remove from SessionApp
                        //_currentOrderDetails.Delete(_listStoreModelSelectedIndex);

                        //Remove from TreviewModel
                        //_listStoreModel.Remove(ref _treeIter);
                        //Get Reference to current OrderMain

                        CurrentOrderDetails = orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails;

                        //Always Change to OrderMain ListMode before Update Model
                        _listMode = TicketListMode.Ticket;
                        orderMain.CleanSessionOrder();
                        Gdk.Color colorListMode = (_listMode == TicketListMode.Ticket) ? colorListMode = Utils.ColorToGdkColor(_colorPosTicketListModeTicketBackground) : colorListMode = Utils.ColorToGdkColor(_colorPosTicketListModeOrderMainBackground);
                        _treeView.ModifyBase(StateType.Normal, colorListMode);
                        //UpdateModel();
                        UpdateOrderStatusBar();
                        UpdateTicketListOrderButtons();
                        //IMPORTANT & REQUIRED: Assign Current Order Details from New CurrentTicketId, ELSE we cant add items to OrderMain
                        CurrentOrderDetails = orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails;
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message, ex);
                    }
                }
            }
            else
            {
                DeleteItem_Event(TicketListDeleteMode.Delete);
            }
        }