Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
QuestionWhy is my Sidebar not in the right place?? Pin
blacktech13-Jul-15 8:51
blacktech13-Jul-15 8:51 
AnswerRe: Why is my Sidebar not in the right place?? Pin
blacktech13-Jul-15 8:53
blacktech13-Jul-15 8:53 
SuggestionRe: Why is my Sidebar not in the right place?? Pin
Richard MacCutchan13-Jul-15 22:15
mveRichard MacCutchan13-Jul-15 22:15 
GeneralRe: Why is my Sidebar not in the right place?? Pin
blacktech15-Jul-15 2:39
blacktech15-Jul-15 2:39 
QuestionSaving an array to disk Pin
Member 1171394212-Jul-15 5:57
Member 1171394212-Jul-15 5:57 
AnswerRe: Saving an array to disk PinPopular
OriginalGriff12-Jul-15 5:59
mveOriginalGriff12-Jul-15 5:59 
GeneralRe: Saving an array to disk Pin
Member 1171394212-Jul-15 6:05
Member 1171394212-Jul-15 6:05 
QuestionHow to update database when adding an item Pin
Member 1183153312-Jul-15 5:15
Member 1183153312-Jul-15 5:15 
Dear Forum Members,

I started learning c# by making some applications. Recently i made an application where you can add an employee and his rate (per hour) in a database. When you add the employee, it should update the database and show a report of the amount of employees.

I can add an employee and it shows the new entry in the table, but when i refresh the report, it shows no new entries. When i close the application and start it over, it shows the new employee.

I can't figure out what i did wrong. Could someone help me out?

Source code:

This part is the main form, where you can see the report:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Employeereport
{
    public partial class Employeestart : Form
    {
        public Employeestart()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'employeeDatabase.Table' table. You can move, or remove it, as needed.
            
            this.TableTableAdapter.Fill(this.employeeDatabase.Table);
            this.reportViewer1.RefreshReport();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            addEmployee medewerker = new addEmployee();
            medewerker.ShowDialog();

        }

        private void reportViewer1_Load(object sender, EventArgs e)
        {

        }
    }
}


When you press the "add new employee" button it opens a new form where you can add the employee and his rate. Next to this there is a table where the entry is added:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Employeereport
{
    public partial class addEmployee : Form
    {
        public addEmployee()
        {
            InitializeComponent();
        }

        private void tableBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.tableBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.employeeDatabase);

        }

        private void addEmployee_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'employeeDatabase.Table' table. You can move, or remove it, as needed.
            this.tableTableAdapter.Fill(this.employeeDatabase.Table);

        }
    }
}



I added my project files here:
https://www.dropbox.com/s/1klokwyupx78tuz/Employeeapplication.zip?dl=0[^]


Thanks in advance!

modified 12-Jul-15 11:52am.

AnswerRe: How to update database when adding an item Pin
OriginalGriff12-Jul-15 5:46
mveOriginalGriff12-Jul-15 5:46 
GeneralRe: How to update database when adding an item Pin
Member 1183153312-Jul-15 5:53
Member 1183153312-Jul-15 5:53 
AnswerRe: How to update database when adding an item Pin
Dave Kreskowiak12-Jul-15 6:26
mveDave Kreskowiak12-Jul-15 6:26 
GeneralRe: How to update database when adding an item Pin
Member 1183153312-Jul-15 7:00
Member 1183153312-Jul-15 7:00 
QuestionLinq-ToSql and EF Questions Pin
Kevin Marois10-Jul-15 4:54
professionalKevin Marois10-Jul-15 4:54 
AnswerRe: Linq-ToSql and EF Questions Pin
Richard Deeming10-Jul-15 5:54
mveRichard Deeming10-Jul-15 5:54 
GeneralRe: Linq-ToSql and EF Questions Pin
Kevin Marois10-Jul-15 5:56
professionalKevin Marois10-Jul-15 5:56 
Questionwifi form Pin
Member 118239158-Jul-15 16:51
Member 118239158-Jul-15 16:51 
AnswerRe: wifi form Pin
Dave Kreskowiak8-Jul-15 17:22
mveDave Kreskowiak8-Jul-15 17:22 
QuestionCasting HttpRequestMessage.Properties["MS_RequestContext"] to OwinHttpRequestContext Pin
Alaric_8-Jul-15 11:09
professionalAlaric_8-Jul-15 11:09 
QuestionSelectSingleNode issue Pin
tiwal7-Jul-15 7:42
tiwal7-Jul-15 7:42 
QuestionRe: SelectSingleNode issue Pin
ZurdoDev7-Jul-15 7:50
professionalZurdoDev7-Jul-15 7:50 
AnswerRe: SelectSingleNode issue Pin
tiwal7-Jul-15 8:25
tiwal7-Jul-15 8:25 
AnswerRe: SelectSingleNode issue Pin
Richard Deeming7-Jul-15 8:36
mveRichard Deeming7-Jul-15 8:36 
GeneralRe: SelectSingleNode issue Pin
tiwal7-Jul-15 9:08
tiwal7-Jul-15 9:08 
GeneralRe: SelectSingleNode issue Pin
Dave Kreskowiak7-Jul-15 9:12
mveDave Kreskowiak7-Jul-15 9:12 
GeneralRe: SelectSingleNode issue Pin
tiwal7-Jul-15 9:40
tiwal7-Jul-15 9:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.