public TablePage(GridViewLoadfile gridview, LoadfileBase loadfile) { InitializeComponent(); Dgv = gridview; // Collect the fieldnames added to the grid this.cmboFunctionField.ItemsSource = Dgv.FieldNamesAsDisplayed; this.cmboFunctionField.DataContext = Dgv; this.tbPageRowCount.Text = Dgv.PageRowCount.ToString(); this.tbLastPage.Text = Dgv.LastPage.ToString(); this.tblTotalRowCount.Text = Dgv.TotalRowCount.ToString("#,##0") + " rows"; // wire up the paging events now that we are ready for the user this.tbLastPage.TextChanged += tbLastPage_TextChanged; this.tbCurrentPage.TextChanged += tbCurrentPage_TextChanged; Dgv.Sort(this.dgData, 0); // the loadfile object this.Loadfile = loadfile; }
public void LoadLoadfile() { Status("Loading " + Loadfile.FileInformation.Name + ".... "); try { Log.Timer.Start(); // create database if (string.IsNullOrEmpty(Db.Connect.DatabasePath)) { Db.Connect.Initialize(this.Loadfile.FileInformation.Length); } // read loadfile into database using (Db.Load Loader = new Db.Load()) { Loader.LoadToDatabase(Loadfile); this.tbFilepath.Text = this.Loadfile.FileInformation.FullName; // add TablePage tabs for data and errors GridViewLoadfile DataGridView = new GridViewLoadfile(Loader.TableName, Loader.CountTotalRecords, Loadfile.FieldNamesSelected); Views.TablePage DataPage = new Views.TablePage(DataGridView, Loadfile); DataPage.StatusUpdate += OnStatusUpdate; DataPage.TabName = Loader.TableName.Replace("_", "__"); // the underscores can indicate a hotkey so escape them with a second underscore Frame DataPageFrame = new Frame(); DataPageFrame.Content = DataPage; TabItem DataPageTabItem = new TabItem(); DataPageTabItem.Content = DataPage; DataPageTabItem.Header = DataPage.TabName; this.tabcontrolGridViews.Items.Add(DataPageTabItem); // we need to add a tab for errors as well GridViewLoadfile ErrorGridView = new GridViewLoadfile(Loader.ErrorTableName, Loader.CountTotalRecordsErrors, new List <string>() { "Position", "Error", "Line" }); Views.TablePage ErrorPage = new Views.TablePage(ErrorGridView, Loadfile); ErrorPage.TabName = Loader.ErrorTableName.Replace("_", "__"); // the underscores can indicate a hotkey so escape them with a second underscore Frame ErrorPageFrame = new Frame(); ErrorPageFrame.Content = ErrorPage; TabItem ErrorPageTabItem = new TabItem(); ErrorPageTabItem.Content = ErrorPageFrame; ErrorPageTabItem.Header = ErrorPage.TabName; this.tabcontrolGridViews.Items.Add(ErrorPageTabItem); this.btnSave.IsEnabled = true; Status("Load is complete with " + (Loader.CountBadRecords + Loader.CountErrors).ToString("#,##0") + " errors: " + Loadfile.FileInformation.FullName + " (" + Log.Timer.ElapsedTime().ToString() + ")"); } } catch (Exception Ex) { Log.ErrorLog.AddMessage("Error on LoadLoadfile operation" + Environment.NewLine + Ex.Message + Environment.NewLine + Ex.StackTrace); Status("Error on LoadLoadfile operation (" + Log.Timer.ElapsedTime().ToString() + ")"); } }