Пример #1
0
        /// <summary>
        /// Load the form using table 'EmployeeTerritories' PrimaryKey
        /// </summary>
        public void LoadForm(int EmployeeID, string TerritoryID)
        {
            string error = null;

            EmployeeTerritoriesDataContext = dataConnection.GetDataContext(EmployeeID, TerritoryID, out error);
            DataContext = EmployeeTerritoriesDataContext;
        }
Пример #2
0
        /// <summary>
        /// Alternative contructor. Creates the Form and also load it's data using table '' Primary key.
        /// </summary>
        public FormWPFEmployeeTerritories(WPFConfig config, int EmployeeID, string TerritoryID, Frame mainFrame)
        {
            this.config          = config;
            this.FrameMainWindow = mainFrame;
            dataConnection       = new WPFEmployeeTerritoriesDB(config);
            string error = null;

            EmployeeTerritoriesDataContext = dataConnection.GetDataContext(EmployeeID, TerritoryID, out error);
            DataContext = EmployeeTerritoriesDataContext;
            InitializeComponent();
        }
Пример #3
0
        public void LoadGrid(Func <ModelNotifiedForEmployeeTerritories, bool> filter = null)
        {
            this.DataGridEmployeeTerritories.ItemsSource = null;

            //Saving current language
            WPFMessageAndLabelForList currentLanguage = new WPFMessageAndLabelForList();

            if (this.EmployeeTerritoriesDataContext != null)
            {
                currentLanguage = this.EmployeeTerritoriesDataContext.WPFMessageAndLabelForList;
            }
            string error = null;

            this.EmployeeTerritoriesDataContext = dataConnection.GetDataContext(out error);
            if (!string.IsNullOrEmpty(error))
            {
                MessageBox.Show(error);
                return;
            }

            //Setting language messages
            this.EmployeeTerritoriesDataContext.WPFMessageAndLabelForList = currentLanguage;

            this.DataContext = EmployeeTerritoriesDataContext;

            List <ModelNotifiedForEmployeeTerritories> filteredList;

            if (filter == null)
            {
                filteredList = EmployeeTerritoriesDataContext.modelNotifiedForEmployeeTerritoriesMain;
            }
            else
            {
                filteredList = EmployeeTerritoriesDataContext.modelNotifiedForEmployeeTerritoriesMain.Where(filter).ToList();
            }

            //Bind data
            SetGridData(filteredList);

            //Load detail forms/lists in master/detail
            if (EmployeeTerritoriesDataContext.modelNotifiedForEmployeeTerritoriesMain.Count != 0)
            {
                this.LoadDetail(EmployeeTerritoriesDataContext.modelNotifiedForEmployeeTerritoriesMain[0]);
            }
        }