Beispiel #1
0
        /// <summary>
        /// Show Close Message, Shared for Day and Terminal Sessions
        /// </summary>
        /// <param name="pWorkSessionPeriod"></param>
        /// <returns></returns>
        public void ShowClosePeriodMessage(Window pSourceWindow, POS_WorkSessionPeriod pWorkSessionPeriod)
        {
            string messageResource = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ?
                                     Resx.dialog_message_worksession_day_close_successfully :
                                     Resx.dialog_message_worksession_terminal_close_successfully
            ;
            string messageTotalSummary = string.Empty;
            //used to store number of payments used, to increase dialog window size
            int workSessionPeriodTotalCount = 0;
            //Window Height Helper vars
            int lineHeight   = 28;
            int windowHeight = 300;

            //Get Session Period Details
            Hashtable resultHashTable = ProcessWorkSessionPeriod.GetSessionPeriodSummaryDetails(pWorkSessionPeriod);
            //Get Total Money in CashDrawer On Open/Close
            string totalMoneyInCashDrawerOnOpen = string.Format("{0}: {1}", Resx.global_total_cashdrawer_on_open, FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawerOnOpen"]));
            string totalMoneyInCashDrawer       = string.Format("{0}: {1}", Resx.global_total_cashdrawer, FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawer"]));
            //Get Total Money and TotalMoney Out (NonPayments)
            string totalMoneyIn  = string.Format("{0}: {1}", Resx.global_cashdrawer_money_in, FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyIn"]));
            string totalMoneyOut = string.Format("{0}: {1}", Resx.global_cashdrawer_money_out, FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyOut"]));

            //Init Message
            messageTotalSummary = string.Format("{1}{0}{2}{0}{3}{0}{4}{0}", Environment.NewLine, totalMoneyInCashDrawerOnOpen, totalMoneyInCashDrawer, totalMoneyIn, totalMoneyOut);

            //Get Payments Totals
            try
            {
                XPCollection workSessionPeriodTotal = ProcessWorkSessionPeriod.GetSessionPeriodTotal(pWorkSessionPeriod);
                if (workSessionPeriodTotal.Count > 0)
                {
                    messageTotalSummary += string.Format("{0}{1}{0}", Environment.NewLine, Resx.global_total_by_type_of_payment);
                    foreach (POS_WorkSessionPeriodTotal item in workSessionPeriodTotal)
                    {
                        messageTotalSummary += string.Format("{1}-{2}: {3}{0}", Environment.NewLine, item.PaymentMethod.Acronym, item.PaymentMethod.Designation, FrameworkUtils.DecimalToStringCurrency(item.Total));
                    }
                    workSessionPeriodTotalCount = workSessionPeriodTotal.Count;
                }

                windowHeight = (workSessionPeriodTotalCount > 0) ? windowHeight + ((workSessionPeriodTotalCount + 2) * lineHeight) : windowHeight + lineHeight;

                Utils.ShowMessageTouch(
                    pSourceWindow,
                    DialogFlags.Modal,
                    new Size(600, windowHeight),
                    MessageType.Info,
                    ButtonsType.Close,
                    "Info",
                    string.Format(messageResource, messageTotalSummary)
                    );
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Beispiel #2
0
        void _touchButtonStartStopWorkSessionPeriodDay_Clicked(object sender, EventArgs e)
        {
            //Stop WorkSessionPeriodDay
            if (GlobalFramework.WorkSessionPeriodDay != null && GlobalFramework.WorkSessionPeriodDay.SessionStatus == WorkSessionPeriodStatus.Open)
            {
                //Check if we can StopSessionPeriodDay
                bool resultCanClose = CanCloseWorkSessionPeriodDay();
                if (resultCanClose == false)
                {
                    return;
                }

                // ShowRequestBackupDialog and Backup only if PluginSoftwareVendor is Active
                if (GlobalFramework.PluginSoftwareVendor != null)
                {
                    //Request User to do a DatabaseBackup, After Check Can Close
                    DataBaseBackup.ShowRequestBackupDialog(this);
                }

                //Stop WorkSession Period Day
                bool result = ProcessWorkSessionPeriod.SessionPeriodClose(GlobalFramework.WorkSessionPeriodDay);
                if (result)
                {
                    _touchButtonStartStopWorkSessionPeriodDay.LabelText = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_day");
                    _touchButtonCashDrawer.Sensitive = false;

                    //Show ClosePeriodMessage
                    ShowClosePeriodMessage(this, GlobalFramework.WorkSessionPeriodDay); /* IN009054 -  WorkSessionPeriodDay: NullReferenceException when closing day on non-licensed app */

                    //PrintWorkSessionMovement Day
                    //PrintRouter.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodDay);
                    //PrintRouter.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodTerminal);
                    ResponseType pResponse = Utils.ShowMessageTouch(
                        this, DialogFlags.Modal, new Size(500, 350), MessageType.Question, ButtonsType.YesNo, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_button_label_print"),
                        resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_request_print_document_confirmation"));

                    if (pResponse == ResponseType.Yes)
                    {
                        FrameworkCalls.PrintWorkSessionMovement(this, GlobalFramework.LoggedTerminal.ThermalPrinter, GlobalFramework.WorkSessionPeriodTerminal);
                    }
                    //FrameworkCalls.PrintWorkSessionMovement(this, GlobalFramework.LoggedTerminal.ThermalPrinter, GlobalFramework.WorkSessionPeriodDay);
                }
            }
            //Start WorkSessionPeriodDay
            else
            {
                bool result = ProcessWorkSessionPeriod.SessionPeriodOpen(WorkSessionPeriodType.Day);
                if (result)
                {
                    _touchButtonStartStopWorkSessionPeriodDay.LabelText = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_day");
                    _touchButtonCashDrawer.Sensitive = true;
                }
            }
        }
Beispiel #3
0
        void _touchButtonStartStopWorkSessionPeriodDay_Clicked(object sender, EventArgs e)
        {
            //Stop WorkSessionPeriodDay
            if (GlobalFramework.WorkSessionPeriodDay != null && GlobalFramework.WorkSessionPeriodDay.SessionStatus == WorkSessionPeriodStatus.Open)
            {
                //Check if we can StopSessionPeriodDay
                bool resultCanClose = CanCloseWorkSessionPeriodDay();
                if (resultCanClose == false)
                {
                    return;
                }

                // ShowRequestBackupDialog and Backup only if PluginSoftwareVendor is Active
                if (GlobalFramework.PluginSoftwareVendor != null)
                {
                    //Request User to do a DatabaseBackup, After Check Can Close
                    DataBaseBackup.ShowRequestBackupDialog(this);
                }

                //Stop WorkSession Period Day
                bool result = ProcessWorkSessionPeriod.SessionPeriodClose(GlobalFramework.WorkSessionPeriodDay);
                if (result)
                {
                    _touchButtonStartStopWorkSessionPeriodDay.LabelText = Resx.global_worksession_open_day;
                    _touchButtonCashDrawer.Sensitive = false;

                    //PrintWorkSessionMovement Day
                    //PrintRouter.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodDay);
                    //PrintRouter.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodTerminal);
                    FrameworkCalls.PrintWorkSessionMovement(this, GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodDay);

                    //Show ClosePeriodMessage
                    ShowClosePeriodMessage(this, GlobalFramework.WorkSessionPeriodDay);
                }
            }
            //Start WorkSessionPeriodDay
            else
            {
                bool result = ProcessWorkSessionPeriod.SessionPeriodOpen(WorkSessionPeriodType.Day);
                if (result)
                {
                    _touchButtonStartStopWorkSessionPeriodDay.LabelText = Resx.global_worksession_close_day;
                    _touchButtonCashDrawer.Sensitive = true;
                }
            }
        }
Beispiel #4
0
        private bool UpdateClock()
        {
            if (GlobalApp.WindowPos.Visible)
            {
                _labelClock.Text = FrameworkUtils.CurrentDateTime(_clockFormat);

                //Call Current OrderMain Update Status
                if (GlobalFramework.SessionApp.CurrentOrderMainOid != Guid.Empty && GlobalFramework.SessionApp.OrdersMain.ContainsKey(GlobalFramework.SessionApp.CurrentOrderMainOid))
                {
                    UpdateGUITimer(GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid], _ticketList);
                }

                //Update UI Button and Get WorkSessionPeriodDay if is Opened by Other Terminal
                if (GlobalFramework.WorkSessionPeriodTerminal == null ||
                    (GlobalFramework.WorkSessionPeriodTerminal != null && GlobalFramework.WorkSessionPeriodTerminal.SessionStatus == WorkSessionPeriodStatus.Close))
                {
                    POS_WorkSessionPeriod workSessionPeriodDay = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);

                    if (workSessionPeriodDay == null)
                    {
                        GlobalFramework.WorkSessionPeriodDay = null;
                        UpdateWorkSessionUI();
                    }
                    else
                    {
                        if (workSessionPeriodDay.SessionStatus == WorkSessionPeriodStatus.Open)
                        {
                            GlobalFramework.WorkSessionPeriodDay = workSessionPeriodDay;
                            UpdateWorkSessionUI();
                        }
                    }
                }
            }
            // returning true means that the timeout routine should be invoked
            // again after the timeout period expires. Returning false would
            // terminate the timeout.
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Check if Open and Close CashDrawer Amount is Valid, Totals are Equal
        /// </summary>
        /// <param name="pLastMovementTypeAmount"></param>
        /// <returns></returns>
        private Boolean IsCashDrawerAmountValid(decimal pLastMovementTypeAmount)
        {
            decimal totalInCashDrawer;

            //With Drawer Opened
            if (GlobalFramework.WorkSessionPeriodTerminal != null)
            {
                decimal moneyCashTotalMovements = ProcessWorkSessionPeriod.GetSessionPeriodMovementTotal(GlobalFramework.WorkSessionPeriodTerminal, MovementTypeTotal.MoneyInCashDrawer);
                totalInCashDrawer = Math.Round(moneyCashTotalMovements, _decimalRoundTo);
            }
            //With Drawer Closed
            else
            {
                totalInCashDrawer = Math.Round(pLastMovementTypeAmount, _decimalRoundTo);
            }

            decimal diference = Math.Round(_movementAmountMoney - totalInCashDrawer, _decimalRoundTo);
            string  message   = string.Empty;

            //_log.Debug(string.Format("_movementAmountMoney: [{0}], pLastMovementTypeAmount:[{1}], totalInCashDrawer: [{2}], diference: [{3}]", _movementAmountMoney, pLastMovementTypeAmount, totalInCashDrawer, diference));

            if (diference != 0)
            {
                message = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_cashdrawer_open_close_total_enter_diferent_from_total_in_cashdrawer")
                                        , FrameworkUtils.DecimalToStringCurrency(totalInCashDrawer)
                                        , FrameworkUtils.DecimalToStringCurrency(_movementAmountMoney)
                                        , FrameworkUtils.DecimalToStringCurrency(diference)
                                        );
                Utils.ShowMessageTouch(this, DialogFlags.Modal, new Size(600, 450), MessageType.Error, ButtonsType.Close, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), message);

                return(false);
            }
            else
            {
                return(true);
            }
        }
        public bool PrintWorkSessionMovement(sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod, SplitCurrentAccountMode pSplitCurrentAccountMode)
        {
            bool result = false;

            if (pPrinter != null)
            {
                sys_configurationprinters          printer  = pPrinter;
                sys_configurationprinterstemplates template = (sys_configurationprinterstemplates)FrameworkUtils.GetXPGuidObject(typeof(sys_configurationprinterstemplates), SettingsApp.XpoOidConfigurationPrintersTemplateWorkSessionMovement);
                string splitCurrentAccountFilter            = string.Empty;
                string fileTicket = template.FileTemplate;

                switch (pSplitCurrentAccountMode)
                {
                case SplitCurrentAccountMode.All:
                    break;

                case SplitCurrentAccountMode.NonCurrentAcount:
                    //Diferent from DocumentType CC
                    splitCurrentAccountFilter = string.Format("AND DocumentType <> '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    break;

                case SplitCurrentAccountMode.CurrentAcount:
                    //Only DocumentType CC
                    splitCurrentAccountFilter = string.Format("AND DocumentType = '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    break;
                }

                try
                {
                    //Shared Where for details and totals Queries
                    string sqlWhere = string.Empty;

                    if (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day)
                    {
                        sqlWhere = string.Format("PeriodParent = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter);
                    }
                    else
                    {
                        sqlWhere = string.Format("Period = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter);
                    }

                    //Shared for Both Modes
                    if (sqlWhere != string.Empty)
                    {
                        sqlWhere = string.Format(" AND {0}", sqlWhere);
                    }

                    //Format to Display Vars
                    string dateCloseDisplay = (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Open) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_in_progress") : pWorkSessionPeriod.DateEnd.ToString(SettingsApp.DateTimeFormat);

                    //Get Session Period Details
                    Hashtable resultHashTable = ProcessWorkSessionPeriod.GetSessionPeriodSummaryDetails(pWorkSessionPeriod);

                    //Print Header Summary
                    DataRow   dataRow   = null;
                    DataTable dataTable = new DataTable();
                    dataTable.Columns.Add(new DataColumn("Label", typeof(string)));
                    dataTable.Columns.Add(new DataColumn("Value", typeof(string)));
                    //Open DateTime
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_datetime"));
                    dataRow[1] = pWorkSessionPeriod.DateStart.ToString(SettingsApp.DateTimeFormat);
                    dataTable.Rows.Add(dataRow);
                    //Close DataTime
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_datetime"));
                    dataRow[1] = dateCloseDisplay;
                    dataTable.Rows.Add(dataRow);
                    //Open Total CashDrawer
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_total_cashdrawer"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawerOnOpen"]);
                    dataTable.Rows.Add(dataRow);
                    //Close Total CashDrawer
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_total_cashdrawer"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawer"]);
                    dataTable.Rows.Add(dataRow);
                    //Total Money In
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_in"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyIn"]);
                    dataTable.Rows.Add(dataRow);
                    //Total Money Out
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_out"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyOut"]);
                    dataTable.Rows.Add(dataRow);
                    //Configure Ticket Column Properties
                    List <TicketColumn> columns = new List <TicketColumn>();
                    columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right));
                    columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left));
                    TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold);
                    //Print Ticket Table
                    ticketTable.Print(_thermalPrinterGeneric);
                    //Line Feed
                    _thermalPrinterGeneric.LineFeed();

                    //Get Final Rendered DataTable Groups
                    Dictionary <DataTableGroupPropertiesType, DataTableGroupProperties> dictGroupProperties = GenDataTableWorkSessionMovementResume(pWorkSessionPeriod.PeriodType, pSplitCurrentAccountMode, sqlWhere);

                    //Prepare Local vars for Group Loop
                    XPSelectData xPSelectData = null;
                    string       designation  = string.Empty;
                    decimal      quantity     = 0.0m;
                    decimal      total        = 0.0m;
                    string       unitMeasure  = string.Empty;
                    //Store Final Totals
                    decimal summaryTotalQuantity = 0.0m;
                    decimal summaryTotal         = 0.0m;
                    //Used to Custom Print Table Ticket Rows
                    List <string> tableCustomPrint = new List <string>();

                    //Start to process Group
                    int groupPosition = -1;
                    //Assign Position to Print Payment Group Split Title
                    int groupPositionTitlePayments = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ? 9 : 8;
                    //If CurrentAccount Mode decrease 1, it dont have PaymentMethods
                    if (pSplitCurrentAccountMode == SplitCurrentAccountMode.CurrentAcount)
                    {
                        groupPositionTitlePayments--;
                    }


                    foreach (KeyValuePair <DataTableGroupPropertiesType, DataTableGroupProperties> item in dictGroupProperties)
                    //foreach (DataTableGroupProperties item in dictGroupProperties.Values)
                    {
                        if (item.Value.Enabled)
                        {
                            //Increment Group Position
                            groupPosition++;

                            //Print Group Titles (FinanceDocuments|Payments)
                            if (groupPosition == 0)
                            {
                                _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents"), WriteLineTextMode.Big);
                                _thermalPrinterGeneric.LineFeed();
                            }
                            else if (groupPosition == groupPositionTitlePayments)
                            {
                                //When finish FinanceDocuemnts groups, print Last Row, the Summary Totals Row
                                _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight);
                                _thermalPrinterGeneric.LineFeed();

                                _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_paymens_documents"), WriteLineTextMode.Big);
                                _thermalPrinterGeneric.LineFeed();
                            }

                            //Reset Totals
                            summaryTotalQuantity = 0.0m;
                            summaryTotal         = 0.0m;

                            //Get Group Data from group Query
                            xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(item.Value.Sql);

                            //Generate Columns
                            columns = new List <TicketColumn>();
                            columns.Add(new TicketColumn("GroupTitle", item.Value.Title, 0, TicketColumnsAlign.Left));
                            columns.Add(new TicketColumn("Quantity", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quantity_acronym"), 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));
                            //columns.Add(new TicketColumn("UnitMeasure", string.Empty, 3));
                            columns.Add(new TicketColumn("Total", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_totalfinal_acronym"), 10, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));

                            //Init DataTable
                            dataTable = new DataTable();
                            dataTable.Columns.Add(new DataColumn("GroupDesignation", typeof(string)));
                            dataTable.Columns.Add(new DataColumn("Quantity", typeof(decimal)));
                            //dataTable.Columns.Add(new DataColumn("UnitMeasure", typeof(string)));
                            dataTable.Columns.Add(new DataColumn("Total", typeof(decimal)));

                            //If Has data
                            if (xPSelectData.Data.Length > 0)
                            {
                                foreach (SelectStatementResultRow row in xPSelectData.Data)
                                {
                                    designation = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("Designation")]);
                                    quantity    = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Quantity")]);
                                    unitMeasure = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("UnitMeasure")]);
                                    total       = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Total")]);
                                    // Override Encrypted values
                                    if (GlobalFramework.PluginSoftwareVendor != null && item.Key.Equals(DataTableGroupPropertiesType.DocumentsUser) || item.Key.Equals(DataTableGroupPropertiesType.PaymentsUser))
                                    {
                                        designation = GlobalFramework.PluginSoftwareVendor.Decrypt(designation);
                                    }
                                    //Sum Summary Totals
                                    summaryTotalQuantity += quantity;
                                    summaryTotal         += total;
                                    //_log.Debug(string.Format("Designation: [{0}], quantity: [{1}], unitMeasure: [{2}], total: [{3}]", designation, quantity, unitMeasure, total));
                                    //Create Row
                                    dataRow    = dataTable.NewRow();
                                    dataRow[0] = designation;
                                    dataRow[1] = quantity;
                                    //dataRow[2] = unitMeasure;
                                    dataRow[2] = total;
                                    dataTable.Rows.Add(dataRow);
                                }
                            }
                            else
                            {
                                //Create Row
                                dataRow    = dataTable.NewRow();
                                dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cashdrawer_without_movements");
                                dataRow[1] = 0.0m;
                                //dataRow[2] = string.Empty;//UnitMeasure
                                dataRow[2] = 0.0m;
                                dataTable.Rows.Add(dataRow);
                            }

                            //Add Final Summary Row
                            dataRow    = dataTable.NewRow();
                            dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total");
                            dataRow[1] = summaryTotalQuantity;
                            //dataRow[2] = string.Empty;
                            dataRow[2] = summaryTotal;
                            dataTable.Rows.Add(dataRow);

                            //Prepare TicketTable
                            ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormal);

                            //Custom Print Loop, to Print all Table Rows, and Detect Rows to Print in DoubleHeight (Title and Total)
                            tableCustomPrint = ticketTable.GetTable();
                            WriteLineTextMode rowTextMode;

                            //Dynamic Print All except Last One (Totals), Double Height in Titles
                            for (int i = 0; i < tableCustomPrint.Count - 1; i++)
                            {
                                //Prepare TextMode Based on Row
                                rowTextMode = (i == 0) ? WriteLineTextMode.DoubleHeight : WriteLineTextMode.Normal;
                                //Print Row
                                _thermalPrinterGeneric.WriteLine(tableCustomPrint[i], rowTextMode);
                            }

                            //Line Feed
                            _thermalPrinterGeneric.LineFeed();
                        }
                    }

                    //When finish all groups, print Last Row, the Summary Totals Row, Ommited in Custom Print Loop
                    _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight);

                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    throw new Exception(ex.Message);
                }
            }

            return(result);
        }
Beispiel #7
0
        public PosCashDrawerDialog(Window pSourceWindow, DialogFlags pDialogFlags)
        //Disable WindowTitleCloseButton
            : base(pSourceWindow, pDialogFlags, true, false)
        {
            try
            {
                //Parameters
                _sourceWindow = pSourceWindow;

                //If has a valid open session
                if (GlobalFramework.WorkSessionPeriodTerminal != null)
                {
                    //Get From MoneyInCashDrawer, Includes CASHDRAWER_START and Money Movements
                    _totalAmountInCashDrawer = ProcessWorkSessionPeriod.GetSessionPeriodMovementTotal(GlobalFramework.WorkSessionPeriodTerminal, MovementTypeTotal.MoneyInCashDrawer);
                }
                //Dont have Open Terminal Session YET, use from last Closed CashDrawer
                else
                {
                    //Default Last Closed Cash Value
                    _totalAmountInCashDrawer = ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount("CASHDRAWER_CLOSE");
                }

                //Init Local Vars
                String windowTitle           = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_cashdrawer"), FrameworkUtils.DecimalToStringCurrency(_totalAmountInCashDrawer));
                Size   windowSize            = new Size(462, 310);//400 With Other Payments
                String fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_cash_drawer.png");
                String fileActionPrint       = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Dialogs\icon_pos_dialog_action_print.png");

                //Get SeletedData from WorkSessionMovementType Buttons
                string       executeSql   = @"SELECT Oid, Token, ResourceString, ButtonIcon, Disabled FROM pos_worksessionmovementtype WHERE (Token LIKE 'CASHDRAWER_%') AND (Disabled IS NULL or Disabled  <> 1) ORDER BY Ord;";
                XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(executeSql);
                //Init Dictionary
                string buttonBagKey;
                bool   buttonDisabled;
                Dictionary <string, TouchButtonIconWithText> buttonBag = new Dictionary <string, TouchButtonIconWithText>();
                TouchButtonIconWithText touchButtonIconWithText;
                HBox hboxCashDrawerButtons = new HBox(true, 5);
                bool buttonOkSensitive;

                //Generate Buttons
                foreach (SelectStatementResultRow row in xPSelectData.Data)
                {
                    buttonBagKey   = row.Values[xPSelectData.GetFieldIndex("Token")].ToString();
                    buttonDisabled = Convert.ToBoolean(row.Values[xPSelectData.GetFieldIndex("Disabled")]);

                    touchButtonIconWithText = new TouchButtonIconWithText(
                        string.Format("touchButton{0}_Green", buttonBagKey),
                        Color.Transparent /*_colorBaseDialogDefaultButtonBackground*/,
                        resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], row.Values[xPSelectData.GetFieldIndex("ResourceString")].ToString()),
                        _fontBaseDialogButton,
                        _colorBaseDialogDefaultButtonFont,
                        FrameworkUtils.OSSlash(string.Format("{0}{1}", GlobalFramework.Path["images"], row.Values[xPSelectData.GetFieldIndex("ButtonIcon")].ToString())),
                        _sizeBaseDialogDefaultButtonIcon,
                        _sizeBaseDialogDefaultButton.Width,
                        _sizeBaseDialogDefaultButton.Height
                        )
                    {
                        CurrentButtonOid = new Guid(row.Values[xPSelectData.GetFieldIndex("Oid")].ToString()),
                        Sensitive        = !buttonDisabled
                    };
                    //Add to Dictionary
                    buttonBag.Add(buttonBagKey, touchButtonIconWithText);
                    //pack to VBhox
                    hboxCashDrawerButtons.PackStart(touchButtonIconWithText, true, true, 0);
                    //Events
                    buttonBag[buttonBagKey].Clicked += PosCashDrawerDialog_Clicked;
                }

                //Initial Button Status, Based on Open/Close Terminal Session
                string initialButtonToken;
                if (GlobalFramework.WorkSessionPeriodTerminal != null && GlobalFramework.WorkSessionPeriodTerminal.SessionStatus == WorkSessionPeriodStatus.Open)
                {
                    buttonBag["CASHDRAWER_OPEN"].Sensitive  = false;
                    buttonBag["CASHDRAWER_CLOSE"].Sensitive = true;
                    buttonBag["CASHDRAWER_IN"].Sensitive    = true;
                    buttonBag["CASHDRAWER_OUT"].Sensitive   = true;
                    initialButtonToken = "CASHDRAWER_CLOSE";
                    buttonOkSensitive  = true;
                }
                else
                {
                    buttonBag["CASHDRAWER_OPEN"].Sensitive  = true;
                    buttonBag["CASHDRAWER_CLOSE"].Sensitive = false;
                    buttonBag["CASHDRAWER_IN"].Sensitive    = false;
                    buttonBag["CASHDRAWER_OUT"].Sensitive   = false;
                    initialButtonToken = "CASHDRAWER_OPEN";
                    buttonOkSensitive  = false;
                }
                //Initial Dialog Values
                _selectedCashDrawerButton = buttonBag[initialButtonToken];
                _selectedCashDrawerButton.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(Utils.Lighten(_colorBaseDialogDefaultButtonBackground, 0.50f)));
                _selectedMovementType       = (pos_worksessionmovementtype)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(pos_worksessionmovementtype), _selectedCashDrawerButton.CurrentButtonOid);
                _selectedMovementType.Token = initialButtonToken;

                //EntryAmountMoney
                _entryBoxMovementAmountMoney = new EntryBoxValidation(this, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_money"), KeyboardMode.Money, SettingsApp.RegexDecimalGreaterEqualThanZero, true);
                _entryBoxMovementAmountMoney.EntryValidation.Changed += delegate { ValidateDialog(); };

                //TODO: Enable Other Payments
                //EntryAmountOtherPayments
                //_entryBoxMovementAmountOtherPayments = new EntryBox(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_other_payments, KeyboardModes.Money, regexDecimalGreaterThanZero, false);
                //_entryBoxMovementAmountOtherPayments.EntryValidation.Changed += delegate { ValidateDialog(); };

                //EntryDescription
                _entryBoxMovementDescription = new EntryBoxValidation(this, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_description"), KeyboardMode.AlfaNumeric, SettingsApp.RegexAlfaNumericExtended, false);
                _entryBoxMovementDescription.EntryValidation.Changed += delegate { ValidateDialog(); };

                //VBox
                VBox vbox = new VBox(false, 0);
                vbox.PackStart(hboxCashDrawerButtons, false, false, 0);
                vbox.PackStart(_entryBoxMovementAmountMoney, false, false, 0);
                //vbox.PackStart(_entryBoxMovementAmountOtherPayments, false, false, 0);
                vbox.PackStart(_entryBoxMovementDescription, false, false, 0);

                //Init Content
                Fixed fixedContent = new Fixed();
                fixedContent.Put(vbox, 0, 0);

                //ActionArea Buttons
                _buttonOk              = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok);
                _buttonCancel          = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel);
                _buttonPrint           = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Print);
                _buttonOk.Sensitive    = false;
                _buttonPrint.Sensitive = buttonOkSensitive;

                //ActionArea
                ActionAreaButtons actionAreaButtons = new ActionAreaButtons();
                actionAreaButtons.Add(new ActionAreaButton(_buttonPrint, _responseTypePrint));
                actionAreaButtons.Add(new ActionAreaButton(_buttonOk, ResponseType.Ok));
                actionAreaButtons.Add(new ActionAreaButton(_buttonCancel, ResponseType.Cancel));

                //Call Activate Button Helper Method
                ActivateButton(buttonBag[initialButtonToken]);

                //Init Object
                this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, fixedContent, actionAreaButtons);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Beispiel #8
0
        //LogicPos BootStrap
        private static void Init()
        {
            Console.WriteLine(string.Format("BootStrap {0}....", SettingsApp.AppName));

            try
            {
                //Prepare AutoCreateOption
                AutoCreateOption xpoAutoCreateOption = AutoCreateOption.None;

                //Init Settings Main Config Settings
                //GlobalFramework.Settings = ConfigurationManager.AppSettings;

                //CultureInfo/Localization
                string culture = GlobalFramework.Settings["culture"];
                if (!string.IsNullOrEmpty(culture))
                {
                    /* IN006018 and IN007009 */
                    //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
                }
                //GlobalFramework.CurrentCulture = CultureInfo.CurrentUICulture;
                string sql = "SELECT value FROM cfg_configurationpreferenceparameter where token = 'CULTURE';";
                string getCultureFromDB = GlobalFramework.SessionXpo.ExecuteScalar(sql).ToString();
                GlobalFramework.CurrentCulture = new System.Globalization.CultureInfo(getCultureFromDB);

                //Always use en-US NumberFormat because of mySql Requirements
                GlobalFramework.CurrentCultureNumberFormat = CultureInfo.GetCultureInfo(SettingsApp.CultureNumberFormat);

                // Init Paths
                GlobalFramework.Path = new Hashtable();
                GlobalFramework.Path.Add("temp", FrameworkUtils.OSSlash(GlobalFramework.Settings["pathTemp"]));
                GlobalFramework.Path.Add("saftpt", FrameworkUtils.OSSlash(GlobalFramework.Settings["pathSaftPt"]));
                //Create Directories
                FrameworkUtils.CreateDirectory(FrameworkUtils.OSSlash(Convert.ToString(GlobalFramework.Path["temp"])));
                FrameworkUtils.CreateDirectory(FrameworkUtils.OSSlash(Convert.ToString(GlobalFramework.Path["saftpt"])));

                //Get DataBase Details
                GlobalFramework.DatabaseType = (DatabaseType)Enum.Parse(typeof(DatabaseType), GlobalFramework.Settings["databaseType"]);
                GlobalFramework.DatabaseName = SettingsApp.DatabaseName;
                //Xpo Connection String
                string xpoConnectionString = string.Format(GlobalFramework.Settings["xpoConnectionString"], GlobalFramework.DatabaseName.ToLower());

                //Init XPO Connector DataLayer
                try
                {
                    _log.Debug(string.Format("Init XpoDefault.DataLayer: [{0}]", xpoConnectionString));
                    XpoDefault.DataLayer       = XpoDefault.GetDataLayer(xpoConnectionString, xpoAutoCreateOption);
                    GlobalFramework.SessionXpo = new Session(XpoDefault.DataLayer)
                    {
                        LockingOption = LockingOption.None
                    };
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    throw;
                }

                //Get Terminal from Db
                GlobalFramework.LoggedTerminal = Utils.GetTerminal();

                //SettingsApp
                SettingsApp.ConfigurationSystemCountry  = (cfg_configurationcountry)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(cfg_configurationcountry), new Guid(GlobalFramework.Settings["xpoOidConfigurationCountrySystemCountry"]));
                SettingsApp.ConfigurationSystemCurrency = (cfg_configurationcurrency)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(cfg_configurationcurrency), new Guid(GlobalFramework.Settings["xpoOidConfigurationCurrencySystemCurrency"]));

                //PreferenceParameters
                GlobalFramework.PreferenceParameters = FrameworkUtils.GetPreferencesParameters();

                //Try to Get open Session Day/Terminal for this Terminal
                GlobalFramework.WorkSessionPeriodDay      = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);
                GlobalFramework.WorkSessionPeriodTerminal = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Terminal);

                //Init FastReports Custom Functions and Custom Vars
                CustomFunctions.Register(SettingsApp.AppName);

                //Init AppSession
                //string appSessionFile = SettingsApp.AppSessionFile;
                //if (File.Exists(appSessionFile))
                //{
                //    GlobalFramework.SessionApp = GlobalFrameworkSession.InitSession(appSessionFile);
                //}
                //else
                //{
                //    throw new Exception(string.Format("Missing appSessionFile: {0}", appSessionFile));
                //}
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Beispiel #9
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

        private void Init()
        {
            try
            {
                //Used to Force create DatabaseScema and Fixtures with XPO (Non Script Mode): Requirements for Work: Empty or Non Exist Database
                //Notes: OnError "An exception of type 'DevExpress.Xpo.DB.Exceptions.SchemaCorrectionNeededException'", UnCheck [X] Break when this exception is user-unhandled and continue, watch log and wait until sucefull message appear
                bool xpoCreateDatabaseAndSchema           = SettingsApp.XPOCreateDatabaseAndSchema;
                bool xpoCreateDatabaseObjectsWithFixtures = xpoCreateDatabaseAndSchema;
                //Prepare AutoCreateOption
                AutoCreateOption xpoAutoCreateOption = (xpoCreateDatabaseAndSchema) ? AutoCreateOption.DatabaseAndSchema : AutoCreateOption.None;

                //Init Settings Main Config Settings
                //GlobalFramework.Settings = ConfigurationManager.AppSettings;

                //Override Licence data with Encrypted File Data
                if (File.Exists(SettingsApp.LicenceFileName))
                {
                    Utils.AssignLicence(SettingsApp.LicenceFileName, true);
                }

                //Other Global App Settings
                GlobalApp.MultiUserEnvironment = Convert.ToBoolean(GlobalFramework.Settings["appMultiUserEnvironment"]);
                GlobalApp.UseVirtualKeyBoard   = Convert.ToBoolean(GlobalFramework.Settings["useVirtualKeyBoard"]);

                //Init App Notifications
                GlobalApp.Notifications = new System.Collections.Generic.Dictionary <string, bool>();
                GlobalApp.Notifications["SHOW_PRINTER_UNDEFINED"] = true;

                //System
                GlobalApp.FilePickerStartPath = System.IO.Directory.GetCurrentDirectory();

                //Get DataBase Details
                GlobalFramework.DatabaseType = (DatabaseType)Enum.Parse(typeof(DatabaseType), GlobalFramework.Settings["databaseType"]);
                //Override default Database name with parameter from config
                string configDatabaseName = GlobalFramework.Settings["databaseName"];
                GlobalFramework.DatabaseName = (string.IsNullOrEmpty(configDatabaseName)) ? SettingsApp.DatabaseName : configDatabaseName;
                //Xpo Connection String
                string xpoConnectionString = string.Format(GlobalFramework.Settings["xpoConnectionString"], GlobalFramework.DatabaseName.ToLower());
                Utils.AssignConnectionStringToSettings(xpoConnectionString);

                //Removed Protected Files
                //ProtectedFiles, Before Create Database from Scripts, usefull if Scripts are modified by User
                if (SettingsApp.ProtectedFilesUse)
                {
                    GlobalApp.ProtectedFiles = InitProtectedFiles();
                }

                //Check if Database Exists if Not Create it from Scripts
                bool databaseCreated = false;
                if (!xpoCreateDatabaseAndSchema)
                {
                    //Get result to check if DB is created (true)
                    try
                    {
                        // Launch Scripts
                        databaseCreated = DataLayer.CreateDatabaseSchema(xpoConnectionString, GlobalFramework.DatabaseType, GlobalFramework.DatabaseName);
                    }
                    catch (Exception ex)
                    {
                        //Extra protection to prevent goes to login without a valid connection
                        _log.Error(ex.Message, ex);
                        Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new Size(900, 700), MessageType.Error, ButtonsType.Ok, Resx.global_error, ex.Message);
                        Environment.Exit(0);
                    }
                }

                //Init XPO Connector DataLayer
                try
                {
                    _log.Debug(string.Format("Init XpoDefault.DataLayer: [{0}]", xpoConnectionString));
                    XpoDefault.DataLayer       = XpoDefault.GetDataLayer(xpoConnectionString, xpoAutoCreateOption);
                    GlobalFramework.SessionXpo = new Session(XpoDefault.DataLayer)
                    {
                        LockingOption = LockingOption.None
                    };
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new Size(900, 700), MessageType.Error, ButtonsType.Ok, Resx.global_error, ex.Message);
                    throw;
                }

                //Check Valid Database Scheme
                if (!xpoCreateDatabaseAndSchema && !FrameworkUtils.IsRunningOnMono())
                {
                    bool isSchemaValid = DataLayer.IsSchemaValid(xpoConnectionString);
                    _log.Debug(string.Format("Check if Database Scheme: isSchemaValid : [{0}]", isSchemaValid));
                    if (!isSchemaValid)
                    {
                        string endMessage = "Invalid database Schema! Fix database Schema and Try Again!";
                        Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new Size(500, 300), MessageType.Error, ButtonsType.Ok, Resx.global_error, string.Format(endMessage, Environment.NewLine));
                        Environment.Exit(0);
                    }
                }

                // Assign PluginSoftwareVendor Reference to DataLayer SettingsApp to use In Date Protection, we Required to assign it Statically to Prevent Circular References
                // Required to be here, before it is used in above lines, ex Utils.GetTerminal()
                if (GlobalFramework.PluginSoftwareVendor != null)
                {
                    logicpos.datalayer.App.SettingsApp.PluginSoftwareVendor = GlobalFramework.PluginSoftwareVendor;
                }

                //If not in Xpo create database Scheme Mode, Get Terminal from Db
                if (!xpoCreateDatabaseAndSchema)
                {
                    GlobalFramework.LoggedTerminal = Utils.GetTerminal();
                }

                //After Assigned LoggedUser
                if (xpoCreateDatabaseObjectsWithFixtures)
                {
                    InitFixtures.InitUserAndTerminal(GlobalFramework.SessionXpo);
                    InitFixtures.InitOther(GlobalFramework.SessionXpo);
                    InitFixtures.InitDocumentFinance(GlobalFramework.SessionXpo);
                    InitFixtures.InitWorkSession(GlobalFramework.SessionXpo);
                }

                //End Xpo Create Scheme and Fixtures, Terminate App and Request assign False to Developer Vars
                if (xpoCreateDatabaseAndSchema)
                {
                    string endMessage = "Xpo Create Schema and Fixtures Done!{0}Please assign false to 'xpoCreateDatabaseAndSchema' and 'xpoCreateDatabaseObjectsWithFixtures' and run App again";
                    Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new Size(500, 300), MessageType.Info, ButtonsType.Ok, Resx.global_information, string.Format(endMessage, Environment.NewLine));
                    Environment.Exit(0);
                }

                //Init PreferenceParameters
                GlobalFramework.PreferenceParameters = FrameworkUtils.GetPreferencesParameters();
                //Init Preferences Path
                MainApp.InitPathsPrefs();

                bool validDirectoryBackup = FrameworkUtils.CreateDirectory(FrameworkUtils.OSSlash(Convert.ToString(GlobalFramework.Path["backups"])));
                //Show Dialog if Cant Create Backups Directory (Extra Protection for Shared Network Folders)
                if (!validDirectoryBackup)
                {
                    ResponseType response = Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, Resx.global_error, string.Format(Resx.dialog_message_error_create_directory_backups, Convert.ToString(GlobalFramework.Path["backups"])));
                    //Enable Quit After BootStrap, Preventing Application.Run()
                    if (response == ResponseType.No)
                    {
                        _quitAfterBootStrap = true;
                    }
                }

                //CultureInfo/Localization
                string culture = GlobalFramework.PreferenceParameters["CULTURE"];
                if (!string.IsNullOrEmpty(culture))
                {
                    Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
                }
                GlobalFramework.CurrentCulture = CultureInfo.CurrentUICulture;
                //Always use en-US NumberFormat because of mySql Requirements
                GlobalFramework.CurrentCultureNumberFormat = CultureInfo.GetCultureInfo(SettingsApp.CultureNumberFormat);

                //Init AppSession
                string appSessionFile = Utils.GetSessionFileName();
                if (databaseCreated && File.Exists(appSessionFile))
                {
                    File.Delete(appSessionFile);
                }
                GlobalFramework.SessionApp = GlobalFrameworkSession.InitSession(appSessionFile);

                //Try to Get open Session Day/Terminal for this Terminal
                GlobalFramework.WorkSessionPeriodDay      = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);
                GlobalFramework.WorkSessionPeriodTerminal = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Terminal);

                //Use Detected ScreenSize
                string appScreenSize = string.IsNullOrEmpty(GlobalFramework.Settings["appScreenSize"])
                    ? GlobalFramework.PreferenceParameters["APP_SCREEN_SIZE"]
                    : GlobalFramework.Settings["appScreenSize"];
                if (appScreenSize.Replace(" ", string.Empty).Equals("0,0") || string.IsNullOrEmpty(appScreenSize))
                {
                    // Force Unknown Screen Size
                    //GlobalApp.ScreenSize = new Size(2000, 1800);
                    GlobalApp.ScreenSize = Utils.GetThemeScreenSize();
                }
                //Use config ScreenSize
                else
                {
                    Size configAppScreenSize = Utils.StringToSize(appScreenSize);
                    GlobalApp.ScreenSize = Utils.GetThemeScreenSize(configAppScreenSize);
                }

                // Init ExpressionEvaluator
                GlobalApp.ExpressionEvaluator.EvaluateFunction += ExpressionEvaluatorExtended.ExpressionEvaluator_EvaluateFunction;
                // Init Variables
                ExpressionEvaluatorExtended.InitVariablesStartupWindow();
                ExpressionEvaluatorExtended.InitVariablesPosMainWindow();

                // Define Max Dialog Window Size
                GlobalApp.MaxWindowSize = new Size(GlobalApp.ScreenSize.Width - 40, GlobalApp.ScreenSize.Height - 40);
                // Add Variables to ExpressionEvaluator.Variables Singleton
                GlobalApp.ExpressionEvaluator.Variables.Add("globalScreenSize", GlobalApp.ScreenSize);

                //Parse and store Theme in Singleton
                try
                {
                    GlobalApp.Theme = XmlToObjectParser.ParseFromFile(SettingsApp.FileTheme);
                    // Use with dynamic Theme properties like:
                    // GlobalApp.Theme.Theme.Frontoffice.Window[0].Globals.Name = PosBaseWindow
                    // GlobalApp.Theme.Theme.Frontoffice.Window[1].Objects.TablePadUser.Position = 50,50
                    // or use predicate with from object id ex
                    //var predicate = (Predicate<dynamic>)((dynamic x) => x.ID == "StartupWindow");
                    //var themeWindow = GlobalApp.Theme.Theme.Frontoffice.Window.Find(predicate);
                    //_log.Debug(string.Format("Message: [{0}]", themeWindow.Globals.Title));
                }
                catch (Exception ex)
                {
                    Utils.ShowMessageTouchErrorRenderTheme(GlobalApp.WindowStartup, ex.Message);
                }

                //Init FastReports Custom Functions and Custom Vars
                CustomFunctions.Register(SettingsApp.AppName);

                //Hardware : Init Display
                if (GlobalFramework.LoggedTerminal.PoleDisplay != null)
                {
                    GlobalApp.UsbDisplay = (UsbDisplayDevice)UsbDisplayDevice.InitDisplay();
                    GlobalApp.UsbDisplay.WriteCentered(string.Format("{0} {1}", SettingsApp.AppName, FrameworkUtils.ProductVersion), 1);
                    GlobalApp.UsbDisplay.WriteCentered(SettingsApp.AppUrl, 2);
                    GlobalApp.UsbDisplay.EnableStandBy();
                }

                //Hardware : Init BarCodeReader
                if (GlobalFramework.LoggedTerminal.BarcodeReader != null)
                {
                    GlobalApp.BarCodeReader = new InputReader();
                }

                //Hardware : Init WeighingBalance
                if (GlobalFramework.LoggedTerminal.WeighingMachine != null)
                {
                    GlobalApp.WeighingBalance = new WeighingBalance(GlobalFramework.LoggedTerminal.WeighingMachine);
                    //_log.Debug(string.Format("IsPortOpen: [{0}]", GlobalApp.WeighingBalance.IsPortOpen()));
                }

                //Start Database Backup Timer if not create XPO Schema and SoftwareVendor is Active
                if (GlobalFramework.PluginSoftwareVendor != null && validDirectoryBackup && !xpoCreateDatabaseAndSchema)
                {
                    _backupDatabaseTimeSpan           = TimeSpan.Parse(GlobalFramework.PreferenceParameters["DATABASE_BACKUP_TIMESPAN"]);
                    _databaseBackupTimeSpanRangeStart = TimeSpan.Parse(GlobalFramework.PreferenceParameters["DATABASE_BACKUP_TIME_SPAN_RANGE_START"]);
                    _databaseBackupTimeSpanRangeEnd   = TimeSpan.Parse(GlobalFramework.PreferenceParameters["DATABASE_BACKUP_TIME_SPAN_RANGE_END"]);
                    StartBackupTimer();
                }

                //Send To Log
                _log.Debug(string.Format("ProductVersion: [{0}], ImageRuntimeVersion: [{1}], IsLicensed: [{2}]", FrameworkUtils.ProductVersion, FrameworkUtils.ProductAssembly.ImageRuntimeVersion, LicenceManagement.IsLicensed));

                //Audit
                FrameworkUtils.Audit("APP_START", string.Format("{0} {1} clr {2}", SettingsApp.AppName, FrameworkUtils.ProductVersion, FrameworkUtils.ProductAssembly.ImageRuntimeVersion));
                if (databaseCreated)
                {
                    FrameworkUtils.Audit("DATABASE_CREATE");
                }

                // Plugin Errors Messages
                if (GlobalFramework.PluginSoftwareVendor == null || !GlobalFramework.PluginSoftwareVendor.IsValidSecretKey(SettingsApp.SecretKey))
                {
                    Utils.ShowMessageTouch(GlobalApp.WindowStartup, DialogFlags.Modal, new Size(650, 380), MessageType.Error, ButtonsType.Ok, Resx.global_error, Resx.dialog_message_error_plugin_softwarevendor_not_registered);
                    _log.Debug(String.Format("Wrong key detected [{0}]. Use a valid LogicposFinantialLibrary with same key as SoftwareVendorPlugin", SettingsApp.SecretKey));
                }

                //Create SystemNotification
                FrameworkUtils.SystemNotification();

                //Clean Documents Folder on New Database, else we have Document files that dont correspond to Database
                if (databaseCreated && Directory.Exists(GlobalFramework.Path["documents"].ToString()))
                {
                    string documentsFolder     = GlobalFramework.Path["documents"].ToString();
                    System.IO.DirectoryInfo di = new DirectoryInfo(documentsFolder);
                    if (di.GetFiles().Length > 0)
                    {
                        _log.Debug(string.Format("New database created. Start Delete [{0}] document(s) from [{1}] folder!", di.GetFiles().Length, documentsFolder));
                        foreach (FileInfo file in di.GetFiles())
                        {
                            try
                            {
                                file.Delete();
                            }
                            catch (Exception)
                            {
                                _log.Error(string.Format("Error! Cant delete Document file : [{0}]", file.Name));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Beispiel #10
0
        private Dictionary <string, AccordionNode> GetAccordionDefinition()
        {
            _log.Debug("GetAccordionDefinition Begin");

            //Init accordionDefinition
            Dictionary <string, AccordionNode> accordionDefinition = null;

            try
            {
                accordionDefinition = new Dictionary <string, AccordionNode>();
                Widget startContent;

                //Define Start Content for backoffice mode
                _dashboardButton.Content = Utils.GetGenericTreeViewXPO <DashBoard>(this);
                startContent             = Utils.GetGenericTreeViewXPO <DashBoard>(this);
                //_labelActiveContent.Text = "DASHBOARD";

                ////Define Start Content with Articles TreeView
                //else
                //{
                //    startContent = Utils.GetGenericTreeViewXPO<TreeViewArticle>(this);
                //    //Hide/Show Current Active Content based on user privileges
                //    string currentNodePrivilegesToken = string.Format(_privilegesBackOfficeMenuOperation, "Article".ToUpper());
                //    startContent.Sensitive = FrameworkUtils.HasPermissionTo(currentNodePrivilegesToken);
                //    _labelActiveContent.Text = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_articles");
                //}


                _nodeContent = startContent;

                _hboxContent.PackEnd(_nodeContent);

                //Define used CriteriaOperators/Override Defaults from TreeViews
                CriteriaOperator criteriaOperatorCustomer = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1) AND (Hidden IS NULL OR Hidden = 0)");
                CriteriaOperator criteriaConfigurationPreferenceParameterCompany = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1) AND (Token <> 'COMPANY_COUNTRY_OID' AND Token <> 'SYSTEM_CURRENCY_OID' AND FormType = 1)");
                CriteriaOperator criteriaConfigurationPreferenceParameterSystem  = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1) AND (FormType = 2)");

                //START WORK SESSION AND DAY FOR BACKOFFICE MODE
                if (GlobalFramework.AppUseBackOfficeMode)
                {
                    bool openDay = ProcessWorkSessionPeriod.SessionPeriodOpen(WorkSessionPeriodType.Day, "");
                    if (openDay)
                    {
                        pos_worksessionperiod workSessionPeriodDay = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);
                        GlobalFramework.WorkSessionPeriodTerminal = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);
                        GlobalFramework.WorkSessionPeriodTerminal.SessionStatus = WorkSessionPeriodStatus.Open;
                    }
                }

                ////TK016235 BackOffice - Mode - Finance Documents for backoffice mode
                Dictionary <string, AccordionNode> _accordionChildDocuments = new Dictionary <string, AccordionNode>();
                _accordionChildDocuments.Add("DocumentsNew", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_new_finance_documents"))
                {
                    Clicked = delegate { Utils.startNewDocumentFromBackOffice(this); }
                });
                _accordionChildDocuments.Add("DocumentsShow", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_record_finance_documents"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 1); }
                });
                _accordionChildDocuments.Add("DocumentsPay", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_finance_documents_ft_unpaid"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 2); }
                });
                _accordionChildDocuments.Add("DocumentsPayments", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_payments"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 3); }
                });
                _accordionChildDocuments.Add("DocumentsCurrentAccount", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_finance_documents_cc"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 4); }
                });
                //_accordionChildDocuments.Add("DocumentsListall", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents")) {  Content = Utils.GetGenericTreeViewXPO<DashBoard>(this) }); ;
                Utils util = new Utils();
                util._accordionChildDocumentsTemp = _accordionChildDocuments;
                Dictionary <string, AccordionNode> _accordionChildReports = new Dictionary <string, AccordionNode>();
                _accordionChildReports.Add("DocumentsReports", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_reports"))
                {
                    Clicked = delegate { Utils.startReportsMenuFromBackOffice(this); }
                });

                //Articles
                Dictionary <string, AccordionNode> _accordionChildArticles = new Dictionary <string, AccordionNode>();
                //, Clicked = testClickedEventHandlerFromOutside }
                _accordionChildArticles.Add("ArticleFamily", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_families"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleFamily>(this)
                });;
                _accordionChildArticles.Add("ArticleSubFamily", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_subfamilies"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleSubFamily>(this)
                });
                _accordionChildArticles.Add("Article", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_articles"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticle>(this)
                });
                _accordionChildArticles.Add("ArticleType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_article_types"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleType>(this)
                });
                _accordionChildArticles.Add("ArticleClass", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_article_class"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleClass>(this)
                });
                _accordionChildArticles.Add("ConfigurationPriceType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_price_type"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPriceType>(this)
                });
                Utils.startTreeViewFromBackOffice(_accordionChildArticles);
                // Disable to Speed uo Opening BO, noew we have Stock Reports
                //_accordionChildArticles.Add("ArticleStock", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_stock_movements) { Content = Utils.GetGenericTreeViewXPO<TreeViewArticleStock>(this) });

                //Customers
                Dictionary <string, AccordionNode> _accordionChildCustomers = new Dictionary <string, AccordionNode>();
                _accordionChildCustomers.Add("Customer", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customers"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewCustomer>(this, criteriaOperatorCustomer)
                });
                _accordionChildCustomers.Add("CustomerType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customer_types"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewCustomerType>(this)
                });
                _accordionChildCustomers.Add("CustomerDiscountGroup", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customer_discount_groups"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewCustomerDiscountGroup>(this)
                });

                //Users
                Dictionary <string, AccordionNode> _accordionChildUsers = new Dictionary <string, AccordionNode>();
                _accordionChildUsers.Add("UserDetail", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_users"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewUser>(this)
                });
                //Commented by Mario: Not Usefull, UserPermissionProfile has same funtionality
                //_accordionChildUsers.Add("UserProfile", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_profile) { Content = Utils.GetGenericTreeViewXPO<TreeViewUserProfile>(this) });
                //WARNING: Works with diferent constructs, its still need to be improved : new TreeViewUserProfilePermissions(this)
                _accordionChildUsers.Add("UserPermissionProfile", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_user_permissions"))
                {
                    Content = new TreeViewUserProfilePermissions(this)
                });
                _accordionChildUsers.Add("UserCommissionGroup", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_user_commission_groups"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewUserCommissionGroup>(this)
                });
                //Moved to Custom Toolbar
                //_accordionChildUsers.Add("System_ApplyPrivileges", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_user_apply_privileges) { Clicked = delegate { Accordion.UpdateMenuPrivileges(); } });

                //Documents
                Dictionary <string, AccordionNode> _accordionDocuments = new Dictionary <string, AccordionNode>();
                _accordionDocuments.Add("DocumentFinanceYears", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_years"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewDocumentFinanceYears>(this)
                });
                _accordionDocuments.Add("DocumentFinanceSeries", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_series"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewDocumentFinanceSeries>(this)
                });
                _accordionDocuments.Add("DocumentFinanceType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_type"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewDocumentFinanceType>(this)
                });
                //_accordionDocuments.Add("DocumentFinanceYearSerieTerminal", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_yearsseriesterminal) { Content = Utils.GetGenericTreeViewXPO<TreeViewDocumentFinanceYearSerieTerminal>(this) });
                _accordionDocuments.Add("ConfigurationVatRate", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_vat_rates"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationVatRate>(this)
                });
                _accordionDocuments.Add("ConfigurationVatExemptionReason", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_vat_exemption_reason"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationVatExceptionReason>(this)
                });
                _accordionDocuments.Add("ConfigurationPaymentCondition", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_payment_conditions"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPaymentCondition>(this)
                });
                _accordionDocuments.Add("ConfigurationPaymentMethod", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_payment_methods"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPaymentMethod>(this)
                });

                //AuxiliarTables
                Dictionary <string, AccordionNode> _accordionChildAuxiliarTables = new Dictionary <string, AccordionNode>();
                //_accordionChildAuxiliarTables.Add("ConfigurationCashRegister", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cash_registers) { Content = Utils.GetGenericTreeView<TreeViewConfigurationCashRegister>(this) });
                _accordionChildAuxiliarTables.Add("ConfigurationCountry", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_country"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationCountry>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationCurrency", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationCurrency"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationCurrency>(this)
                });
                //_accordionChildAuxiliarTables.Add("ConfigurationDevice", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_devices) { Content = Utils.GetGenericTreeView<TreeViewConfigurationDevice>(this) });
                //_accordionChildAuxiliarTables.Add("ConfigurationKeyboard", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_keyboards) { Content = Utils.GetGenericTreeView<TreeViewConfigurationKeyboard>(this) });
                //_accordionChildAuxiliarTables.Add("ConfigurationMaintenance", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_maintenance) { Content = Utils.GetGenericTreeView<TreeViewConfigurationMaintenance>(this) });
                _accordionChildAuxiliarTables.Add("ConfigurationPlace", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_places"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlace>(this)
                });
                /* IN009035 */
                string configurationPlaceTableLabel = SettingsApp.IsDefaultTheme ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_place_tables") : resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_orders");
                _accordionChildAuxiliarTables.Add("ConfigurationPlaceTable", new AccordionNode(configurationPlaceTableLabel)
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceTable>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationPlaceMovementType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_places_movement_type"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceMovementType>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationUnitMeasure", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_units_measure"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationUnitMeasure>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationUnitSize", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_units_size"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationUnitSize>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationHolidays", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_holidays"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationHolidays>(this)
                });

                //Devices
                Dictionary <string, AccordionNode> _accordionDevices = new Dictionary <string, AccordionNode>();
                _accordionDevices.Add("ConfigurationPrintersType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPrintersType"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPrintersType>(this)
                });
                _accordionDevices.Add("ConfigurationPrinters", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPrinters"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPrinters>(this)
                });
                _accordionDevices.Add("ConfigurationInputReader", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationInputReader"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationInputReader>(this)
                });
                _accordionDevices.Add("ConfigurationPoleDisplay", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPoleDisplay"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPoleDisplay>(this)
                });
                _accordionDevices.Add("ConfigurationWeighingMachine", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationWeighingMachine"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationWeighingMachine>(this)
                });
                // Deprecated
                //_accordionPrinters.Add("ConfigurationPrintersTemplates", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPrintersTemplates) { Content = Utils.GetGenericTreeViewXPO<TreeViewConfigurationPrintersTemplates>(this) });
                //_accordionPrinters.Add("ExternalApp_Composer", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_callposcomposer) { Content = null, ExternalAppFileName = SettingsApp.ExecutableComposer });

                //Configuration
                Dictionary <string, AccordionNode> _accordionChildConfiguration = new Dictionary <string, AccordionNode>();
                _accordionChildConfiguration.Add("ConfigurationPreferenceParameterCompany", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_preferenceparameter_company"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPreferenceParameter>(this, criteriaConfigurationPreferenceParameterCompany)
                });
                _accordionChildConfiguration.Add("ConfigurationPreferenceParameterSystem", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_preferenceparameter_system"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPreferenceParameter>(this, criteriaConfigurationPreferenceParameterSystem)
                });
                _accordionChildConfiguration.Add("ConfigurationPlaceTerminal", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_places_terminals"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceTerminal>(this)
                });


                //import
                Dictionary <string, AccordionNode> _accordionChildImport = new Dictionary <string, AccordionNode>();
                _accordionChildImport.Add("System_Import_Articles", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_import_articles"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.OpenExcelArticles); }
                });
                _accordionChildImport.Add("System_Import_Costumers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_import_costumers"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.OpenExcelCostumers); }
                });


                // Add Menu Items Based On Plugins PluginSoftwareVendor
                Dictionary <string, AccordionNode> _accordionChildExport = new Dictionary <string, AccordionNode>();
                //Export
                if (GlobalFramework.PluginSoftwareVendor != null && SettingsApp.ConfigurationSystemCountry.Oid == SettingsApp.XpoOidConfigurationCountryPortugal)
                {
                    _accordionChildExport.Add("System_ExportSaftPT_SaftPt", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_saftpt_whole_year"))
                    {
                        Clicked = delegate { FrameworkCalls.ExportSaftPt(this, ExportSaftPtMode.WholeYear); }
                    });
                    _accordionChildExport.Add("System_ExportSaftPT_E-Fatura", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_saftpt_last_month"))
                    {
                        Clicked = delegate { FrameworkCalls.ExportSaftPt(this, ExportSaftPtMode.LastMonth); }
                    });
                    _accordionChildExport.Add("System_ExportSaftPT_Custom", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_saftpt_custom"))
                    {
                        Clicked = delegate { FrameworkCalls.ExportSaftPt(this, ExportSaftPtMode.Custom); }
                    });
                }
                _accordionChildExport.Add("System_Export_Articles", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_articles"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.ExportArticles); }
                });
                _accordionChildExport.Add("System_Export_Costumers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_costumers"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.ExportCustomers); }
                });
                //System
                Dictionary <string, AccordionNode> _accordionChildSystem = new Dictionary <string, AccordionNode>();
                /* IN006001 - "System" > "Notification" menu option */
                _accordionChildSystem.Add("System_Notification", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_notification"))
                {
                    Clicked = delegate { Utils.ShowNotifications(this, true); }
                });
                // Add Menu Items Based On Plugins PluginSoftwareVendor
                if (GlobalFramework.PluginSoftwareVendor != null)
                {
                    _accordionChildSystem.Add("System_DataBaseBackup", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_database_backup"))
                    {
                        Clicked = delegate { DataBaseBackup.Backup(this); }
                    });
                    _accordionChildSystem.Add("System_DataBaseRestore_FromSystem", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_database_restore"))
                    {
                        Clicked = delegate { DataBaseBackup.Restore(this, DataBaseRestoreFrom.SystemBackup); }
                    });
                    _accordionChildSystem.Add("System_DataBaseRestore_FromFile", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_database_restore_from_file"))
                    {
                        Clicked = delegate { DataBaseBackup.Restore(this, DataBaseRestoreFrom.ChooseFromFilePickerDialog); }
                    });
                }
                _accordionChildSystem.Add("System_Menu", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_application_logout_user"))
                {
                    Clicked = ClickedSystemLogout
                });
                //                _accordionChildSystem.Add("System_Pos", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_pos) { Clicked = ClickedSystemPos });
                //_accordionChildSystem.Add("System_Quit", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quit")) { Clicked = delegate { LogicPos.Quit(this); } });

                //Compose Main Accordion Parent Buttons
                //TK016235 BackOffice - Mode
                if (GlobalFramework.AppUseBackOfficeMode)
                {
                    accordionDefinition.Add("TopMenuFinanceDocuments", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_record_finance_documents"))
                    {
                        Childs = _accordionChildDocuments, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_documentos.png")
                    });
                }
                accordionDefinition.Add("TopMenuArticles", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_articles"))
                {
                    Childs = _accordionChildArticles, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_artigos.png")
                });
                accordionDefinition.Add("TopMenuDocuments", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documents"))
                {
                    Childs = _accordionDocuments, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_informacao_fiscal.png")
                });
                accordionDefinition.Add("TopMenuCustomers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customers"))
                {
                    Childs = _accordionChildCustomers, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_clientes.png")
                });
                accordionDefinition.Add("TopMenuUsers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_users"))
                {
                    Childs = _accordionChildUsers, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_utilizadores.png")
                });
                accordionDefinition.Add("TopMenuDevices", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_devices"))
                {
                    Childs = _accordionDevices, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_impressoras.png")
                });
                accordionDefinition.Add("TopMenuOtherTables", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_other_tables"))
                {
                    Childs = _accordionChildAuxiliarTables, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_outras_tabelas.png")
                });
                accordionDefinition.Add("TopMenuConfiguration", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_configuration"))
                {
                    Childs = _accordionChildConfiguration, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_configuracao.png")
                });
                //TK016235 BackOffice - Mode
                if (GlobalFramework.AppUseBackOfficeMode)
                {
                    accordionDefinition.Add("TopMenuReports", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_reports"))
                    {
                        Childs = _accordionChildReports, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_relatorios.png")
                    });
                }

                accordionDefinition.Add("TopMenuImport", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_import"))
                {
                    Childs = _accordionChildImport, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_import.png")
                });

                if (_accordionChildExport.Count > 0)
                {
                    accordionDefinition.Add("TopMenuExport", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export"))
                    {
                        Childs = _accordionChildExport, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_export.png")
                    });
                }
                accordionDefinition.Add("TopMenuSystem", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_system"))
                {
                    Childs = _accordionChildSystem, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_sistema.png")
                });



                //Assets/Images/Icons/Accordion/pos_backoffice_sistema.png
                //Assets/Images/Icons/icon_pos_toolbar_back_office.png
                //TK016235 BackOffice - Mode
                //if (!GlobalFramework.AppUseBackOfficeMode)
                //{
                //    Dictionary<string, AccordionNode> _accordionChildSystemPOSMainWindow = new Dictionary<string, AccordionNode>();
                //    _accordionChildSystemPOSMainWindow.Add("System_Pos", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_pos")) { Clicked = ClickedSystemPos });
                //    accordionDefinition.Add("TopMenuPOSMainWindow", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_pos")) { Childs = _accordionChildSystemPOSMainWindow, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_sistema.png") });
                //}
                _log.Debug("GetAccordionDefinition End");
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(accordionDefinition);
        }
Beispiel #11
0
        private bool CanCloseWorkSessionPeriodDay()
        {
            //Check if has Working Open Orders/Tables
            XPSelectData xPSelectDataTables  = ProcessWorkSessionPeriod.GetOpenOrderTables();
            int          noOfOpenOrderTables = xPSelectDataTables.Data.Length;

            if (noOfOpenOrderTables > 0)
            {
                string openOrderTables = string.Empty;
                POS_ConfigurationPlaceTable currentOpenOrderTable;
                Guid tableOid = Guid.Empty;
                foreach (SelectStatementResultRow row in xPSelectDataTables.Data)
                {
                    tableOid = new Guid(row.Values[xPSelectDataTables.GetFieldIndex("PlaceTable")].ToString());
                    currentOpenOrderTable = GlobalFramework.SessionXpo.GetObjectByKey <POS_ConfigurationPlaceTable>(tableOid);
                    openOrderTables      += string.Format("{0}{1}", currentOpenOrderTable.Designation, " ");
                }

                ResponseType dialogResponse = Utils.ShowMessageTouch(
                    this,
                    DialogFlags.Modal,
                    new Size(620, 300),
                    MessageType.Error,
                    ButtonsType.Close,
                    Resx.global_error,
                    string.Format(Resx.dialog_message_worksession_period_warning_open_orders_tables, noOfOpenOrderTables, string.Format("{0}{1}", Environment.NewLine, openOrderTables))
                    );

                //Exit Event Button Without Close Cash Drwawer
                return(false);
            }

            //Check if has Working Terminal Sessions
            XPSelectData xPSelectDataTerminals    = ProcessWorkSessionPeriod.GetSessionPeriodOpenTerminalSessions();
            int          noOfTerminalOpenSessions = xPSelectDataTerminals.Data.Length;

            if (noOfTerminalOpenSessions > 0)
            {
                string openTerminals = string.Empty;
                POS_ConfigurationPlaceTerminal currentOpenSessionTerminal;
                Guid terminalOid = Guid.Empty;
                foreach (SelectStatementResultRow row in xPSelectDataTerminals.Data)
                {
                    terminalOid = new Guid(row.Values[xPSelectDataTerminals.GetFieldIndex("Terminal")].ToString());
                    currentOpenSessionTerminal = GlobalFramework.SessionXpo.GetObjectByKey <POS_ConfigurationPlaceTerminal>(terminalOid);
                    openTerminals += string.Format("{0}{1} - {2}", Environment.NewLine, currentOpenSessionTerminal.Designation, row.Values[xPSelectDataTerminals.GetFieldIndex("Designation")].ToString());
                }

////Check if Has Opened Terminal Connections before Close Day
//PosMessageDialog messageDialog = new PosMessageDialog(
//    this,
//    DialogFlags.DestroyWithParent,
//    new Size(600, 300),
//    string.Format(Resx.dialog_message_worksession_period_warning_open_terminals, noOfTerminalOpenSessions, string.Format("{0}{1}", Environment.NewLine, openTerminals)),
//    MessageType.Warning,
//    ResponseType.Ok,
//    Resx.global_button_label_ok
//);

//int messageDialogResponse = messageDialog.Run();
//messageDialog.Destroy();

                ResponseType responseType = Utils.ShowMessageTouch(this, DialogFlags.Modal, new Size(600, 400), MessageType.Question, ButtonsType.YesNo, Resx.global_information,
                                                                   string.Format(Resx.dialog_message_worksession_period_warning_open_terminals, noOfTerminalOpenSessions, string.Format("{0}{1}", Environment.NewLine, openTerminals))
                                                                   );

                if (responseType == ResponseType.Yes)
                {
                    return(Utils.CloseAllOpenTerminals(this, GlobalFramework.SessionXpo));
                }
                else
                {
                    //Exit Event Button Without Close Period Day Session
                    return(false);
                }
            }
            return(true);
        }
Beispiel #12
0
        void _touchButtonCashDrawer_Clicked(object sender, EventArgs e)
        {
            bool result;

            //ProcessWorkSessionPeriod.GetSessionPeriodMovementTotalDebug(GlobalFramework.WorkSessionPeriodTerminal, true );
            PosCashDrawerDialog dialogCashDrawer = new PosCashDrawerDialog(this, DialogFlags.DestroyWithParent);

            int response = dialogCashDrawer.Run();

            if (response == (int)ResponseType.Ok)
            {
                //Get Fresh XPO Objects, Prevent Deleted Object Bug
                POS_WorkSessionPeriod workSessionPeriodDay = GlobalFramework.SessionXpo.GetObjectByKey <POS_WorkSessionPeriod>(GlobalFramework.WorkSessionPeriodDay.Oid);
                POS_WorkSessionPeriod workSessionPeriodTerminal;

                switch (dialogCashDrawer.MovementType.Token)
                {
                case "CASHDRAWER_OPEN":

                    //Start Terminal Period
                    result = ProcessWorkSessionPeriod.SessionPeriodOpen(WorkSessionPeriodType.Terminal, dialogCashDrawer.MovementDescription);

                    if (result)
                    {
                        //Update UI
                        GlobalApp.WindowPos.UpdateWorkSessionUI();
                        GlobalApp.WindowPos.TicketList.UpdateOrderStatusBar();

                        //Here we already have GlobalFramework.WorkSessionPeriodTerminal, assigned on ProcessWorkSessionPeriod.SessionPeriodStart
                        //Get Fresh XPO Objects, Prevent Deleted Object Bug
                        workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <POS_WorkSessionPeriod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                        result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                            workSessionPeriodTerminal,
                            dialogCashDrawer.MovementType,
                            GlobalFramework.LoggedUser,
                            GlobalFramework.LoggedTerminal,
                            FrameworkUtils.CurrentDateTimeAtomic(),
                            dialogCashDrawer.MovementAmountMoney,
                            dialogCashDrawer.MovementDescription
                            );
                    }

                    if (result)
                    {
                        //PrintWorkSessionMovement
                        FrameworkCalls.PrintCashDrawerOpenAndMoneyInOut(dialogCashDrawer, GlobalFramework.LoggedTerminal.Printer, Resx.ticket_title_worksession_terminal_open, 0.0m, dialogCashDrawer.TotalAmountInCashDrawer, dialogCashDrawer.MovementDescription);

                        //Enable UI Buttons When Have Open Session
                        GlobalApp.WindowPos.TouchButtonPosToolbarNewFinanceDocument.Sensitive = true;
                        //Open CashDrawer
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, new Size(500, 280), MessageType.Info, ButtonsType.Close, Resx.global_information, Resx.dialog_message_cashdrawer_open_successfully);
                    }
                    else
                    {
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, Resx.app_error_contact_support);
                    }
                    break;

                case "CASHDRAWER_CLOSE":

                    //Stop Terminal Period
                    result = ProcessWorkSessionPeriod.SessionPeriodClose(GlobalFramework.WorkSessionPeriodTerminal);

                    if (result)
                    {
                        //Update UI
                        GlobalApp.WindowPos.UpdateWorkSessionUI();
                        GlobalApp.WindowPos.LabelCurrentTable.Text = Resx.status_message_open_cashdrawer;

                        //Get Fresh XPO Objects, Prevent Deleted Object Bug
                        workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <POS_WorkSessionPeriod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                        //Add CASHDRAWER_CLOSE Movement to Day Period
                        result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                            workSessionPeriodTerminal,
                            dialogCashDrawer.MovementType,
                            GlobalFramework.LoggedUser,
                            GlobalFramework.LoggedTerminal,
                            FrameworkUtils.CurrentDateTimeAtomic(),
                            dialogCashDrawer.MovementAmountMoney,
                            dialogCashDrawer.MovementDescription
                            );

                        //PrintWorkSessionMovement
                        FrameworkCalls.PrintWorkSessionMovement(dialogCashDrawer, GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodTerminal);

                        //Enable UI Buttons When Have Open Session
                        GlobalApp.WindowPos.TouchButtonPosToolbarNewFinanceDocument.Sensitive = false;
                        //Show ClosePeriodMessage
                        ShowClosePeriodMessage(dialogCashDrawer, GlobalFramework.WorkSessionPeriodTerminal);
                    }
                    break;

                case "CASHDRAWER_IN":

                    dialogCashDrawer.TotalAmountInCashDrawer += dialogCashDrawer.MovementAmountMoney;

                    workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <POS_WorkSessionPeriod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                    result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                        workSessionPeriodTerminal,
                        dialogCashDrawer.MovementType,
                        GlobalFramework.LoggedUser,
                        GlobalFramework.LoggedTerminal,
                        FrameworkUtils.CurrentDateTimeAtomic(),
                        dialogCashDrawer.MovementAmountMoney,
                        dialogCashDrawer.MovementDescription
                        );

                    if (result)
                    {
                        //PrintCashDrawerOpenAndMoneyInOut
                        FrameworkCalls.PrintCashDrawerOpenAndMoneyInOut(dialogCashDrawer, GlobalFramework.LoggedTerminal.Printer, Resx.ticket_title_worksession_money_in, dialogCashDrawer.MovementAmountMoney, dialogCashDrawer.TotalAmountInCashDrawer, dialogCashDrawer.MovementDescription);
                        //Open CashDrawer
                        PrintRouter.OpenDoor(GlobalFramework.LoggedTerminal.Printer);
                        //Audit
                        FrameworkUtils.Audit("CASHDRAWER_IN", string.Format(
                                                 Resx.audit_message_cashdrawer_in,
                                                 FrameworkUtils.DecimalToStringCurrency(dialogCashDrawer.MovementAmountMoney),
                                                 dialogCashDrawer.MovementDescription)
                                             );

                        //ShowMessage
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, new Size(500, 300), MessageType.Info, ButtonsType.Close, Resx.global_information, Resx.dialog_message_operation_successfully);
                    }
                    else
                    {
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, Resx.app_error_contact_support);
                    }
                    break;

                //Work with Terminal Session
                case "CASHDRAWER_OUT":

                    dialogCashDrawer.TotalAmountInCashDrawer -= dialogCashDrawer.MovementAmountMoney;

                    workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <POS_WorkSessionPeriod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                    //In Period Terminal
                    result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                        workSessionPeriodTerminal,
                        dialogCashDrawer.MovementType,
                        GlobalFramework.LoggedUser,
                        GlobalFramework.LoggedTerminal,
                        FrameworkUtils.CurrentDateTimeAtomic(),
                        -dialogCashDrawer.MovementAmountMoney,
                        dialogCashDrawer.MovementDescription
                        );

                    if (result)
                    {
                        //PrintCashDrawerOpenAndMoneyInOut
                        FrameworkCalls.PrintCashDrawerOpenAndMoneyInOut(dialogCashDrawer, GlobalFramework.LoggedTerminal.Printer, Resx.ticket_title_worksession_money_out, dialogCashDrawer.MovementAmountMoney, dialogCashDrawer.TotalAmountInCashDrawer, dialogCashDrawer.MovementDescription);
                        //Open CashDrawer
                        PrintRouter.OpenDoor(GlobalFramework.LoggedTerminal.Printer);
                        //Audit
                        FrameworkUtils.Audit("CASHDRAWER_OUT", string.Format(
                                                 Resx.audit_message_cashdrawer_out,
                                                 FrameworkUtils.DecimalToStringCurrency(dialogCashDrawer.MovementAmountMoney),
                                                 dialogCashDrawer.MovementDescription)
                                             );
                        //ShowMessage
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, new Size(500, 300), MessageType.Info, ButtonsType.Close, Resx.global_information, Resx.dialog_message_operation_successfully);
                    }
                    else
                    {
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, Resx.app_error_contact_support);
                    }

                    break;

                case "CASHDRAWER_MONEY_OUT":
                    break;

                default:
                    break;
                }
            }
            ;
            dialogCashDrawer.Destroy();

            //TODO: Remove Comments
            //_log.Debug(string.Format("ProcessWorkSessionPeriod: [{0}]", ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount(GlobalFramework.WorkSessionPeriodDay)));
            //if (GlobalFramework.WorkSessionPeriodDay != null) ProcessWorkSessionPeriod.GetSessionPeriodMovementTotalDebug(GlobalFramework.WorkSessionPeriodDay, true);
            //if (GlobalFramework.WorkSessionPeriodTerminal != null) ProcessWorkSessionPeriod.GetSessionPeriodMovementTotalDebug(GlobalFramework.WorkSessionPeriodTerminal, true);
        }
Beispiel #13
0
        protected override void OnResponse(ResponseType pResponse)
        {
            if (pResponse == ResponseType.Ok)
            {
                _movementAmountMoney = FrameworkUtils.StringToDecimal(_entryBoxMovementAmountMoney.EntryValidation.Text);
                _movementDescription = _entryBoxMovementDescription.EntryValidation.Text;

                decimal cashLastMovementTypeAmount = 0.0m;

                if (_selectedMovementType.Token == "CASHDRAWER_OPEN")
                {
                    cashLastMovementTypeAmount = ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount("CASHDRAWER_CLOSE");
                }
                else if (_selectedMovementType.Token == "CASHDRAWER_CLOSE")
                {
                    cashLastMovementTypeAmount = ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount("CASHDRAWER_OPEN");
                    //Keep Running
                    if (!IsCashDrawerAmountValid(cashLastMovementTypeAmount))
                    {
                        this.Run();
                    }
                    else
                    {
                        pResponse = Utils.ShowMessageTouch(
                            this, DialogFlags.Modal, new Size(500, 350), MessageType.Question, ButtonsType.YesNo, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_button_label_print"),
                            resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_request_print_document_confirmation"));

                        if (pResponse == ResponseType.Yes)
                        {
                            FrameworkCalls.PrintWorkSessionMovement(this, GlobalFramework.LoggedTerminal.ThermalPrinter, GlobalFramework.WorkSessionPeriodTerminal);
                        }
                    }
                }
                else if (_selectedMovementType.Token == "CASHDRAWER_OUT")
                {
                    //Check if Value is Small than AmountInCashDrawer
                    if (_movementAmountMoney > _totalAmountInCashDrawer)
                    {
                        string movementAmountMoney     = FrameworkUtils.DecimalToStringCurrency(_movementAmountMoney);
                        string totalAmountInCashDrawer = FrameworkUtils.DecimalToStringCurrency(_totalAmountInCashDrawer);

                        Utils.ShowMessageTouch(
                            this, DialogFlags.Modal, new Size(500, 350), MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"),
                            string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_cashdrawer_money_out_error"), movementAmountMoney, totalAmountInCashDrawer)
                            );
                        //Keep Running
                        this.Run();
                    }
                }
            }
            else if (pResponse == _responseTypePrint)
            {
                //Uncomment to Pront Session Day
                //PrintTicket.PrintWorkSessionMovementInit(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodDay);

                //PrintWorkSessionMovement
                //PrintRouter.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodTerminal);
                FrameworkCalls.PrintWorkSessionMovement(this, GlobalFramework.LoggedTerminal.ThermalPrinter, GlobalFramework.WorkSessionPeriodTerminal);

                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodDay);
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodTerminal);
                //(_sourceWindow as PosCashDialog).ShowClosePeriodMessage(GlobalFramework.WorkSessionPeriodDay);
                //(_sourceWindow as PosCashDialog).ShowClosePeriodMessage(GlobalFramework.WorkSessionPeriodTerminal);

                //TEST FROM PERSISTED GUID, PAST RESUMES - DEBUG ONLY
                //WorkSessionPeriod workSessionPeriodDay;
                //WorkSessionPeriod workSessionPeriodTerminal;

                //#0 - Day 1
                //workSessionPeriodDay = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("90a187b3-c91b-4c5b-907a-d54a6ee1dcb6"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodDay);
                //#8 - Day 2
                //workSessionPeriodDay = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("5ce65097-55a2-4a6c-9406-aabe9f3f0124"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodDay);

                //#1 - Day1
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("12d74d99-9734-4adb-b322-82f337e24d3e"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#2 - Day1
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("67758bb2-c52a-4c05-8e10-37f63f729ce4"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#3 - Day1
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("f43ae288-3615-44c0-b876-4fcac01efd1e"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#4 - Day1
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("8b261a90-c15d-4e54-a013-c85467338224"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#5 - Day1
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("13816f1f-4dd5-4351-afe4-c492f61cacb1"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#6 - Day1
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("e5698d06-5740-4317-b7c7-d3eb92063b37"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#7 - Day1
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("734c8ed3-34f9-4096-8c20-de9110a24817"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#9 - Day2 - Terminal #10
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("f445c36c-3ebd-46f1-bcbd-d158e497eda9"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#10 - Day2 - Terminal #20
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("74fd498a-c1a7-46e6-a117-14eea795e93d"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);
                //#11 - Day2 - Terminal #30
                //workSessionPeriodTerminal = (WorkSessionPeriod)FrameworkUtils.GetXPGuidObjectFromSession(typeof(WorkSessionPeriod), new Guid("14631cda-f31a-4e7a-8a75-a3ba2955ccf8"));
                //PrintTicket.PrintWorkSessionMovement(GlobalFramework.LoggedTerminal.Printer, workSessionPeriodTerminal);

                this.Run();
            }
        }