void TreeViewDocumentFinanceYears_RecordAfterInsert(object sender, EventArgs e) { try { //Get References to TreeViewDocumentFinanceSeries and TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceSeries treeViewDocumentFinanceSeries = ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceSeries"].Content as TreeViewDocumentFinanceSeries); //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceYearSerieTerminal treeViewDocumentFinanceYearSerieTerminal = ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceYearSerieTerminal")) ? ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceYearSerieTerminal"].Content as TreeViewDocumentFinanceYearSerieTerminal) : null; //Refresh TreeViews after Insert Record, and Hide old Series Refresh(); treeViewDocumentFinanceSeries.Refresh(); if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } //Apply Permissions ButtonCreateDocumentFinanceSeries treeViewDocumentFinanceSeries.ButtonCreateDocumentFinanceSeries.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCESERIES_MANAGE_SERIES"); //Request Create Series for all Type of Finance Documents ResponseType responseType = Utils.ShowMessageTouch( _sourceWindow, DialogFlags.Modal, new Size(600, 400), MessageType.Question, ButtonsType.YesNo, Resx.window_title_series_create_series, Resx.dialog_message_series_create_document_type_series ); if (responseType == ResponseType.Yes) { //Get Current Active FinanceYear FIN_DocumentFinanceYears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear(); bool result = TreeViewDocumentFinanceSeries.UICreateDocumentFinanceYearSeriesTerminal(_sourceWindow, currentDocumentFinanceYear); } } 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); }
private void buttonCreateDocumentFinanceSeries_Clicked(object sender, EventArgs e) { try { //Refresh Terminal XPO Object XPCollection xpcDocumentFinanceYears = new XPCollection(GlobalFramework.SessionXpo, typeof(FIN_DocumentFinanceYears)); xpcDocumentFinanceYears.Reload(); //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceYearSerieTerminal treeViewDocumentFinanceYearSerieTerminal = ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceYearSerieTerminal")) ? ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceYearSerieTerminal"].Content as TreeViewDocumentFinanceYearSerieTerminal) : null; //Internal Shared Action to Refresh Components var internalMethodRefreshComponents = new System.Action(() => { //Refresh Current Tree Model Refresh(); //Refresh TreeViewDocumentFinanceYearSerieTerminal (If Visible/Enabled) if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } }); //Get Current Active FinanceYear FIN_DocumentFinanceYears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear(); //If has Active FiscalYear, Show Warning Request to Close/Open if (currentDocumentFinanceYear != null) { //Call Create Series UI bool result = UICreateDocumentFinanceYearSeriesTerminal(_sourceWindow, currentDocumentFinanceYear); //Refresh Current Tree Model if (result) { //Refresh Current Tree Model Refresh(); //Refresh TreeViewDocumentFinanceYearSerieTerminal (If Visible/Enabled) if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } } } else { ResponseType responseType = Utils.ShowMessageTouch( _sourceWindow, DialogFlags.Modal, new Size(600, 400), MessageType.Error, ButtonsType.Close, Resx.window_title_series_create_series, Resx.dialog_message_series_create_document_type_series_miss_year ); //Disable Button, Extra protection for deleted year outside App _buttonCreateDocumentFinanceSeries.Sensitive = false; } } catch (Exception ex) { _log.Error(ex.Message, ex); } }