Example #1
0
        /// <summary>
        /// Retrieves table from database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadTableFromDatabase(object sender, EventArgs e)
        {
            using (GetUserServiceClient client = new GetUserServiceClient("NetTcpBinding_IGetUserService"))
            {
                DataSet set = client.GetTable();

                if (set.DataSetName == "Error")
                {
                    MessageBox.Show("Client could not connect to database. Server is either unavailable or you are not connected to the internet.",
                                    "Connection error");
                    return;
                }
                DataTable table = set.Tables[0];

                RefreshDataGridView(MainGridView);

                MainGridView.DataSource = table;
                foreach (DataGridViewColumn column in MainGridView.Columns)
                {
                    column.HeaderText = table.Columns[MainGridView.Columns.IndexOf(column)].Caption;
                }
            }

            ChangedCells.Clear();
            BadCells.Clear();
            SetButtons(true, true, true);
            LoadSettings();
            Output("Loaded data from database.");
        }
Example #2
0
        /// <summary>
        /// Loads table from XML file.
        /// </summary>
        private void LoadFromXML()
        {
            if (!File.Exists(XmlPath))
            {
                MainGridView.Rows.Clear();
                return;
            }

            RefreshDataGridView(MainGridView);

            using (DataSet set = new DataSet())
            {
                set.ReadXml(XmlPath, XmlReadMode.ReadSchema);

                MainGridView.DataSource = set.Tables[0];

                foreach (DataGridViewColumn column in MainGridView.Columns)
                {
                    column.HeaderText = set.Tables[0].Columns[MainGridView.Columns.IndexOf(column)].Caption;
                }
            }

            ChangedCells.Clear();
            BadCells.Clear();

            SetButtons(false, false, true);
            LoadSettings();
        }
Example #3
0
        /// <summary>
        /// Sets changed cell's colors to white and clears the list.
        /// </summary>
        private void ClearChangedCells()
        {
            foreach (DataGridViewCell cell in ChangedCells)
            {
                cell.Style.BackColor = Color.Empty;
            }

            ChangedCells.Clear();
        }
Example #4
0
        /// <summary>
        /// Deletes content of given DataGridView.
        /// </summary>
        /// <param name="gridView"></param>
        private void RefreshDataGridView(DataGridView gridView)
        {
            gridView.Columns.Clear();

            DataTable DT = (DataTable)gridView.DataSource;

            DT?.Clear();
            BadCells.Clear();
            ChangedCells.Clear();

            gridView.Refresh();
        }