Beispiel #1
0
        /// <summary>
        /// Load the form using table 'Tag' PrimaryKey
        /// </summary>
        public void LoadForm(int TagID)
        {
            string error = null;

            TagDataContext = dataConnection.GetDataContext(TagID, out error);
            DataContext    = TagDataContext;
        }
Beispiel #2
0
        /// <summary>
        /// Alternative contructor. Creates the Form and also load it's data using table '' Primary key.
        /// </summary>
        public FormWPFTag(WPFConfig config, int TagID, Frame mainFrame)
        {
            this.config          = config;
            this.FrameMainWindow = mainFrame;
            dataConnection       = new WPFTagDB(config);
            string error = null;

            TagDataContext = dataConnection.GetDataContext(TagID, out error);
            DataContext    = TagDataContext;
            InitializeComponent();
        }
Beispiel #3
0
        public void LoadGrid(Func <ModelNotifiedForTag, bool> filter = null)
        {
            this.DataGridTag.ItemsSource = null;

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

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

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

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

            this.DataContext = TagDataContext;

            List <ModelNotifiedForTag> filteredList;

            if (filter == null)
            {
                filteredList = TagDataContext.modelNotifiedForTagMain;
            }
            else
            {
                filteredList = TagDataContext.modelNotifiedForTagMain.Where(filter).ToList();
            }

            //Bind data
            SetGridData(filteredList);

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