private void button5_Click(object sender, EventArgs e)
        {
            //// TODO: This line of code loads data into the 'homeTextileDBDataSet2.Employees' table. You can move, or remove it, as needed.
            //this.employeesTableAdapter.Fill(this.homeTextileDBDataSet2.Employees);
            //// TODO: This line of code loads data into the 'homeTextileDBDataSet2.Advances' table. You can move, or remove it, as needed.
            //this.advancesTableAdapter.Fill(this.homeTextileDBDataSet2.Advances);

            DialogResult res = MessageBox.Show("Are you sure you want to Update", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (res == DialogResult.Cancel)
            {
                return;
            }

            Advance advances = new Advance();
            Advance advanceU = new Advance();

            try
            {
                advances.Id = Convert.ToInt32(idTextBox.Text);
                advanceU    = db.Advances.Find(advances.Id);
            }
            catch
            {
            }
            advanceU.EmployeeId = Convert.ToInt32(employeeIdComboBox.SelectedValue);
            advanceU.Amount     = Convert.ToDouble(amountTextBox.Text) - advanceU.Amount;
            advanceU.Date       = Convert.ToDateTime(dateDateTimePicker.Text);


            if (advanceU.IsAbleToTakeAdvance() && advanceU.Id != 0)
            {
                advanceU.Amount          = Convert.ToDouble(amountTextBox.Text);
                db.Entry(advanceU).State = EntityState.Modified;

                db.SaveChanges();
            }

            else
            {
                MessageBox.Show("Employee can not take advance for this month!");
                db = new DatabaseContext();
                db = new DatabaseContext();
                this.advanceDataGridView.DataSource = db.Advances.ToList();
                return;
            }



            MessageBox.Show("Save Sucessfully!");
            db = new DatabaseContext();
            db = new DatabaseContext();
            this.advanceDataGridView.DataSource = db.Advances.ToList();


            //this.advanceBindingSource.DataSource = db.Advances.ToList();
        }
        private void SaveAll()
        {
            //this.Validate();
            //this.advancesBindingSource.EndEdit();
            //this.tableAdapterManager.UpdateAll(this.homeTextileDBDataSet2);
            Advance advances = new Advance();

            try
            {
                advances.Id = Convert.ToInt32(idTextBox.Text);
            }
            catch
            {
            }
            advances.EmployeeId = Convert.ToInt32(employeeIdComboBox.SelectedValue);
            advances.Amount     = Convert.ToDouble(amountTextBox.Text);
            advances.Date       = Convert.ToDateTime(dateDateTimePicker.Text);


            if (advances.IsAbleToTakeAdvance())
            {
                db.Advances.Add(advances);

                db.SaveChanges();
            }

            else
            {
                MessageBox.Show("Employee can not take advance for this month!");
                db = new DatabaseContext();
                this.advanceDataGridView.DataSource = db.Advances.ToList();
                return;
            }



            MessageBox.Show("Save Sucessfully!");
            //this.advanceBindingSource.DataSource = db.Advances.ToList();
            db = new DatabaseContext();
            this.advanceDataGridView.DataSource = db.Advances.ToList();
        }