//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //Static Helpers //UI Helper to Request Acronym for Terminal Series public static logicpos.Utils.ResponseText PosConfirmAcronymSeriesDialog(Window pSourceWindow, FIN_DocumentFinanceYears pDocumentFinanceYear, DataTable pTerminals, string pInitialValue) { logicpos.Utils.ResponseText result = new Utils.ResponseText(); FrameworkCallsResult frameworkCallsResult; try { string fileWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_input_text_default.png"); PosInputTextDialog dialog = new PosInputTextDialog( pSourceWindow, DialogFlags.Modal, new System.Drawing.Size(800, 600), Resx.window_title_series_create_series, fileWindowIcon, Resx.global_acronym, pInitialValue, SettingsApp.RegexDocumentSeriesAcronym, true ); //Initialize EntryBoxValidationMultiLine EntryBoxValidationMultiLine entryBoxValidationMultiLine = new EntryBoxValidationMultiLine(pSourceWindow, Resx.global_preview); entryBoxValidationMultiLine.HeightRequest = 420; entryBoxValidationMultiLine.EntryMultiline.TextView.WrapMode = WrapMode.Word; entryBoxValidationMultiLine.EntryMultiline.TextView.Sensitive = false; //Start with Preview frameworkCallsResult = ProcessFinanceDocumentSeries.CreateDocumentFinanceYearSeriesTerminal(pDocumentFinanceYear, pTerminals, dialog.EntryBoxValidation.EntryValidation.Text, true); entryBoxValidationMultiLine.EntryMultiline.TextView.Buffer.Text = frameworkCallsResult.Output; //Pack Widgets dialog.VBoxContent.PackStart(entryBoxValidationMultiLine, true, true, 0); dialog.VBoxContent.ShowAll(); dialog.EntryBoxValidation.EntryValidation.Changed += delegate { if (dialog.EntryBoxValidation.EntryValidation.Validated) { frameworkCallsResult = ProcessFinanceDocumentSeries.CreateDocumentFinanceYearSeriesTerminal(pDocumentFinanceYear, pTerminals, dialog.EntryBoxValidation.EntryValidation.Text, true); entryBoxValidationMultiLine.EntryMultiline.TextView.Buffer.Text = frameworkCallsResult.Output; } }; ResponseType responseType = (ResponseType)dialog.Run(); result.ResponseType = responseType; if (responseType == ResponseType.Ok) { result.Text = dialog.Value; } dialog.Destroy(); } catch (Exception ex) { _log.Error(ex.Message, ex); } return(result); }
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //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); }