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

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

            SuppliersDataContext = dataConnection.GetDataContext(SupplierID, out error);
            DataContext          = SuppliersDataContext;
            InitializeComponent();
        }
Exemple #3
0
        public void LoadGrid(Func <ModelNotifiedForSuppliers, bool> filter = null)
        {
            this.DataGridSuppliers.ItemsSource = null;

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

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

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

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

            this.DataContext = SuppliersDataContext;

            List <ModelNotifiedForSuppliers> filteredList;

            if (filter == null)
            {
                filteredList = SuppliersDataContext.modelNotifiedForSuppliersMain;
            }
            else
            {
                filteredList = SuppliersDataContext.modelNotifiedForSuppliersMain.Where(filter).ToList();
            }

            //Bind data
            SetGridData(filteredList);

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