Exemplo n.º 1
0
        //XPO Mode: Prepare GenericTreeView to Use in InitObject : Constructor OverLoad 2
        public PosSelectRecordDialog(
            Window pSourceWindow,
            DialogFlags pDialogFlags,
            string pWindowsTitle,
            Size pSize,
            XPGuidObject pDefaultValue,
            CriteriaOperator pXpoCriteria,
            GenericTreeViewMode pGenericTreeViewMode,
            ActionAreaButtons pActionAreaButtons
            )
            : base(pSourceWindow, pDialogFlags)
        {
            try
            {
                //We can use InitObject Here because we dont have pColumnProperties, pDataSource and pDialogType
                //We must create instance with Activator to use Generic parameter constructors, and Send it to InitObject
                _genericTreeView = (T3)Activator.CreateInstance(typeof(T3), new object[] {
                    pSourceWindow,
                    pDefaultValue,
                    pXpoCriteria,
                    null,          //DialogType
                    pGenericTreeViewMode,
                    GenericTreeViewNavigatorMode.HideToolBar
                });

                //InitObject
                InitObject(pSourceWindow, pDialogFlags, pWindowsTitle, pSize, _genericTreeView, pGenericTreeViewMode, pActionAreaButtons);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Exemplo n.º 2
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //IGenericTreeViewMode Implementation

        //Object Initializer
        public override void InitObject(
            Window pSourceWindow,
            DataRow pDefaultValue,
            GenericTreeViewMode pGenericTreeViewMode,
            GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode,
            List <GenericTreeViewColumnProperty> pColumnProperties,
            DataTable pDataSource,
            Type pDialogType
            )
        {
            //Parameters
            _sourceWindow     = pSourceWindow;
            _columnProperties = pColumnProperties;
            _dataSource       = pDataSource;
            _dataSourceRow    = _dataSource.Rows[_currentRowIndex];
            _guidDefaultValue = default(Guid);
            _treeViewMode     = pGenericTreeViewMode;
            _navigatorMode    = pGenericTreeViewNavigatorMode;

            //Get First Custom Field Position ex OID
            _modelFirstCustomFieldIndex = (_treeViewMode == GenericTreeViewMode.Default) ? 1 : 2;

            //InitDataModel
            InitDataModel(_dataSource, _columnProperties, _treeViewMode);

            //ReIndex and count Rows
            _listStoreModel.Foreach(new TreeModelForeachFunc(TreeModelForEachTask));

            InitUI();

            //Always have a valid cursor, in first Record or in pDefaultValue
            SetInitialCursorPosition();
        }
Exemplo n.º 3
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //IGenericTreeViewMode Implementation

        //Object Initializer
        public override void InitObject(
            Window pSourceWindow,
            DataRow pDefaultValue,
            GenericTreeViewMode pGenericTreeViewMode,
            GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode,
            List <GenericTreeViewColumnProperty> pColumnProperties,
            DataTable pDataSource,
            Type pDialogType
            )
        {
            if (_debug)
            {
                _log.Debug("InitObject Begin(" + pSourceWindow + "," + pDataSource + "," + pColumnProperties + "," + pGenericTreeViewMode + "," + pGenericTreeViewNavigatorMode);
            }

            //Parameters
            _sourceWindow = pSourceWindow;
            _dataSource   = pDataSource;
            if (_dataSource.Rows.Count > 0)
            {
                _dataSourceRow = _dataSource.Rows[_currentRowIndex];
            }
            _guidDefaultValue = default(Guid);
            _dialogType       = pDialogType;
            _columnProperties = pColumnProperties;
            _treeViewMode     = pGenericTreeViewMode;
            _navigatorMode    = pGenericTreeViewNavigatorMode;

            //Get First Custom Field Position ex OID
            _modelFirstCustomFieldIndex = (_treeViewMode == GenericTreeViewMode.Default) ? 1 : 2;

            //InitDataModel
            InitDataModel(_dataSource, _columnProperties, _treeViewMode);

            //ReIndex and count Rows
            _listStoreModel.Foreach(new TreeModelForeachFunc(TreeModelForEachTask));

            //Initialize UI
            if (_debug)
            {
                _log.Debug("InitObject Before InitUI");
            }
            InitUI();

            //Update Navigator Permissions
            InitNavigatorPermissions();

            //Change Navigator
            _navigator.ButtonRefresh.Visible = false;
            _navigator.ButtonRefresh.Destroy();

            //Always have a valid cursor, in first Record or in pDefaultValue
            SetInitialCursorPosition();

            if (_debug)
            {
                _log.Debug("InitObject End");
            }
        }
Exemplo n.º 4
0
        public void InitObject(
            Window pSourceWindow,
            DialogFlags pDialogFlags,
            string pWindowsTitle,
            Size pSize,
            //Type pTreeViewType,
            //CriteriaOperator pCriteria,
            T3 pGenericTreeView,
            GenericTreeViewMode pGenericTreeViewMode,
            ActionAreaButtons pActionAreaButtons
            )
        {
            //Init private Vars from Parameters
            String windowTitle = pWindowsTitle;
            Size   windowSize  = pSize;// new Size(900, 700);

            _genericTreeView     = pGenericTreeView;
            _genericTreeViewMode = pGenericTreeViewMode;
            //_actionAreaButtons = (pActionAreaButtons != null) ? pActionAreaButtons : GetDefaultActionAreaButtons();
            _actionAreaButtons = pActionAreaButtons;

            //Init Local Vars
            String fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_select_record.png");
            Size   usefullAreaSize       = new Size(windowSize.Width - 14, windowSize.Height - 124);

            //Modify default genericTreeView properties
            _genericTreeView.SetSizeRequest(usefullAreaSize.Width, usefullAreaSize.Height);
            _genericTreeView.AllowRecordUpdate = false;
            //Format Columns FontSizes for Touch
            _genericTreeView.FormatColumnPropertiesForTouch();


            //Init Content
            Fixed fixedContent = new Fixed();

            fixedContent.Put(_genericTreeView, 0, 0);

            //Events
            this.KeyReleaseEvent += PosSelectRecordDialog_KeyReleaseEvent;

            //Capture EventHandlers from GenericTreeView
            _genericTreeView.CursorChanged   += _genericTreeView_CursorChanged;
            _genericTreeView.CheckBoxToggled += _genericTreeView_CheckBoxToggled;

            //Init Object
            this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, fixedContent, _genericTreeView.Navigator.TreeViewSearch, _actionAreaButtons);
        }
Exemplo n.º 5
0
        //XpoMode
        public TreeViewArticleType(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(fin_articletype);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            fin_articletype defaultValue = (pDefaultValue != null) ? pDefaultValue as fin_articletype : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogArticleType);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_code"), MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation"), Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("HavePrice")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_article_haveprice")
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_date_updated"), MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
            PGenericTreeViewMode = pGenericTreeViewMode;
        }
Exemplo n.º 6
0
        public void InitDashboard(
            Window pSourceWindow,
            GenericTreeViewMode pGenericTreeViewMode,
            GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode
            )
        {
            if (_debug)
            {
                _log.Debug("InitObject Begin(" + pSourceWindow + "," + pGenericTreeViewMode + "," + pGenericTreeViewNavigatorMode);
            }

            //Parameters
            _sourceWindow  = pSourceWindow;
            _dialogType    = null;
            _treeViewMode  = pGenericTreeViewMode;
            _navigatorMode = pGenericTreeViewNavigatorMode;

            //Get First Custom Field Position ex OID
            _modelFirstCustomFieldIndex = (_treeViewMode == GenericTreeViewMode.Default) ? 1 : 2;

            //Initialize UI
            //if (_debug) _log.Debug("InitObject Before InitUI");
            InitUiDashBoard();

            //Update Navigator Permissions
            InitNavigatorPermissions();

            //Init Protected Record Events
            InitProtectedRecordsEvents();

            //Always have a valid cursor, in first Record or in pDefaultValue
            //SetInitialCursorPosition();

            if (_debug)
            {
                _log.Debug("InitObject End");
            }
        }
Exemplo n.º 7
0
        //XpoMode
        public TreeViewConfigurationCountry(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(cfg_configurationcountry);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            cfg_configurationcountry defaultValue = (pDefaultValue != null) ? pDefaultValue as cfg_configurationcountry : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogConfigurationCountry);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_code"), MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation"), Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_date_updated"), MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            CriteriaOperator criteria = (ReferenceEquals(pXpoCriteria, null)) ? null : pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[1];
            sortProperty[0] = new SortProperty("Code", SortingDirection.Ascending);
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );

            //Protected Records
            ProtectedRecords.Add(new Guid("9655510a-ff58-461e-9719-c037058f10ed")); //AO
            ProtectedRecords.Add(new Guid("16fcd7f2-e885-48d8-9f8e-9d224cc36f32")); //MZ
            ProtectedRecords.Add(new Guid("e7e8c325-a0d4-4908-b148-508ed750676a")); //PT
            ProtectedRecords.Add(new Guid("4ad7cfde-f5d9-4ebd-b9e2-5144d74bd923")); //PT-AC
            ProtectedRecords.Add(new Guid("6ca6a849-7d81-4284-b948-44f87e49c47b")); //PT-MA
        }
Exemplo n.º 8
0
        //XpoMode
        public TreeViewConfigurationHolidays(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(cfg_configurationholidays);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            cfg_configurationholidays defaultValue = (pDefaultValue != null) ? pDefaultValue as cfg_configurationholidays : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogConfigurationHolidays);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_code"), MinWidth = 100
            });
            /* IN009137 - adding Year, Month and Day columns to Holidays window */
            columnProperties.Add(new GenericTreeViewColumnProperty("Day")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_day"), MinWidth = 40
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Month")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_month"), MinWidth = 40
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Year")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_year"), MinWidth = 60
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation"), Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_date_updated"), MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria = pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[1];
            sortProperty[0] = new SortProperty("Code", SortingDirection.Ascending);
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 9
0
        //XpoMode
        public TreeViewDocumentFinancePayment(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_DocumentFinancePayment);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_DocumentFinancePayment defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_DocumentFinancePayment : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Config
            int fontGenericTreeViewColumn = Convert.ToInt16(GlobalFramework.Settings["fontGenericTreeViewColumn"]);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("CreatedAt")
            {
                Title = Resx.global_document_date, MinWidth = 180
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("PaymentRefNo")
            {
                Title = Resx.global_document_number, MinWidth = 180
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("PaymentStatus")
            {
                Title = Resx.global_document_status, MinWidth = 50, MaxWidth = 50
            });
            //Shared Query
            string query = "SELECT {0} as Result FROM view_documentfinancepayment WHERE fpaOid = '{1}' GROUP BY fpaOid;";

            columnProperties.Add(new GenericTreeViewColumnProperty("EntityName")
            {
                Title        = Resx.global_entity, MinWidth = 260, MaxWidth = 260,
                Query        = string.Format(query, "cusName", "{0}"),
                DecryptValue = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("EntityFiscalNumber")
            {
                Title        = Resx.global_fiscal_number, MinWidth = 70, MaxWidth = 120,
                Query        = string.Format(query, "cusFiscalNumber", "{0}"),
                DecryptValue = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("PaymentAmount")
            {
                Title    = Resx.global_total,
                MinWidth = 100,
                //Alignment = 1.0F,
                FormatProvider = new FormatterDecimalCurrency(),
                //CellRenderer = new CellRendererText()
                //{
                //    FontDesc = new Pango.FontDescription() { Size = fontGenericTreeViewColumn },
                //    Alignment = Pango.Alignment.Right,
                //    Xalign = 1.0F
                //}
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria = pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[1];
            sortProperty[0] = new SortProperty("CreatedAt", SortingDirection.Ascending);
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 10
0
        //XpoMode
        public TreeViewConfigurationPlaceTerminal(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(POS_ConfigurationPlaceTerminal);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            POS_ConfigurationPlaceTerminal defaultValue = (pDefaultValue != null) ? pDefaultValue as POS_ConfigurationPlaceTerminal : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogConfigurationPlaceTerminal);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("HardwareId")
            {
                Title = Resx.global_hardware_id
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Events
            //this.RecordAfterUpdate += TreeViewConfigurationPlaceTerminal_RecordAfterUpdate;

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 11
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Override Super/Base Class Methods

        //Object Initializer
        public override void InitObject(
            Window pSourceWindow,
            XPGuidObject pXpoDefaultValue,
            GenericTreeViewMode pGenericTreeViewMode,
            GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode,
            List <GenericTreeViewColumnProperty> pColumnProperties,
            XPCollection pXpoCollection,
            Type pDialogType
            )
        {
            if (_debug)
            {
                _log.Debug("InitObject Begin(" + pSourceWindow + "," + pColumnProperties + "," + pXpoCollection + "," + pXpoDefaultValue + "," + pDialogType + "," + pGenericTreeViewMode + "," + pGenericTreeViewNavigatorMode);
            }

            //Parameters
            _sourceWindow = pSourceWindow;
            _dataSource   = pXpoCollection;

            if (_dataSource.Count > 0)
            {
                _dataSourceRow = pXpoDefaultValue;
            }
            _guidDefaultValue  = (_dataSourceRow != null) ? _dataSourceRow.Oid : default(Guid);
            _xpoGuidObjectType = pXpoCollection.ObjectType;
            _dialogType        = pDialogType;
            _columnProperties  = pColumnProperties;
            _treeViewMode      = pGenericTreeViewMode;
            _navigatorMode     = pGenericTreeViewNavigatorMode;

            //Get First Custom Field Position ex OID
            _modelFirstCustomFieldIndex = (_treeViewMode == GenericTreeViewMode.Default) ? 1 : 2;

            //Add default Sorting, if not defined in XPCollection - Use Ord, XPObject must have Ord, else it Throw Exception Intentionally, this way developer detect error
            if (pXpoCollection.Sorting.Count == 0)
            {
                try
                {
                    pXpoCollection.Sorting = FrameworkUtils.GetXPCollectionDefaultSortingCollection();
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    throw;
                }
            }

            //DropIdentityMap Removed, gives problems, Avoid used DropIdentityMap
            //_dataSource.Session.DropIdentityMap();
            //Force Reload Objects Without Cache
            _dataSource.Reload();

            //InitDataModel
            InitDataModel(_dataSource, _columnProperties, _treeViewMode);

            //ReIndex and count Rows
            _listStoreModel.Foreach(new TreeModelForeachFunc(TreeModelForEachTask));

            //Initialize UI
            if (_debug)
            {
                _log.Debug("InitObject Before InitUI");
            }
            InitUI();

            //Prepare CRUD Privileges
            //Require to use Object Name Without Prefixs (Remove Prefixs PFX_)
            string objectNameWithoutPrefix = _xpoGuidObjectType.UnderlyingSystemType.Name.Substring(4, _xpoGuidObjectType.UnderlyingSystemType.Name.Length - 4);
            string tokenAllowDelete        = string.Format("{0}_{1}", string.Format(SettingsApp.PrivilegesBackOfficeCRUDOperationPrefix, objectNameWithoutPrefix), "DELETE").ToUpper();
            string tokenAllowInsert        = string.Format("{0}_{1}", string.Format(SettingsApp.PrivilegesBackOfficeCRUDOperationPrefix, objectNameWithoutPrefix), "CREATE").ToUpper();
            string tokenAllowUpdate        = string.Format("{0}_{1}", string.Format(SettingsApp.PrivilegesBackOfficeCRUDOperationPrefix, objectNameWithoutPrefix), "EDIT").ToUpper();
            string tokenAllowView          = string.Format("{0}_{1}", string.Format(SettingsApp.PrivilegesBackOfficeCRUDOperationPrefix, objectNameWithoutPrefix), "VIEW").ToUpper();

            // Help to Debug some Kind of Types Privileges
            //if (this.GetType().Equals(typeof(TreeViewConfigurationInputReader)))
            //{
            //    _log.Debug($"BREAK {typeof(TreeViewConfigurationInputReader)}");
            //}

            //Assign CRUD permissions to private members, Overriding Defaults
            if (GlobalFramework.LoggedUserPermissions != null)
            {
                _allowRecordDelete = FrameworkUtils.HasPermissionTo(tokenAllowDelete);
                _allowRecordInsert = FrameworkUtils.HasPermissionTo(tokenAllowInsert);
                _allowRecordUpdate = FrameworkUtils.HasPermissionTo(tokenAllowUpdate);
                _allowRecordView   = FrameworkUtils.HasPermissionTo(tokenAllowView);
            }

            //Update Navigator Permissions
            InitNavigatorPermissions();

            //Init Protected Record Events
            InitProtectedRecordsEvents();

            //Always have a valid cursor, in first Record or in pDefaultValue
            SetInitialCursorPosition();

            if (_debug)
            {
                _log.Debug("InitObject End");
            }
        }
Exemplo n.º 12
0
        //XpoMode
        public TreeViewCustomer(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(ERP_Customer);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            ERP_Customer defaultValue = (pDefaultValue != null) ? pDefaultValue as ERP_Customer : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogCustomer);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Name")
            {
                Title = Resx.global_name, MinWidth = 200, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("FiscalNumber")
            {
                Title = Resx.global_fiscal_number, MinWidth = 150
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("CardNumber")
            {
                Title = Resx.global_card_number, MinWidth = 150
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Custom Events
            //WIP: this.CursorChanged += TreeViewCustomer_CursorChanged;

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );

            //Protected Records
            ProtectedRecords.Add(SettingsApp.XpoOidDocumentFinanceMasterFinalConsumerEntity);//FinalConsumerEntity
        }
Exemplo n.º 13
0
        //XpoMode
        public TreeViewDocumentOrderTicket(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(fin_documentorderticket);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            fin_documentorderticket defaultValue = (pDefaultValue != null) ? pDefaultValue as fin_documentorderticket : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("TicketId")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ticket_number"), MinWidth = 50
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("DateStart")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_date"), MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedBy")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_user_name"), ChildName = "Name", MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedWhere")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_terminal_name"), ChildName = "Designation", MinWidth = 100
            });

            //Sort Order
            SortProperty[] sortProperty = new SortProperty[1];
            sortProperty[0] = new SortProperty("TicketId", SortingDirection.Ascending);

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 14
0
        //DataTable Mode
        public TreeViewTerminalSeries(Window pSourceWindow, DataRow pDefaultValue, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            DataRow defaultValue = (pDefaultValue != null) ? pDefaultValue : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            /*00*/
            columnProperties.Add(new GenericTreeViewColumnProperty("Oid")
            {
                Type = typeof(Guid), Visible = false
            });
            /*01*/
            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Type = typeof(UInt32), Title = Resx.global_record_code
            });
            /*02*/
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Type = typeof(String), Title = Resx.global_designation, Expand = true
            });
            /*03*/
            columnProperties.Add(new GenericTreeViewColumnProperty("HardwareId")
            {
                Type = typeof(String), Title = Resx.global_hardware_id, MinWidth = 200
            });

            //init DataTable
            DataTable dataTable = GetDataTable(columnProperties);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                  //Pass parameter
                pDefaultValue,                  //Pass parameter
                pGenericTreeViewMode,           //Pass parameter
                pGenericTreeViewNavigatorMode,  //Pass parameter
                columnProperties,               //Created Here
                dataTable,                      //Created Here
                typeDialogClass                 //Created Here
                );
        }
Exemplo n.º 15
0
        //XpoMode
        public TreeViewArticleStock(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_ArticleStock);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_ArticleStock defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_ArticleStock : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Config
            int fontGenericTreeViewColumn = Convert.ToInt16(GlobalFramework.Settings["fontGenericTreeViewColumn"]);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Quantity")
            {
                Title = Resx.global_stock_movement, MinWidth = 100, FormatProvider = new FormatterStockMovement(),
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Date")
            {
                Title = Resx.global_date, MinWidth = 100, FormatProvider = new FormatterDate(),
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Customer")
            {
                Title = Resx.global_entity, ChildName = "Name", MinWidth = 125
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("DocumentNumber")
            {
                Title = Resx.global_document_number, MinWidth = 125
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Article")
            {
                Title = Resx.global_article, ChildName = "Designation", MinWidth = 125
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Quantity")
            {
                Title    = Resx.global_quantity,
                MinWidth = 100,
                //Alignment = 1.0F,
                FormatProvider = new FormatterDecimal(),
                //CellRenderer = new CellRendererText()
                //{
                //    FontDesc = new Pango.FontDescription() { Size = fontGenericTreeViewColumn },
                //    Alignment = Pango.Alignment.Right,
                //    Xalign = 1.0F
                //}
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria = pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[2];
            sortProperty[0] = new SortProperty("CreatedAt", SortingDirection.Ascending);
            sortProperty[1] = new SortProperty("Ord", SortingDirection.Ascending);
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
        //XpoMode
        public TreeViewDocumentFinancePayment(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(fin_documentfinancepayment);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            fin_documentfinancepayment defaultValue = (pDefaultValue != null) ? pDefaultValue as fin_documentfinancepayment : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Config
            int fontGenericTreeViewColumn = Convert.ToInt16(GlobalFramework.Settings["fontGenericTreeViewColumn"]);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("CreatedAt")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_document_date"), MinWidth = 140
            });                                                                                                                                                                                                                                 /* IN009067 */
            columnProperties.Add(new GenericTreeViewColumnProperty("PaymentRefNo")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_document_number"), MinWidth = 120
            });                                                                                                                                                                                                                                      /* IN009067 */
            columnProperties.Add(new GenericTreeViewColumnProperty("PaymentStatus")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_document_status"), MinWidth = 50, MaxWidth = 50
            });
            //Shared Query
            /* IN009075 - removing call to view */
            // string query = "SELECT {0} as Result FROM view_documentfinancepayment WHERE fpaOid = '{1}' GROUP BY fpaOid,{0};";
            string queryForCustomerDetails = "SELECT {0} FROM erp_customer AS Customer LEFT JOIN fin_documentfinancepayment AS Payment ON (Payment.EntityOid = Customer.Oid) WHERE Payment.Oid = '{1}';";

            columnProperties.Add(new GenericTreeViewColumnProperty("EntityName")
            {
                Title        = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_entity"),
                MinWidth     = 260,
                MaxWidth     = 260,
                Query        = string.Format(queryForCustomerDetails, "Name", "{0}"), /* IN009075 */
                DecryptValue = true
            });
            /* IN009067 */
            columnProperties.Add(new GenericTreeViewColumnProperty("EntityFiscalNumber")
            {
                Title        = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_fiscal_number"),
                MinWidth     = 100,
                Query        = string.Format(queryForCustomerDetails, "FiscalNumber", "{0}"), /* IN009075 */
                DecryptValue = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("PaymentAmount")
            {
                Title    = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total"),
                MinWidth = 100,
                //Alignment = 1.0F,
                FormatProvider = new FormatterDecimalCurrency(),
                /* IN009067 */
                CellRenderer = new CellRendererText()
                {
                    FontDesc = new Pango.FontDescription()
                    {
                        Size = fontGenericTreeViewColumn
                    },
                    Alignment = Pango.Alignment.Right,
                    Xalign    = 1.0F
                }
            });

            /* IN009067 - TODO */
            string relatedDocumentsQuery = logicpos.DataLayer.GenerateRelatedDocumentsQuery(true);

            columnProperties.Add(new GenericTreeViewColumnProperty("RelatedDocuments")
            {
                Query    = relatedDocumentsQuery,
                Title    = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_document_finance_column_related_doc"),
                MinWidth = 100
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria = pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[1];
            /* IN009067 - setting up descending sort */
            sortProperty[0] = new SortProperty("CreatedAt", SortingDirection.Descending);
            //Configure Criteria/XPCollection/Model
            //New IN009223 IN009227
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty)
            {
                TopReturnedObjects = SettingsApp.PaginationRowsPerPage
            };

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 17
0
        //XpoMode
        public TreeViewDocumentFinanceType(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(fin_documentfinancetype);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            fin_documentfinancetype defaultValue = (pDefaultValue != null) ? pDefaultValue as fin_documentfinancetype : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogDocumentFinanceType);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_code"), MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation"), Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Acronym")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_acronym")
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_date_updated"), MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            CriteriaOperator criteria = (ReferenceEquals(pXpoCriteria, null)) ? null : pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[1];
            sortProperty[0] = new SortProperty("Designation", SortingDirection.Ascending);
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 18
0
        //XpoMode
        public TreeViewArticle(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_Article);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_Article defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_Article : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogArticle);

            //Config
            int fontGenericTreeViewColumn = Convert.ToInt16(GlobalFramework.Settings["fontGenericTreeViewColumn"]);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            //To Test XPGuidObject InitialValue (InitialValue = xArticleFamily) : ArticleFamily xArticleFamily = (ArticleFamily)FrameworkUtils.GetXPGuidObjectFromSession(GlobalFramework.SessionXpoBackoffice, typeof(ArticleFamily), new Guid("471d8c1e-45c1-4dbe-8526-349c20bd53ef"));
            columnProperties.Add(new GenericTreeViewColumnProperty("Family")
            {
                Title = Resx.global_article_family, ChildName = "Designation"
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("SubFamily")
            {
                Title = Resx.global_article_subfamily, ChildName = "Designation"
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Type")
            {
                Title = Resx.global_article_type, ChildName = "Designation"
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("TotalStock")
            {
                Query    = "SELECT SUM(Quantity) as Result FROM fin_articlestock WHERE Article = '{0}' AND (Disabled = 0 OR Disabled is NULL) GROUP BY Article;",
                Title    = Resx.global_total_stock,
                MinWidth = 100,
                //Alignment = 1.0F,
                FormatProvider = new FormatterDecimal(),
                //CellRenderer = new CellRendererText()
                //{
                //    FontDesc = new Pango.FontDescription() { Size = fontGenericTreeViewColumn },
                //    Alignment = Pango.Alignment.Right,
                //    Xalign = 1.0F
                //}
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //Default Criteria with XpoOidUndefinedRecord
            CriteriaOperator criteria = pXpoCriteria;

            // Override Criteria adding XpoOidHiddenRecordsFilter
            criteria = CriteriaOperator.Parse($"({pXpoCriteria.ToString()}) OR (Oid NOT LIKE '{SettingsApp.XpoOidHiddenRecordsFilter}')");
            //Custom Criteria hidding all Hidden Oids
            //CriteriaOperator criteria = CriteriaOperator.Parse($"(Oid = '{SettingsApp.XpoOidUndefinedRecord}' OR Oid NOT LIKE '{SettingsApp.XpoOidHiddenRecordsFilter}')");
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 19
0
        public DashBoard(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Config
            int fontGenericTreeViewColumn = Convert.ToInt16(GlobalFramework.Settings["fontGenericTreeViewColumn"]);
            var predicate   = (Predicate <dynamic>)((dynamic x) => x.ID == "PosBaseWindow");
            var themeWindow = GlobalApp.Theme.Theme.Frontoffice.Window.Find(predicate);


            Color screenBackgroundColor = FrameworkUtils.StringToColor(themeWindow.Globals.ScreenBackgroundColor);
            Color white = System.Drawing.Color.White;
            Color black = System.Drawing.Color.Black;


            //_log.Debug("Theme Background: " + eventBackGround);
            //Shared error Message
            string errorMessage = "Node: <Window ID=\"PosBaseWindow\">";

            Fixed fix   = new Fixed();
            HBox  hbox  = new HBox();
            Frame frame = new Frame();

            VBox vbox  = new VBox(false, 2);
            VBox vbox2 = new VBox(true, 0);
            VBox vbox3 = new VBox(false, 5);

            DateTime datenow = new DateTime();

            //Icons dos botões do dashboard
            String _fileFiscalYearIcon   = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_configurations.png");
            String _fileInsertFiscalYear = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_fiscal_year.png");
            String _fileInsertIcon       = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_printer.png");
            String _fileTerminalsIcon    = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_terminals.png");

            String _fileArticlesIcon    = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_articles.png");
            String _fileCostumersIcon   = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_costumers.png");
            String _fileEmployeesIcon   = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_employees.png");
            String _fileOtherTablesIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_other_tables.png");

            String _fileDocumentsIcon      = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_documents.png");
            String _fileNewDocumentIcon    = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_documents_new.png");
            String _filePayedDocumentsIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_documents_new.png");
            String _fileInsertMerchIcon    = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_documents_merch.png");

            String _fileReportsMenuIcon    = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_reports.png");
            String _fileReportsTotalIcon   = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_reports_sales_report.png");
            String _fileReportsClientsIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_reports_sales_client.png");
            String _fileReportsDayIcon     = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\BackOffice\icon_reports_sales_day.png");

            //Tamanho dos Icons e da Font do Texto dos botões
            Size   sizeIcon = new Size(35, 35);
            string _fontBaseDialogButton = "8";

            //uint borderWidth = 5;
            //Cria o evento por trás da dashboard, tudo será carregado para aqui
            _eventboxDashboard = new EventBox();
            //_eventboxDashboard.ModifyBg(StateType.Normal, Utils.ColorToGdkColor(screenBackgroundColor));
            _eventboxDashboard.WidthRequest  = GlobalApp.boScreenSize.Width;
            _eventboxDashboard.HeightRequest = GlobalApp.boScreenSize.Height;
            Alignment _alignmentWindow = new Alignment(0.0f, 0.0f, 0.0f, 0.0f);

            _alignmentWindow.Add(_eventboxDashboard);
            Add(_alignmentWindow);
            try
            {
                //Imagem carregada aqui para o dashboard
                string fileImageBack        = FrameworkUtils.OSSlash(string.Format("{0}Default/Backgrounds/Windows/LogicPOS_WorkFlow_{1}.png", GlobalFramework.Path["themes"], GlobalFramework.Settings["customCultureResourceDefinition"]));
                System.Drawing.Image pImage = System.Drawing.Image.FromFile(fileImageBack);
                Gdk.Pixbuf           pixbuf = Utils.ImageToPixbuf(pImage);
                _eventboxDashboard.Style = Utils.GetImageBackgroundDashboard(pixbuf);
                //Buttons Configuração
                botao1 = new TouchButtonIconWithText("BACKOFFICE_MAN_CONFIGURATIONPLACETERMINAL_MENU", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_edit_ConfigurationPlaceTerminal_tab1_label"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileTerminalsIcon, sizeIcon, 105, 70);
                botao2 = new TouchButtonIconWithText("BACKOFFICE_MAN_CONFIGURATIONPREFERENCEPARAMETER_VIEW", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_application_setup"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileFiscalYearIcon, sizeIcon, 105, 70);
                botao3 = new TouchButtonIconWithText("BACKOFFICE_MAN_DOCUMENTFINANCEYEARS_CREATE", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_years_short"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileInsertFiscalYear, sizeIcon, 105, 70);
                botao4 = new TouchButtonIconWithText("BACKOFFICE_MAN_CONFIGURATIONPRINTERS_VIEW", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_printers"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileInsertIcon, sizeIcon, 105, 70);

                //Buttons Tabelas
                botao5 = new TouchButtonIconWithText("BACKOFFICE_MAN_ARTICLE_VIEW", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_articles"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileArticlesIcon, sizeIcon, 105, 70);
                botao6 = new TouchButtonIconWithText("BACKOFFICE_MAN_CUSTOMER_VIEW", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customers"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileCostumersIcon, sizeIcon, 105, 70);
                botao7 = new TouchButtonIconWithText("BACKOFFICE_MAN_USERDETAIL_VIEW", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_users"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileEmployeesIcon, sizeIcon, 105, 70);
                botao8 = new TouchButtonIconWithText("BACKOFFICE_MAN_CONFIGURATIONPLACETABLE_VIEW", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_other_tables"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileOtherTablesIcon, sizeIcon, 105, 70);

                //Buttons Documentos
                botao9  = new TouchButtonIconWithText("BACKOFFICE_MAN_DOCUMENTSSHOW_MENU", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileNewDocumentIcon, sizeIcon, 105, 70);
                botao10 = new TouchButtonIconWithText("BACKOFFICE_MAN_DOCUMENTSNEW_MENU", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_new_document"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileDocumentsIcon, sizeIcon, 105, 70);
                botao11 = new TouchButtonIconWithText("BACKOFFICE_MAN_DOCUMENTSPAYMENTS_MENU", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_payments"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _filePayedDocumentsIcon, sizeIcon, 105, 70);
                botao12 = new TouchButtonIconWithText("STOCK_MERCHANDISE_ENTRY_ACCESS", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentticket_type_title_cs_short"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileInsertMerchIcon, sizeIcon, 105, 70);

                //Buttons Relatórios
                botao13 = new TouchButtonIconWithText("REPORT_ACCESS", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_reports"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileReportsMenuIcon, sizeIcon, 105, 70);
                botao14 = new TouchButtonIconWithText("REPORT_COMPANY_BILLING", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "report_company_billing_short"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileReportsTotalIcon, sizeIcon, 105, 70);
                botao15 = new TouchButtonIconWithText("REPORT_CUSTOMER_BALANCE_DETAILS", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "report_customer_balance_details_short"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileReportsClientsIcon, sizeIcon, 105, 70);
                botao16 = new TouchButtonIconWithText("REPORT_SALES_DETAIL_PER_DATE", _colorBaseDialogDefaultButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "report_sales_per_date"), _fontBaseDialogButton, _colorBaseDialogDefaultButtonFont, _fileReportsDayIcon, sizeIcon, 105, 70);

                PosReportsDialog reportsClicked = new PosReportsDialog();

                //Permissões dos botões
                botao1.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_CONFIGURATIONPLACETERMINAL_MENU");
                botao2.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_CONFIGURATIONPREFERENCEPARAMETER_VIEW");
                botao3.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCEYEARS_CREATE");
                botao4.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_CONFIGURATIONPRINTERS_VIEW");

                botao5.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_ARTICLE_VIEW");
                botao6.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_CUSTOMER_VIEW");
                botao7.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_USERDETAIL_VIEW");
                botao8.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_CONFIGURATIONPLACETABLE_VIEW");

                botao9.Sensitive  = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCETYPE_MENU");
                botao10.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCETYPE_CREATE");
                botao11.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCEYEARS_VIEW");
                botao12.Sensitive = FrameworkUtils.HasPermissionTo("STOCK_MERCHANDISE_ENTRY_ACCESS");

                //Este fica comentado, porque o próprio menu dos reports tem controlo de previlégios
                //botao13.Sensitive = FrameworkUtils.HasPermissionTo("REPORT_ACCESS");
                botao14.Sensitive = FrameworkUtils.HasPermissionTo("REPORT_COMPANY_BILLING");
                botao15.Sensitive = FrameworkUtils.HasPermissionTo("REPORT_CUSTOMER_BALANCE_DETAILS");
                botao16.Sensitive = FrameworkUtils.HasPermissionTo("REPORT_SALES_DETAIL_PER_DATE");


                //Actions Configurações
                botao1.Clicked += delegate { botao1.Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceTerminal>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao1, null); };
                botao2.Clicked += delegate { botao2.Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPreferenceParameter>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao2, null); };
                botao3.Clicked += delegate { botao3.Content = Utils.GetGenericTreeViewXPO <TreeViewDocumentFinanceYears>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao3, null); };
                botao4.Clicked += delegate { botao4.Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPrinters>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao4, null); };

                //Actions Tabelas
                botao5.Clicked += delegate { botao5.Content = Utils.GetGenericTreeViewXPO <TreeViewArticle>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao5, null); };
                botao6.Clicked += delegate { botao6.Content = Utils.GetGenericTreeViewXPO <TreeViewCustomer>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao6, null); };
                botao7.Clicked += delegate { botao7.Content = Utils.GetGenericTreeViewXPO <TreeViewUser>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao7, null); };
                botao8.Clicked += delegate { botao8.Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceTable>(pSourceWindow); GlobalApp.WindowBackOffice._dashboardButton_Clicked(botao8, null); };

                //Actions Documents
                botao9.Clicked  += delegate { Utils.startDocumentsMenuFromBackOffice(pSourceWindow, 0); };
                botao10.Clicked += delegate { Utils.startNewDocumentFromBackOffice(pSourceWindow); };
                botao11.Clicked += delegate { Utils.startDocumentsMenuFromBackOffice(pSourceWindow, 3); };
                botao12.Clicked += delegate { Utils.startDocumentsMenuFromBackOffice(pSourceWindow, 6); };

                //Actions Reports
                botao13.Clicked += delegate { Utils.startReportsMenuFromBackOffice(pSourceWindow); };
                botao14.Clicked += delegate { reportsClicked.PrintReportRouter
                                                  (botao14, null); };
                botao15.Clicked += delegate { reportsClicked.PrintReportRouter(botao15, null); };
                botao16.Clicked += delegate { reportsClicked.PrintReportRouter(botao16, null); };

                //Posição dos botões na dashboard
                fix.Put(botao1, 55, 62);
                fix.Put(botao2, 55, 155);
                fix.Put(botao3, 55, 250);
                fix.Put(botao4, 55, 345);

                fix.Put(botao5, 245, 62);
                fix.Put(botao6, 245, 155);
                fix.Put(botao7, 245, 250);
                fix.Put(botao8, 245, 345);

                fix.Put(botao9, 440, 62);
                fix.Put(botao10, 440, 155);
                fix.Put(botao11, 440, 250);
                fix.Put(botao12, 440, 345);

                fix.Put(botao13, 635, 62);
                fix.Put(botao14, 635, 155);
                fix.Put(botao15, 635, 250);
                fix.Put(botao16, 635, 345);

                string currency = "Money";
                try
                {
                    string sqlCurrency = "SELECT Value FROM cfg_configurationpreferenceparameter where Token = 'SYSTEM_CURRENCY'";
                    currency = GlobalFramework.SessionXpo.ExecuteScalar(sqlCurrency).ToString();
                }
                catch
                {
                    currency = SettingsApp.SaftCurrencyCode;
                }

                decimal   dailyTotal   = 0;
                decimal   MonthlyTotal = 0;
                decimal   annualTotal  = 0;
                ArrayList values       = new ArrayList();
                values.Add(DateTime.Now.Year.ToString());
                try
                {
                    SortingCollection sortCollection = new SortingCollection();
                    sortCollection.Add(new SortProperty("Date", SortingDirection.Ascending));
                    CriteriaOperator criteria = CriteriaOperator.Parse(string.Format("(Disabled = 0 OR Disabled IS NULL AND (DocumentType.Oid = '{0}' OR DocumentType.Oid = '{1}' OR DocumentType.Oid = '{2}' OR DocumentType.Oid = '{3}') AND DocumentStatusReason != 'A')", invoiceOid, invoiceAndPaymentOid, simpleInvoiceOid, creditNoteOid));
                    collectionDocuments = GlobalFramework.SessionXpo.GetObjects(GlobalFramework.SessionXpo.GetClassInfo(typeof(fin_documentfinancemaster)), criteria, sortCollection, int.MaxValue, false, true);

                    datenow = DateTime.Now;

                    foreach (fin_documentfinancemaster item in collectionDocuments)
                    {
                        //Faturação por Dia
                        if (item.Date.Day == datenow.Day && item.Date.Month == datenow.Month && item.Date.Year == datenow.Year)
                        {
                            if (item.DocumentType.Oid.ToString() == creditNoteOid && item.DocumentStatusStatus != "A")
                            {
                                dailyTotal -= Convert.ToDecimal(item.TotalFinal);
                            }
                            else if (item.DocumentStatusStatus != "A" && (item.DocumentType.Oid.ToString() == invoiceOid || item.DocumentType.Oid.ToString() == invoiceAndPaymentOid || item.DocumentType.Oid.ToString() == simpleInvoiceOid))
                            {
                                dailyTotal += Convert.ToDecimal(item.TotalFinal);
                            }
                        }
                        //Faturação por Mês
                        if (item.Date.Month == datenow.Month && item.Date.Year == datenow.Year)
                        {
                            if (item.DocumentType.Oid.ToString() == creditNoteOid && item.DocumentStatusStatus != "A")
                            {
                                MonthlyTotal -= Convert.ToDecimal(item.TotalFinal);
                            }
                            else if (item.DocumentStatusStatus != "A" && (item.DocumentType.Oid.ToString() == invoiceOid || item.DocumentType.Oid.ToString() == invoiceAndPaymentOid || item.DocumentType.Oid.ToString() == simpleInvoiceOid))
                            {
                                MonthlyTotal += Convert.ToDecimal(item.TotalFinal);
                            }
                        }
                        //Faturação por Ano
                        if (item.Date.Year == datenow.Year)
                        {
                            if (item.DocumentType.Oid.ToString() == creditNoteOid && item.DocumentStatusStatus != "A")
                            {
                                annualTotal -= Convert.ToDecimal(item.TotalFinal);
                            }
                            else if (item.DocumentStatusStatus != "A" && (item.DocumentType.Oid.ToString() == invoiceOid || item.DocumentType.Oid.ToString() == invoiceAndPaymentOid || item.DocumentType.Oid.ToString() == simpleInvoiceOid))
                            {
                                annualTotal += Convert.ToDecimal(item.TotalFinal);
                            }
                        }
                        //grava anos que existe faturação
                        if (!values.Contains(item.Date.Year.ToString()))
                        {
                            values.Add(item.Date.Year.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }

                label            = new Label();
                frame.ShadowType = (ShadowType)0;

                label.Text = string.Format("{0} {3}\n\n{1} {3}\n\n{2} {3}",
                                           Convert.ToInt64(Math.Round(dailyTotal, 0)).ToString(),
                                           Convert.ToInt64(Math.Round(MonthlyTotal, 0)).ToString(),
                                           Convert.ToInt64(Math.Round(annualTotal, 0)).ToString(),
                                           currency.ToString());

                label.ModifyFont(FontDescription.FromString("Trebuchet MS 16"));
                label.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(white));
                label.Justify = Justification.Right;
                frame.Add(label);
                hbox.PackStart(frame, false, false, 0);
                vbox.PackStart(hbox, false, false, 0);
                fix.Put(vbox, 628, 515);

                //COMBO BOX selecionar os anos do gráfico
                int      w        = 1;
                string[] getYears = new string[values.Count];
                getYears[0] = (string)values[0];
                for (int i = values.Count - 1; i > 0; i--)
                {
                    getYears[i] = (string)values[w];
                    w++;
                }
                //w = 1;
                selAno = new ComboBox(getYears);
                selAno.ModifyFg(StateType.Selected, Utils.ColorToGdkColor(black));

                TreeIter iter;
                selAno.Model.GetIterFirst(out iter);
                do
                {
                    GLib.Value thisRow = new GLib.Value();
                    selAno.Model.GetValue(iter, 0, ref thisRow);
                    if ((thisRow.Val as string).Equals(getYears[0]))
                    {
                        selAno.SetActiveIter(iter);
                        break;
                    }
                } while (selAno.Model.IterNext(ref iter));
                selAno.Changed += delegate
                {
                    annualTotal = 0;
                    foreach (fin_documentfinancemaster item in collectionDocuments)
                    {
                        if (item.Date.Year.ToString() == selAno.ActiveText.ToString())
                        {
                            if (item.DocumentType.Oid.ToString() == creditNoteOid && item.DocumentStatusStatus != "A")
                            {
                                annualTotal -= Convert.ToDecimal(item.TotalFinal);
                            }
                            else if (item.DocumentStatusStatus != "A" && (item.DocumentType.Oid.ToString() == invoiceOid || item.DocumentType.Oid.ToString() == invoiceAndPaymentOid || item.DocumentType.Oid.ToString() == simpleInvoiceOid))
                            {
                                annualTotal += Convert.ToDecimal(item.TotalFinal);
                            }
                        }
                    }
                    label.Text = string.Format("{0} {3}\n\n{1} {3}\n\n{2} {3}",
                                               Convert.ToInt64(Math.Round(dailyTotal, 0)).ToString(),
                                               Convert.ToInt64(Math.Round(MonthlyTotal, 0)).ToString(),
                                               Convert.ToInt64(Math.Round(annualTotal, 0)).ToString(),
                                               currency.ToString());

                    label.ModifyFont(FontDescription.FromString("Trebuchet MS 16"));
                    label.ModifyFg(StateType.Normal, Utils.ColorToGdkColor(white));
                    label.Justify = Justification.Right;
                    frame.Add(label);

                    hbox.PackStart(frame, false, false, 0);
                    vbox.PackStart(hbox, false, false, 0);
                    string selectedDate = string.Format("01/01/{0}", (selAno.ActiveText.ToString()));
                    fix.Put(vbox, 640, 515);
                    fix.Put(drawSalesGraphic(DateTime.Parse(selectedDate), true), 55, 485);
                };
                if (Utils.IsLinux)
                {
                    fix.Put(selAno, 220, 650);
                }
                else
                {
                    fix.Put(selAno, 220, 665);
                }

                //GRÁFICO
                fix.Put(drawSalesGraphic(datenow, false), 55, 485);

                //Adiciona tudo ao evento principal
                _eventboxDashboard.ModifyBg(StateType.Normal, new Gdk.Color(0, 0, 0));
                _eventboxDashboard.Add(fix);
                fix.ModifyBg(StateType.Normal, new Gdk.Color(0, 0, 0));
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                Utils.ShowMessageTouchErrorRenderTheme(pSourceWindow, string.Format("{1}{0}{0}{2}", Environment.NewLine, errorMessage, ex.Message));
            }
        }
Exemplo n.º 20
0
        //XpoMode
        public TreeViewUser(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            Type xpoGuidObjectType = typeof(SYS_UserDetail);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            SYS_UserDetail defaultValue = (pDefaultValue != null) ? pDefaultValue as SYS_UserDetail : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogUserDetail);

            // XPO column properties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Name")
            {
                Title = Resx.global_users, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Profile")
            {
                Title = Resx.global_profile, ChildName = "Designation", MinWidth = 160
            });
            //columnProperties.Add(new GenericTreeViewColumnProperty("MobilePhone") { Title = Resx.global_mobile_phone });
            columnProperties.Add(new GenericTreeViewColumnProperty("FiscalNumber")
            {
                Title = Resx.global_fiscal_number, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //configure criteria/xpcollection/model
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );

            //Protection to LogOff User
            this.RecordBeforeDelete += TreeView_RecordBeforeDelete;
        }
Exemplo n.º 21
0
        //XpoMode
        public TreeViewTemplate(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(Template);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            Template defaultValue = (pDefaultValue != null) ? pDefaultValue as Template : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            //columnProperties.Add(new GenericTreeViewColumnProperty("Disabled") { Title = Resx.global_record_disabled });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria = pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[1];
            sortProperty[0] = new SortProperty("Designation", SortingDirection.Ascending);
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );

            //Protected Records
            //ProtectedRecords.Add(GUID);

            /*
             * //Events Sample
             * this.RecordBeforeDelete += TreeView_RecordBeforeDelete;
             * this.RecordBeforeUpdate += TreeView_RecordBeforeUpdate;
             */
        }
        //XpoMode
        public TreeViewConfigurationPreferenceParameter(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(cfg_configurationpreferenceparameter);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            cfg_configurationpreferenceparameter defaultValue = (pDefaultValue != null) ? pDefaultValue as cfg_configurationpreferenceparameter : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogConfigurationPreferenceParameter);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("ResourceString")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation"), Expand = true, ResourceString = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Value")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_value"), Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_date_updated"), MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model : pXpoCriteria Parameter sent by BO
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            this.RecordAfterUpdate += TreeViewConfigurationPreferenceParameter_RecordAfterUpdate;

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
        //XpoMode
        public TreeViewDocumentFinanceSeries(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Assign Parameters to Members
            _sourceWindow = pSourceWindow;

            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_DocumentFinanceSeries);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_DocumentFinanceSeries defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_DocumentFinanceSeries : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogDocumentFinanceSeries);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("FiscalYear")
            {
                Title = Resx.global_fiscal_year, ChildName = "Designation", MinWidth = 160
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("DocumentType")
            {
                Title = Resx.global_documentfinanceseries_documenttype, ChildName = "Designation", Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model : Use Default Filter
            CriteriaOperator criteria = (ReferenceEquals(pXpoCriteria, null))
                                        // Generate Default Criteria
                ? CriteriaOperator.Parse("(Disabled = 0 OR Disabled IS NULL)")
                                        // Add to Parameter Criteria
                : CriteriaOperator.Parse(string.Format("(Disabled = 0 OR Disabled IS NULL) AND ({0})", pXpoCriteria.ToString()))
            ;
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );

            //Add Extra Button to Navigator
            _buttonCreateDocumentFinanceSeries = Navigator.GetNewButton("touchButtonCreateDocumentFinanceSeries_DialogActionArea", Resx.pos_button_create_series, @"Icons/icon_pos_nav_new.png");
            //_buttonCreateDocumentFinanceSeries.WidthRequest = 110;
            //Check if Has an Active Year Open before apply Permissions
            FIN_DocumentFinanceYears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear();

            //Apply Permissions
            _buttonCreateDocumentFinanceSeries.Sensitive = (currentDocumentFinanceYear != null && FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCESERIES_MANAGE_SERIES"));
            //Event
            _buttonCreateDocumentFinanceSeries.Clicked += buttonCreateDocumentFinanceSeries_Clicked;
            //Add to Extra Slot
            Navigator.ExtraSlot.PackStart(_buttonCreateDocumentFinanceSeries, false, false, 0);
        }
Exemplo n.º 24
0
        //XpoMode
        public TreeViewDocumentFinanceMaster(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_DocumentFinanceMaster);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_DocumentFinanceMaster defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_DocumentFinanceMaster : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Config
            int fontGenericTreeViewColumn = Convert.ToInt16(GlobalFramework.Settings["fontGenericTreeViewColumn"]);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Date")
            {
                Title = Resx.global_document_date, MinWidth = 140
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("DocumentNumber")
            {
                Title = Resx.global_document_number, MinWidth = 180
            });
            //#if (DEBUG)
            columnProperties.Add(new GenericTreeViewColumnProperty("DocumentStatusStatus")
            {
                Title = Resx.global_document_status, MinWidth = 50, MaxWidth = 50
            });
            //#endif
            columnProperties.Add(new GenericTreeViewColumnProperty("EntityName")
            {
                Title = Resx.global_entity, MinWidth = 160
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("EntityFiscalNumber")
            {
                Title = Resx.global_fiscal_number, MinWidth = 70, MaxWidth = 120
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("TotalFinalRound")
            {
                Title          = Resx.global_total,
                MinWidth       = 100,
                Alignment      = 1.0F,
                FormatProvider = new FormatterDecimalCurrency(),
                CellRenderer   = new CellRendererText()
                {
                    FontDesc = new Pango.FontDescription()
                    {
                        Size = fontGenericTreeViewColumn
                    },
                    Alignment = Pango.Alignment.Right,
                    Xalign    = 1.0F
                }
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("TotalDebit")
            {
                //This Query Exists 3 Locations, Find it and change in all Locations - Required "GROUP BY fmaOid,fmaTotalFinal" to work with SQLServer
                Query    = "SELECT fmaTotalFinal - SUM(fmpCreditAmount) as Result FROM view_documentfinancepayment WHERE fmaOid = '{0}' AND fpaPaymentStatus <> 'A' GROUP BY fmaOid, fmaTotalFinal;",
                Title    = Resx.global_debit,
                MinWidth = 100,
                //Alignment = 1.0F,
                FormatProvider = new FormatterDecimalCurrency(),
                //CellRenderer = new CellRendererText()
                //{
                //    FontDesc = new Pango.FontDescription() { Size = fontGenericTreeViewColumn },
                //    Alignment = Pango.Alignment.Right,
                //    Xalign = 1.0F
                //}
            });

            //Sort Order
            SortProperty[] sortProperty = new SortProperty[2];
            sortProperty[0] = new SortProperty("Date", SortingDirection.Ascending);
            sortProperty[1] = new SortProperty("DocumentNumber", SortingDirection.Ascending);

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 25
0
        /// <summary>
        /// Generates a XPCollection with Criteria Operator and create a TreeView Model, from a parameter XPGuidObject Class Type. Used to generate TreeView Models to GenericTreeViewModel Class.
        /// </summary>
        /// <param name="XPCollection"> used to generate TreeView Model</param>
        /// <param name="ColumnProperties"> TreeView Column Properties, used to select which XPOCollection fields are used to generate TreeView ListStore Model.</param>
        /// <param name="TreeViewMode"> TreeView Mode Default or CheckBox</param>
        /// <returns>Returns ListStore, a model ready to be used in GenericTreeViewModel.</returns>
        public override void InitDataModel(XPCollection pDataSource, List <GenericTreeViewColumnProperty> pColumnProperties, GenericTreeViewMode pGenericTreeViewMode)
        {
            //Log4Net
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            //Parameters
            XPCollection _XpCollection = pDataSource;
            List <GenericTreeViewColumnProperty> _columnProperties = pColumnProperties;
            GenericTreeViewMode _treeViewMode = pGenericTreeViewMode;

            //Initialize Model and Column Properties
            ListStore model = GenericTreeViewModel.InitModel(_columnProperties, pGenericTreeViewMode);

            //Init ColumnValues Object Array
            System.Object[] columnValues = new System.Object[_columnProperties.Count];

            //Start Render Model Values from Collection
            String fieldName;

            //Loop Records
            Int32 rowIndex = -1;

            foreach (XPGuidObject dataRow in (_XpCollection as XPCollection))
            {
                // Increment RownIndex
                rowIndex++;
                // reset undefinedRecord
                bool undefinedRecord = false;

                // This will reload current dataRow, without this XPO wil use cached values, and never be in sync when we change data outside
                dataRow.Reload();

                //Loop Fields : Generate Abstract Values to use in Model
                for (int i = 0; i < _columnProperties.Count; i++)
                {
                    //Default FieldName
                    fieldName = _columnProperties[i].Name;

                    //if (fieldName == "Ord" || fieldName == "Code")
                    //{
                    //    _log.Debug("BREAK");
                    //}

                    try
                    {
                        //Dont extract value from Collection if is the CheckBox, its not in Collection, and is always Disabled
                        if (_columnProperties[i].PropertyType == GenericTreeViewColumnPropertyType.CheckBox)
                        {
                            //Initial Checked Value
                            columnValues[i] = false;
                        }
                        else if (fieldName == "RowIndex")
                        {
                            columnValues[i] = rowIndex;
                        }
                        //Query
                        else if (_columnProperties[i].Query != null && _columnProperties[i].Query != string.Empty)
                        {
                            columnValues[i] = ColumnPropertyGetQuery(_columnProperties[i].Query, dataRow.GetMemberValue("Oid"));
                            // Decrypt Before use Format
                            if (_columnProperties[i].DecryptValue)
                            {
                                columnValues[i] = XPGuidObject.DecryptIfNeeded(columnValues[i]);
                            }
                            //Format String using Column FormatProvider
                            if (_columnProperties[i].FormatProvider != null && Convert.ToString(columnValues[i]) != string.Empty)
                            {
                                columnValues[i] = string.Format(_columnProperties[i].FormatProvider, "{0}", columnValues[i]);
                            }
                        }
                        //If detect XPGuidObject Value Type (Value is a XPObject, Child Object), Get Value from its Chield Field (Related Table)
                        else if (dataRow.GetMemberValue(_columnProperties[i].Name) != null &&
                                 dataRow.GetMemberValue(_columnProperties[i].Name).GetType().BaseType == typeof(XPGuidObject))
                        {
                            columnValues[i] = GetXPGuidObjectChildValue(dataRow.GetMemberValue(_columnProperties[i].Name), fieldName, _columnProperties[i].ChildName);
                        }
                        //Get Default Value from Field Name
                        else
                        {
                            // Check/Detect if is a undefinedRecord
                            if (fieldName == "Oid")
                            {
                                undefinedRecord = ((new Guid(dataRow.GetMemberValue(_columnProperties[i].Name).ToString())).Equals(SettingsApp.XpoOidUndefinedRecord));
                            }

                            //TODO (Muga): melhorar isto para ser generico e contemplar os outros campos
                            if (dataRow.GetMemberValue(_columnProperties[i].Name) != null)
                            {
                                // Detect UndefinedRecord and if is a Int Field, and Replace with string.Empty, this ways we Dont Show 0 in Null Undefined Records
                                if (undefinedRecord && dataRow.GetMemberValue(_columnProperties[i].Name).GetType().Name.Equals("UInt32"))
                                {
                                    columnValues[i] = string.Empty;
                                }
                                //Boolean Fields
                                else if (dataRow.GetMemberValue(_columnProperties[i].Name).GetType().Name.Equals("Boolean"))
                                {
                                    bool booleanValue = Convert.ToBoolean(dataRow.GetMemberValue(_columnProperties[i].Name));
                                    columnValues[i] = (booleanValue) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_treeview_true") : resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_treeview_false");
                                }
                                //Other Fields
                                else
                                {
                                    columnValues[i] = Convert.ToString(dataRow.GetMemberValue(_columnProperties[i].Name));
                                    //Format String using Column FormatProvider
                                    if (_columnProperties[i].FormatProvider != null)
                                    {
                                        columnValues[i] = string.Format(_columnProperties[i].FormatProvider, "{0}", columnValues[i]);
                                    }
                                }
                            }
                            //If Field is NULL or Empty always assign string.Empty to prevent re-use last record value
                            else
                            {
                                columnValues[i] = string.Empty;
                            }
                        }

                        // ResourceString : Extract ResourceManager from Final Value
                        if (_columnProperties[i].ResourceString == true && columnValues[i] != null)
                        {
                            // Try to get ResourceString Value, this is required to replace value, but only if it a valid resourceString (not replaced yet after update)
                            // After an Update and Refresh it turns into a string(non resource token), this protection prevents the replace double with a null resourceString,
                            // leaving tree cell value with an empty value
                            bool checkIfResourceStringExist = (resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], columnValues[i].ToString()) != null) ? true : false;
                            // Only Replace resourceString if value is resourceString is not Yet been replaced, ex after an update
                            //_log.Debug(string.Format("columnValues[i]#1: [{0}]", columnValues[i]));
                            if (checkIfResourceStringExist)
                            {
                                columnValues[i] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], columnValues[i].ToString());
                            }
                            //_log.Debug(string.Format("columnValues[i]#2: [{0}]", columnValues[i]));
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(string.Format("XPCollectionToModel(): {0}", ex.Message), ex);
                        columnValues[i] = string.Format("Invalid Field {0}", fieldName);
                    }
                }
                ;
                //Add Column Value to Model
                model.AppendValues(columnValues);
            }
            _listStoreModel = model;
        }
Exemplo n.º 26
0
        /*
         *  /// <summary>Convert a XPObject fields to Object Array of Values, used to Insert, Append in Model</summary>
         *  /// <param name="XpoObject">XPObject Object </param>
         *  /// <param name="ColumnProperties">GenericTreeView Column Properties</param>
         *  public static System.Object[] XPObjectToModelValues(XPGuidObject pXpoObject, List<GenericTreeViewColumnProperty> pColumnProperties)
         *  {
         *    //Parameters
         *    List<GenericTreeViewColumnProperty> _columnProperties = pColumnProperties;
         *    //Used to Store all PropertyInfos of TreeViewColumnProperty Object
         *    PropertyInfo[] pisTreeViewColumnProperties;
         *    //Used to store current TreeViewColumProperty same as _columnProperties[i]
         *    GenericTreeViewColumnProperty currentTreeViewColumnProperty;
         *    //Used to Store Current TreeViewColumnProperty Value
         *    System.Object pInfoValue;
         *
         *    //Used to Store columnValues to Append/Insert to Model and to Store Return
         *    System.Object[] columnValues = new System.Object[_columnProperties.Count];
         *
         *    for (int i = 0; i < _columnProperties.Count; i++)
         *    {
         *      pisTreeViewColumnProperties = typeof(GenericTreeViewColumnProperty).GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
         *
         *      String currentFieldName;
         *
         *      foreach (PropertyInfo pInfo in pisTreeViewColumnProperties)
         *      {
         *        //Default FieldName
         *        currentFieldName = _columnProperties[i].Name;
         *
         *        currentTreeViewColumnProperty = _columnProperties[i];
         *        //Get currentTreeViewColumnProperty Value ex Code, Designation, CreatedAt etc
         *        pInfoValue = pInfo.GetValue(currentTreeViewColumnProperty, null);
         *        //If is Name property and its not XPObject Oid Field Process it
         *        if (pInfo.Name == "Name")
         *        {
         *          //Se detectar XPObject Value Extract value from it, from ChildName
         *          if (pXpoObject.GetMemberValue(_columnProperties[i].Name) != null
         *            && pXpoObject.GetMemberValue(_columnProperties[i].Name).GetType().BaseType == typeof(XPObject))
         *          {
         *            if (_columnProperties[i].ChildName != null & _columnProperties[i].ChildName != string.Empty)
         *            {
         *              currentFieldName += "." + _columnProperties[i].ChildName;
         *              dynamic xpoObjectFieldValue = pXpoObject.GetMemberValue(_columnProperties[i].Name);
         *              columnValues[i] = Convert.ToString(xpoObjectFieldValue.GetType().GetProperty(_columnProperties[i].ChildName).GetValue(xpoObjectFieldValue, null));
         *            }
         *            //Get Default Value from Field Name
         *            else
         *            {
         *              columnValues[i] = string.Format("Detected XPObject! You must define ChildName for Field {0}", currentFieldName);
         *            };
         *          }
         *          else
         *          {
         *            try
         *            {
         *              columnValues[i] = Convert.ToString(pXpoObject.GetMemberValue(_columnProperties[i].Name));
         *              //Console.WriteLine(string.Format("pInfoValue: {0}, xpObjectValue: {1}", pInfoValue, pXpoObject.GetMemberValue((string)pInfoValue)));
         *            }
         *            catch (Exception ex)
         *            {
         *              _log.Error(ex.Message, ex);
         *            };
         *          };
         *        };
         *      };
         *    };
         *
         *    return columnValues;
         *  }
         */
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        // Shared For Both Methods XPOMode and DataTable Mode

        /// <summary>
        /// Initialize ListStore Model with Columns for Both methods, XPOMode and DataTable Mode
        /// </summary>
        /// <param name="pColumnProperties"></param>
        /// <param name="pGenericTreeViewMode"></param>
        /// <returns></returns>
        public static ListStore InitModel(List <GenericTreeViewColumnProperty> pColumnProperties, GenericTreeViewMode pGenericTreeViewMode)
        {
            //Parameters
            List <GenericTreeViewColumnProperty> _columnProperties = pColumnProperties;
            GenericTreeViewMode _treeViewMode = pGenericTreeViewMode;

            ////Only Add System Columns RowIndex, RowCheckBox, and Oid if Not Created First Time, Skip when ReCreate Models
            bool addSystemColumns = (_columnProperties[0].Name != "RowIndex") ? true : false;

            if (addSystemColumns)
            {
                //Insert RowIndex before all Fields
                _columnProperties.Insert(0, new GenericTreeViewColumnProperty("RowIndex")
                {
                    Type = typeof(Int32), Visible = _showSystemColumns
                });

                //Hide Oid Field, Required Fields, Used to access collection XPGuidObjects with Lookup(Oid)
                Boolean hasOid = _columnProperties.Contains(new GenericTreeViewColumnProperty("Oid"));

                //Prepare ViewMode
                switch (_treeViewMode)
                {
                case GenericTreeViewMode.Default:
                    //If miss Oid in ColumnProperties Definition add it After CheckBox
                    if (!hasOid)
                    {
                        _columnProperties.Insert(1, new GenericTreeViewColumnProperty("Oid")
                        {
                            Visible = _showSystemColumns
                        });
                    }
                    break;

                //Add Column CheckBox
                case GenericTreeViewMode.CheckBox:
                    _columnProperties.Insert(1, new GenericTreeViewColumnProperty("RowCheckBox")
                    {
                        Title = string.Empty, PropertyType = GenericTreeViewColumnPropertyType.CheckBox, MinWidth = 50, MaxWidth = 50
                    });
                    //If miss Oid in ColumnProperties Definition add it After CheckBox
                    if (!hasOid)
                    {
                        _columnProperties.Insert(2, new GenericTreeViewColumnProperty("Oid")
                        {
                            Visible = _showSystemColumns
                        });
                    }
                    break;

                default:
                    break;
                }
            }

            //Define array de Types
            Type[] columnTypes = new Type[_columnProperties.Count];

            //Generate columnTypes for ListStore : typeof(string) (G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF)
            for (int i = 0; i < _columnProperties.Count; i++)
            {
                if (_columnProperties[i].PropertyType == GenericTreeViewColumnPropertyType.CheckBox)
                {
                    columnTypes[i] = typeof(bool);
                }
                else
                {
                    //Required to Get Type Int32 from Column, else we cant use it has Int
                    if (_columnProperties[i].Name == "RowIndex")
                    {
                        columnTypes[i] = _columnProperties[i].Type;
                    }
                    else
                    {
                        columnTypes[i] = typeof(string);
                    }
                };
            }
            ;

            ListStore resultListStore = new ListStore(columnTypes);

            return(resultListStore);
        }
        //XpoMode
        public TreeViewDocumentFinanceYears(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_DocumentFinanceYears);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_DocumentFinanceYears defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_DocumentFinanceYears : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogDocumentFinanceYears);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("FiscalYear")
            {
                Title = Resx.global_fiscal_year
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model : Use Default Filter
            CriteriaOperator criteria      = (ReferenceEquals(pXpoCriteria, null)) ? CriteriaOperator.Parse("(Disabled = 0 OR Disabled IS NULL)") : pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Protection to Disable Series Before Creating Year
            this.RecordBeforeInsert += TreeViewDocumentFinanceYears_RecordBeforeInsert;
            this.RecordAfterInsert  += TreeViewDocumentFinanceYears_RecordAfterInsert;

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 28
0
        //XpoMode
        public TreeViewDocumentFinanceYearSerieTerminal(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_DocumentFinanceYearSerieTerminal);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_DocumentFinanceYearSerieTerminal defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_DocumentFinanceYearSerieTerminal : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogDocumentFinanceYearSerieTerminal);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("FiscalYear")
            {
                Title = Resx.global_fiscal_year, ChildName = "Designation"
            });
            //columnProperties.Add(new GenericTreeViewColumnProperty("DocumentType") { Title = Resx.global_documentfinanceseries_documenttype, ChildName = "Designation" });
            //columnProperties.Add(new GenericTreeViewColumnProperty("Serie") { Title = Resx.global_documentfinance_series, ChildName = "Designation" });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Terminal")
            {
                Title = Resx.global_configurationplaceterminal, ChildName = "Designation"
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model : Use Default Filter
            CriteriaOperator criteria = (ReferenceEquals(pXpoCriteria, null)) ? CriteriaOperator.Parse("(Disabled = 0 OR Disabled IS NULL)") : pXpoCriteria;
            //Init Collection
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);
            //Override default Sorting
            SortingCollection sortingCollection = new SortingCollection();

            sortingCollection.Add(new SortProperty("Terminal", DevExpress.Xpo.DB.SortingDirection.Ascending));
            sortingCollection.Add(new SortProperty("Ord", DevExpress.Xpo.DB.SortingDirection.Ascending));
            xpoCollection.Sorting = sortingCollection;

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Exemplo n.º 29
0
        //XpoMode
        public TreeViewConfigurationPrintersType(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(SYS_ConfigurationPrintersType);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            SYS_ConfigurationPrintersType defaultValue = (pDefaultValue != null) ? pDefaultValue as SYS_ConfigurationPrintersType : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogConfigurationPrintersType);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );

            //Protected Records
            ProtectedRecords.Add(SettingsApp.XpoOidConfigurationPrinterTypeThermalPrinterWindows);
            ProtectedRecords.Add(SettingsApp.XpoOidConfigurationPrinterTypeThermalPrinterLinux);
            ProtectedRecords.Add(SettingsApp.XpoOidConfigurationPrinterTypeThermalPrinterSocket);
            ProtectedRecords.Add(SettingsApp.XpoOidConfigurationPrinterTypeGenericWindows);
            ProtectedRecords.Add(SettingsApp.XpoOidConfigurationPrinterTypeGenericLinux);
            ProtectedRecords.Add(SettingsApp.XpoOidConfigurationPrinterTypeExportPdf);
        }
Exemplo n.º 30
0
        //XpoMode
        public TreeViewArticleFamily(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(FIN_ArticleFamily);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            FIN_ArticleFamily defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_ArticleFamily : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogArticleFamily);

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Printer")
            {
                Title = Resx.global_device_printer, ChildName = "Designation"
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //TODO: Clean Comments : Moved Events to XPOWidget - Capture Events - VIEW DialogArticleFamily _crudWidgetList.BeforeUpdate and _crudWidgetList.AfterUpdate
            //this.RecordBeforeInsert += delegate {
            //  _log.Debug(string.Format("[{0}] [{1}]", this.GetType(), "RecordBeforeInsert"));
            //  _log.Debug(string.Format("Dialog.DataSourceRow: [{0}]", (_dialog as DialogArticleFamily).DataSourceRow));
            //  _log.Debug(string.Format("Dialog.CrudWidgetList: [{0}]", (_dialog as DialogArticleFamily).CrudWidgetList));
            //};

            //TODO: Test Events Here
            //this.RecordBeforeUpdate += delegate { _log.Debug(string.Format("[{0}] [{1}]", this.GetType(), "RecordBeforeUpdate"));};
            //this.RecordBeforeDelete += delegate { _log.Debug(string.Format("[{0}] [{1}]", this.GetType(), "RecordBeforeDelete"));};
            //this.RecordAfterInsert += delegate { _log.Debug(string.Format("[{0}] [{1}]", this.GetType(), "RecordAfterInsert")); };
            //this.RecordAfterUpdate += delegate { _log.Debug(string.Format("[{0}] [{1}]", this.GetType(), "RecordAfterUpdate"));};
            //this.RecordAfterDelete += delegate { _log.Debug(string.Format("[{0}] [{1}]", this.GetType(), "RecordAfterDelete"));};
            //this.RecordBeforeConfirm += delegate { _log.Debug(string.Format("[{0}] [{1}]", this.GetType(), "RecordBeforeConfirm"));};

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }