void dialogSelectRecord_Response(object o, ResponseArgs args) { PosSelectRecordDialog <DataTable, DataRow, TreeViewTerminalSeries> dialog = (PosSelectRecordDialog <DataTable, DataRow, TreeViewTerminalSeries>)o; if (args.ResponseId != ResponseType.Cancel) { if (args.ResponseId == ResponseType.Ok) { //Init _resultDataTable, Clone Structure from _dialogSelectRecord.GenericTreeView.DataSource _resultDataTable = _dialogSelectRecord.GenericTreeView.DataSource.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)); } } } }
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //Helper Methods /// <summary> /// Helper method to get VatExemptionReason /// </summary> /// <returns>VatExemptionReason Guid</returns> private Guid GetVatExemptionReason() { Guid result = new Guid(); CriteriaOperator criteria = CriteriaOperator.Parse("(Disabled = 0 OR Disabled IS NULL)"); PosSelectRecordDialog <XPCollection, XPGuidObject, TreeViewConfigurationVatExceptionReason> dialog = new PosSelectRecordDialog <XPCollection, XPGuidObject, TreeViewConfigurationVatExceptionReason>( _sourceWindow, DialogFlags.DestroyWithParent, Resx.global_vat_exemption_reason, GlobalApp.MaxWindowSize, null, //XpoDefaultValue criteria, GenericTreeViewMode.Default, null //pActionAreaButtons ); int response = dialog.Run(); if (response == (int)ResponseType.Ok) { result = dialog.GenericTreeView.DataSourceRow.Oid; } dialog.Destroy(); return(result); }
/// <summary> /// If Record is Selected and Ok clicked /// </summary> /// <param name="pEntry"></param> /// <param name="dialog"></param> private void SelectRecord(Entry pEntry, PosSelectRecordDialog <XPCollection, XPGuidObject, T2> dialog) { PropertyInfo propertyInfo; //Store previousValue before update _value, to keep it _previousValue = _value; //Get Object from dialog else Mixing Sessions, Both belong to diferente Sessions _value = (T1)FrameworkUtils.GetXPGuidObject(typeof(T1), dialog.GenericTreeView.DataSourceRow.Oid); propertyInfo = typeof(T1).GetProperty(_fieldDisplayValue); object value = null; if (propertyInfo != null) { // Get value from XPGuidObject Instance value = propertyInfo.GetValue(_value, null); } else { string invalidFieldMessage = string.Format("Invalid Field DisplayValue:[{0}] on XPGuidObject:[{1}]", _fieldDisplayValue, _value.GetType().Name); _log.Error(invalidFieldMessage); value = invalidFieldMessage; } pEntry.Text = (value != null) ? value.ToString() : resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"); //Call Custom Event, Only if OK, if Cancel Dont Trigger Event OnClosePopup(); }
private static DataBaseBackupFileInfo GetSelectRecordFileName(Window pSourceWindow) { DataBaseBackupFileInfo resultFileInfo = new DataBaseBackupFileInfo(); try { CriteriaOperator criteriaOperator = CriteriaOperator.Parse(string.Format("DataBaseType = '{0}' && FileName IS NOT NULL", GlobalFramework.DatabaseType)); PosSelectRecordDialog <XPCollection, XPGuidObject, TreeViewSystemBackup> dialogSystemBackup = new PosSelectRecordDialog <XPCollection, XPGuidObject, TreeViewSystemBackup>( pSourceWindow, Gtk.DialogFlags.DestroyWithParent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_select_backup_filename"), new Size(780, 580), null, //XpoDefaultValue criteriaOperator, GenericTreeViewMode.Default, null //ActionAreaButtons ); ResponseType response = (ResponseType)dialogSystemBackup.Run(); if (response == ResponseType.Ok) { //Assign Result resultFileInfo.Response = response; sys_systembackup systemBackup = (sys_systembackup)dialogSystemBackup.GenericTreeView.DataSourceRow; if (systemBackup != null) { if (GlobalFramework.DatabaseType == DatabaseType.MSSqlServer) { resultFileInfo.FileName = systemBackup.FileName; resultFileInfo.FileHashValid = true; } else { resultFileInfo.FileName = FrameworkUtils.OSSlash(string.Format(@"{0}{1}", _pathBackups, systemBackup.FileName)); resultFileInfo.FileNamePacked = FrameworkUtils.OSSlash(string.Format(@"{0}{1}", _pathBackups, systemBackup.FileNamePacked)); resultFileInfo.FileHashDB = systemBackup.FileHash; resultFileInfo.FileHashFile = FrameworkUtils.MD5HashFile(resultFileInfo.FileNamePacked); } } } dialogSystemBackup.Destroy(); } catch (Exception ex) { _log.Error(ex.Message, ex); } return(resultFileInfo); }
//Events protected void PopupDialog(Entry pEntry) { try { //Call Custom Event OnOpenPopup(); PosSelectRecordDialog <XPCollection, XPGuidObject, T2> dialog = new PosSelectRecordDialog <XPCollection, XPGuidObject, T2>( _sourceWindow, DialogFlags.DestroyWithParent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_select_record"), _dialogSize, _value, _criteriaOperator, GenericTreeViewMode.Default, null //ActionAreaButtons ); CriteriaOperatorLastFilter = dialog.GenericTreeView.DataSource.Criteria; int response = 0; // Recapture RowActivated : DoubleClick and trigger dialog.Respond dialog.GenericTreeView.TreeView.RowActivated += delegate { dialog.Respond(ResponseType.Ok); }; //_buttonSelectValue.Clicked += delegate { SelectRecord(pEntry, dialog); }; response = PopuDialogMore(pEntry, dialog); /* IN009223 - Call to: * - SelectRecord(pEntry, dialog); * - dialog.Destroy(); * Were causing issues to dialog box messages, therefore call to them removed. */ } catch (Exception ex) { _log.Error(ex.Message, ex); } }
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //Shared UI Helper to Request Selected Terminals to send to ProcessFinanceDocumentSeries (Framework) public static bool UICreateDocumentFinanceYearSeriesTerminal(Window pSourceWindow, FIN_DocumentFinanceYears pDocumentFinanceYear) { bool result = false; try { //Refresh Terminal XPO Object XPCollection xpcConfigurationPlaceTerminal = new XPCollection(GlobalFramework.SessionXpo, typeof(POS_ConfigurationPlaceTerminal)); xpcConfigurationPlaceTerminal.Reload(); //Get Terminals DataTable dataTableSelectedTerminals = PosSelectRecordDialog <DataTable, DataRow, TreeViewTerminalSeries> .GetSelected(pSourceWindow); //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceSeries treeViewDocumentFinanceSeries = ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceSeries")) ? ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceSeries"].Content as TreeViewDocumentFinanceSeries) : null; //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceYearSerieTerminal treeViewDocumentFinanceYearSerieTerminal = ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceYearSerieTerminal")) ? ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceYearSerieTerminal"].Content as TreeViewDocumentFinanceYearSerieTerminal) : null; if (dataTableSelectedTerminals != null && dataTableSelectedTerminals.Rows.Count > 0) { //Request Acronym //string initialValue = string.Format("{0}{1}", pDocumentFinanceYear.Acronym, "01"); string initialValue = pDocumentFinanceYear.Acronym; logicpos.Utils.ResponseText resultAcronym = TreeViewDocumentFinanceSeries.PosConfirmAcronymSeriesDialog(pSourceWindow, pDocumentFinanceYear, dataTableSelectedTerminals, initialValue); // Protect to Skip Cancel if (resultAcronym.ResponseType == ResponseType.Ok) { int sqlCheckExistingSeriesResultInt = 0; string sqlCheckExistingSeries = "SELECT COUNT(*) AS Count FROM fin_documentfinanceseries WHERE (Disabled = 0 OR Disabled IS NULL);"; object sqlCheckExistingSeriesResult = GlobalFramework.SessionXpo.ExecuteScalar(sqlCheckExistingSeries); if (sqlCheckExistingSeriesResult != null) { sqlCheckExistingSeriesResultInt = Convert.ToInt16(sqlCheckExistingSeriesResult); } //Request User Confirmation if already has working Series ResponseType responseType = ResponseType.No; if (resultAcronym.ResponseType == ResponseType.Ok && sqlCheckExistingSeriesResultInt > 0) { responseType = Utils.ShowMessageTouch( GlobalApp.WindowStartup, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, Resx.window_title_series_create_series, Resx.dialog_message_series_create_confirmation_text ); } else { //Auto Yes, if dont have series, assumes Yes responseType = ResponseType.Yes; } if (responseType == ResponseType.Yes) { //Get Result FrameworkCallsResult frameworkCallsResult = ProcessFinanceDocumentSeries.CreateDocumentFinanceYearSeriesTerminal(pDocumentFinanceYear, dataTableSelectedTerminals, resultAcronym.Text, false); //Prepare Result result = frameworkCallsResult.Result; //Refresh Child Trees DocumentFinanceYearSerieTerminal if (result) { //Refresh TreeViewDocumentFinanceSeries (If Visible/Enabled) if (treeViewDocumentFinanceSeries != null) { treeViewDocumentFinanceSeries.Refresh(); } //Refresh TreeViewDocumentFinanceYearSerieTerminal (If Visible/Enabled) if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } } //Show Error to User, Outside of Framework (Non UI) else { Utils.ShowMessageTouch( pSourceWindow, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, string.Format("{0}{1}{1}{2}", string.Format(Resx.dialog_message_series_create_error, resultAcronym.Text), Environment.NewLine, frameworkCallsResult.Exception.InnerException.Message ) ); } } } } } catch (Exception ex) { _log.Error(ex.Message, ex); } return(result); }
//Events protected void PopupDialog(Entry pEntry) { try { //Call Custom Event OnOpenPopup(); //Local Vars PropertyInfo propertyInfo; PosSelectRecordDialog <XPCollection, XPGuidObject, T2> dialog = new PosSelectRecordDialog <XPCollection, XPGuidObject, T2>( _sourceWindow, DialogFlags.DestroyWithParent, Resx.window_title_dialog_select_record, _dialogSize, _value, _criteriaOperator, GenericTreeViewMode.Default, null //ActionAreaButtons ); // Recapture RowActivated : DoubleClick and trigger dialog.Respond dialog.GenericTreeView.TreeView.RowActivated += delegate { dialog.Respond(ResponseType.Ok); }; int response = dialog.Run(); if (response == (int)ResponseType.Ok) { //Store previousValue before update _value, to keep it _previousValue = _value; //Get Object from dialog else Mixing Sessions, Both belong to diferente Sessions _value = (T1)FrameworkUtils.GetXPGuidObject(typeof(T1), dialog.GenericTreeView.DataSourceRow.Oid); propertyInfo = typeof(T1).GetProperty(_fieldDisplayValue); object value = null; if (propertyInfo != null) { // Get value from XPGuidObject Instance value = propertyInfo.GetValue(_value, null); } else { string invalidFieldMessage = string.Format("Invalid Field DisplayValue:[{0}] on XPGuidObject:[{1}]", _fieldDisplayValue, _value.GetType().Name); _log.Error(invalidFieldMessage); value = invalidFieldMessage; } pEntry.Text = (value != null) ? value.ToString() : Resx.global_error; //Call Custom Event, Only if OK, if Cancel Dont Trigger Event OnClosePopup(); } dialog.Destroy(); } catch (Exception ex) { _log.Error(ex.Message, ex); } }
public DataTable SelectRecordDialog() { //Default ActionArea Buttons TouchButtonIconWithText buttonOk = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok); 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 <DataTable, DataRow, TreeViewTerminalSeries>( _sourceWindow, DialogFlags.DestroyWithParent, Resx.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; //Get Indexes int indexColumnCheckBox = _dialogSelectRecord.GenericTreeView.DataSource.Columns.IndexOf("CheckBox"); int indexColumnDesignation = _dialogSelectRecord.GenericTreeView.DataSource.Columns.IndexOf("Designation"); //Update Dialog Title bool itemChecked = (bool)_dialogSelectRecord.GenericTreeView.DataSourceRow.ItemArray[indexColumnCheckBox]; string designation = (string)_dialogSelectRecord.GenericTreeView.DataSourceRow.ItemArray[indexColumnDesignation]; _dialogSelectRecord.WindowTitle = (_dialogSelectRecord.GenericTreeView.MarkedCheckBoxs > 0) ? string.Format("{0} : MarkedCheckBoxs:[{1}] : Last:[{2}]", Resx.window_title_dialog_select_record, _dialogSelectRecord.GenericTreeView.MarkedCheckBoxs, designation) : Resx.window_title_dialog_select_record ; } }; //Events _dialogSelectRecord.Response += dialogSelectRecord_Response; //Call Dialog int response = _dialogSelectRecord.Run(); _dialogSelectRecord.Destroy(); //Return DataTable with CheckItems return(_resultDataTable); }
/// <summary> /// Recursive function for pagination /// </summary> /// <param name="pEntry"></param> /// <param name="dialog"></param> /// <returns></returns> public int PopuDialogMore(Entry pEntry, PosSelectRecordDialog <XPCollection, XPGuidObject, T2> dialog) { DialogResponseType response = (DialogResponseType)dialog.Run(); // Recapture RowActivated : DoubleClick and trigger dialog.Respond dialog.GenericTreeView.TreeView.RowActivated += delegate { SelectRecord(pEntry, dialog); }; if (DialogResponseType.Ok.Equals(response)) { SelectRecord(pEntry, dialog); } //Pagination response if (DialogResponseType.LoadMore.Equals(response)) { dialog.GenericTreeView.DataSource.TopReturnedObjects = (SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber); dialog.GenericTreeView.Refresh(); PopuDialogMore(pEntry, dialog); } //Filter response else if (DialogResponseType.Filter.Equals(response)) { //Reset current page to 1 ( Pagination go to defined initialy ) // Filter SellDocuments string filterField = string.Empty; string statusField = string.Empty; string extraFilter = string.Empty; List <string> result = new List <string>(); PosReportsQueryDialog dialogFilter = new PosReportsQueryDialog(dialog, DialogFlags.DestroyWithParent, ReportsQueryDialogMode.FILTER_DOCUMENTS_PAGINATION, "fin_documentfinancemaster"); DialogResponseType responseFilter = (DialogResponseType)dialogFilter.Run(); //If button Clean Filter Clicked if (DialogResponseType.CleanFilter.Equals(responseFilter)) { dialog.GenericTreeView.CurrentPageNumber = 1; dialog.GenericTreeView.DataSource.Criteria = CriteriaOperatorLastFilter; dialog.GenericTreeView.DataSource.TopReturnedObjects = SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber; dialog.GenericTreeView.Refresh(); dialogFilter.Destroy(); PopuDialogMore(pEntry, dialog); } //If OK filter clicked else if (DialogResponseType.Ok.Equals(responseFilter)) { dialog.GenericTreeView.CurrentPageNumber = 1; filterField = "DocumentType"; statusField = "DocumentStatusStatus"; /* IN009066 - FS and NC added to reports */ //extraFilter = $@" AND ({statusField} <> 'A') AND ( // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeInvoice}' OR // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeSimplifiedInvoice}' OR // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeInvoiceAndPayment}' OR // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeConsignationInvoice}' OR // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeDebitNote}' OR // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeCreditNote}' OR // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypePayment}' // OR // {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput}' // )".Replace(Environment.NewLine, string.Empty); /* IN009089 - # TO DO: above, we need to check with business this condition: {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput}' */ //Assign Dialog FilterValue to Method Result Value result.Add($"{dialogFilter.FilterValue}"); result.Add(dialogFilter.FilterValueHumanReadble); //string addFilter = FilterValue; CriteriaOperator criteriaOperatorLast = dialog.GenericTreeView.DataSource.Criteria; CriteriaOperator criteriaOperator = GroupOperator.And(CriteriaOperatorLastFilter, CriteriaOperator.Parse(result[0])); //lastData = dialog.GenericTreeView.DataSource; dialog.GenericTreeView.DataSource.Criteria = criteriaOperator; dialog.GenericTreeView.DataSource.TopReturnedObjects = SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber; dialog.GenericTreeView.Refresh(); //se retornar zero resultados apresenta dados anteriores ao filtro if (dialog.GenericTreeView.DataSource.Count == 0) { dialog.GenericTreeView.DataSource.Criteria = criteriaOperatorLast; dialog.GenericTreeView.DataSource.TopReturnedObjects = SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber; dialog.GenericTreeView.Refresh(); } dialogFilter.Destroy(); PopuDialogMore(pEntry, dialog); } //If Cancel Filter Clicked else { dialogFilter.Destroy(); PopuDialogMore(pEntry, dialog); } } //Button Close clicked else { dialog.Destroy(); } return((int)response); }