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; } } }
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; } } }
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); }
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(); } }