using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace Payroll
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
private SqlCommand command = new SqlCommand();
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'salariesDataSet.Salaries' table. You can move, or remove it, as needed.
this.salariesTableAdapter.FillBy(this.salariesDataSet.Salaries);
}
//Declaration of variables
private decimal BasicSalary, Overtime, ExtraOvertime, LeaveOutstanding, GrossSalary, SSNIT13, SSNIT5, TaxableIncome, IncomeTax, Absent, TotalDeductions, NetSalary;
private int DaysWorked, DaysAbsent;
private DateTime EmpDate, CurrentDate;
private void saveButton_Click(object sender, EventArgs e)
{
this.Validate();
this.salariesBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.salariesDataSet);
}
private void salariesBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
try
{
this.Validate();
this.salariesBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.salariesDataSet);
SalariesDataSet.SalariesDataTable deletedSalaries = (SalariesDataSet.SalariesDataTable)
SalariesDataSet.SalariesRow.GetChanges(DataRowState.Deleted);
SalariesDataSet.SalariesDataTable newSalaries = (SalariesDataSet.SalariesDataTable)
SalariesDataSet.SalariesRow.GetChanges(DataRowState.Added);
SalariesDataSet.SalariesDataTable modifiedSalaries = (SalariesDataSet.SalariesDataTable)
SalariesDataSet.SalariesRow.GetChanges(DataRowState.Modified);
{
// Remove all deleted salary from the Salaries table.
if (deletedSalaries != null)
{
salariesTableAdapter.Update(deletedSalaries);
}
// Add new salary to the Salaries table.
if (newSalaries != null)
{
salariesTableAdapter.Update(newSalaries);
}
// Update all modified Salaries.
if (modifiedSalaries != null)
{
salariesTableAdapter.Update(newSalaries);
}
salariesDataSet.AcceptChanges();
}
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}