Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 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 = 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;
                }
            }
        }
Ejemplo n.º 3
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);
        }