private static void dialogSelectRecord_Response(object o, ResponseArgs args) { PosSelectRecordDialog <T1, T2, T3> dialog = (PosSelectRecordDialog <T1, T2, T3>)o; if (args.ResponseId != ResponseType.Cancel) { if (args.ResponseId == ResponseType.Ok) { //Init _resultDataTable, Clone Structure from _dialogSelectRecord.GenericTreeView.DataSource _resultDataTable = (_dialogSelectRecord.GenericTreeView.DataSource as DataTable).Clone(); //Single Record Mode - Default - USED HERE ONLY TO TEST Both Dialogs Modes (Default and CheckBox) if (dialog.GenericTreeViewMode == GenericTreeViewMode.Default) { //use dialog.GenericTreeView.DataTableRow.ItemArray } //Multi Record Mode - CheckBox - ACTIVE MODE else if (dialog.GenericTreeViewMode == GenericTreeViewMode.CheckBox) { //Required to use ListStoreModel and not ListStoreModelFilterSort, we only loop the visible filtered rows, and not The hidden Checked Rows dialog.GenericTreeView.ListStoreModel.Foreach(new TreeModelForeachFunc(TreeModelForEachTask)); } } } }
void buttonPrintOrder_Clicked(object sender, EventArgs e) { if (Utils.ShowMessageTouchRequiredValidPrinter(this)) { return; } string sql = string.Empty; OrderMain currentOrderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid]; Guid orderTicketOid = new Guid(); sql = string.Format(@"SELECT COUNT(*) AS Count FROM fin_documentorderticket WHERE OrderMain = '{0}';", currentOrderMain.PersistentOid); var countTickets = GlobalFramework.SessionXpo.ExecuteScalar(sql); //If has more than one ticket show requestTicket dialog if (countTickets != null && Convert.ToInt16(countTickets) > 1) { CriteriaOperator criteria = CriteriaOperator.Parse(string.Format("OrderMain = '{0}'", currentOrderMain.PersistentOid)); PosSelectRecordDialog <XPCollection, XPGuidObject, TreeViewDocumentOrderTicket> dialog = new PosSelectRecordDialog <XPCollection, XPGuidObject, TreeViewDocumentOrderTicket>( this.SourceWindow, DialogFlags.DestroyWithParent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_select_ticket"), //TODO:THEME GlobalApp.MaxWindowSize, null, //XpoDefaultValue criteria, GenericTreeViewMode.Default, null //pActionAreaButtons ); int response = dialog.Run(); if (response == (int)ResponseType.Ok) { orderTicketOid = dialog.GenericTreeView.DataSourceRow.Oid; } dialog.Destroy(); } //Else Print Unique Ticket else { sql = string.Format(@"SELECT Oid FROM fin_documentorderticket WHERE OrderMain = '{0}';", currentOrderMain.PersistentOid); //_log.Debug(string.Format("sql: [{0}]", sql)); orderTicketOid = FrameworkUtils.GetGuidFromQuery(sql); } if (orderTicketOid != new Guid()) { fin_documentorderticket orderTicket = (fin_documentorderticket)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_documentorderticket), orderTicketOid); //POS front-end - Consulta Mesa + Impressão Ticket's + Gerar PDF em modo Thermal Printer [IN009344] ThermalPrinterInternalDocumentOrderRequest thermalPrinterInternalDocumentOrderRequest = new ThermalPrinterInternalDocumentOrderRequest(GlobalFramework.LoggedTerminal.ThermalPrinter, orderTicket); thermalPrinterInternalDocumentOrderRequest.Print(); } }
//Todo //Improve in future to Work with XPOObjects Too, when needed, already wotk with generics, only need minor changes to XPObjects //T1: DataSource (XPCollection|DataTable) //T2: DataSourceRow (XPGuidObject|DataRow) //T3: GenericTreeType public static DataTable GetSelected(Window pSourceWindow) { //Default ActionArea Buttons TouchButtonIconWithText buttonOk = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok); buttonOk.Sensitive = false; TouchButtonIconWithText buttonCancel = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel); //ActionArea Buttons ActionAreaButtons actionAreaButtons = new ActionAreaButtons(); //Add references to Send to Event CursorChanged ActionAreaButton actionAreaButtonOk = new ActionAreaButton(buttonOk, ResponseType.Ok); ActionAreaButton actionAreaButtonCancel = new ActionAreaButton(buttonCancel, ResponseType.Cancel); actionAreaButtons.Add(actionAreaButtonOk); actionAreaButtons.Add(actionAreaButtonCancel); _dialogSelectRecord = new PosSelectRecordDialog <T1, T2, T3>( pSourceWindow, DialogFlags.DestroyWithParent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_select_record"), GlobalApp.MaxWindowSize, null, //pDefaultValue : Require to Send a DataRow GenericTreeViewMode.CheckBox, actionAreaButtons ); //CheckBox Capture CursorChanged/CheckBoxToggled Event, And enable/disable Buttons based on Valid Selection, Must be Here, Where we have a refence to Buttons _dialogSelectRecord.CheckBoxToggled += delegate { //Use inside delegate to have accesss to local references, ex dialogPartialPayment, actionAreaButtonOk if (_dialogSelectRecord.GenericTreeViewMode == GenericTreeViewMode.Default) { //DataTableMode else use XPGuidObject if (_dialogSelectRecord.GenericTreeView.DataSourceRow != null) { actionAreaButtonOk.Button.Sensitive = true; } } else if (_dialogSelectRecord.GenericTreeViewMode == GenericTreeViewMode.CheckBox) { actionAreaButtonOk.Button.Sensitive = (_dialogSelectRecord.GenericTreeView.MarkedCheckBoxs > 0) ? true : false; //This Code may be Usefull in a near future to Update TitleBar //Get Indexes //int indexColumnCheckBox = (_dialogSelectRecord.GenericTreeView.DataSource as DataTable).Columns.IndexOf("CheckBox"); //int indexColumnDesignation = (_dialogSelectRecord.GenericTreeView.DataSource as DataTable).Columns.IndexOf("Designation"); //Update Dialog Title //bool itemChecked = (bool)(_dialogSelectRecord.GenericTreeView.DataSourceRow as DataRow).ItemArray[indexColumnCheckBox]; //string designation = (string)(_dialogSelectRecord.GenericTreeView.DataSourceRow as DataRow).ItemArray[indexColumnDesignation]; //_dialogSelectRecord.WindowTitle = // (_dialogSelectRecord.GenericTreeView.MarkedCheckBoxs > 0) // ? string.Format("{0} : MarkedCheckBoxs:[{1}] : Last:[{2}]", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_select_record, _dialogSelectRecord.GenericTreeView.MarkedCheckBoxs, designation) // : resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_select_record //; } }; //Events _dialogSelectRecord.Response += dialogSelectRecord_Response; //Call Dialog int response = _dialogSelectRecord.Run(); //Always Destroy Dialog _dialogSelectRecord.Destroy(); //Return DataTable with Selectd (One) or CheckItems, or Empty DataTable if (response == -6) { _resultDataTable = new DataTable(); } return(_resultDataTable); }