private void btnSave_Click(object sender, EventArgs e) { if (txtYear.Text.Trim() == "") { MessageBox.Show("Please fill the year"); } else if (cmbMonth.SelectedIndex == -1) { MessageBox.Show("Please select month"); } else if (txtSalary.Text.Trim() == "") { MessageBox.Show("Please fill the salary"); } else if (txtUserNo.Text.Trim() == "") { MessageBox.Show("Please select the employee"); } else { bool control = false; if (!isUpdated) { if (salary.EmployeeID == 0) { MessageBox.Show("Please select the employee from the table"); } else { salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > oldSalary) { control = true; } SalaryBLL.AddSalary(salary, control); MessageBox.Show("Salary added!"); cmbMonth.SelectedIndex = -1; salary = new SALARY(); } } else { DialogResult dialogResult = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { SALARY salary = new SALARY(); salary.ID = detail.SalaryID; salary.EmployeeID = detail.EmployeeID; salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > detail.OldSalary) { control = true; } SalaryBLL.UpdateSalary(salary, control); MessageBox.Show("Salary updated!"); this.Close(); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtYear.Text.Trim() == "") { MessageBox.Show("year is empty"); } else if (txtSalary.Text.Trim() == "") { MessageBox.Show("Salary is empty"); } else if (cmbMonth.SelectedIndex == -1) { MessageBox.Show("Select a month"); } else { bool control = false; if (!isUpdate) { if (salary.EmployeeID == 0) { MessageBox.Show("please select an employee from table"); } else { salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > oldsalary) { control = true; } SalaryBLL.AddSalary(salary, control); MessageBox.Show("Salary was added"); cmbMonth.SelectedIndex = -1; salary = new SALARY(); } } else { DialogResult result = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { SALARY salary = new SALARY(); salary.ID = detail.SalaryID; salary.EmployeeID = detail.EmployeeID; salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > detail.oldSalary) { control = true; } SalaryBLL.UpdateSalary(salary, control); MessageBox.Show("Salary was Uptaded"); this.Close(); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtYear.Text.Trim() == "") { MessageBox.Show("Year is empty"); } else if (cmbMonth.SelectedIndex == -1) { MessageBox.Show("Please select a Month"); } else if (txtSalary.Text.Trim() == "") { MessageBox.Show("Salary is empty"); } else if (txtUserNo.Text.Trim() == "") { MessageBox.Show("User number is empty"); } else { //Guardando el salario maximo del empleado bool control = false; if (!isUpdate) { if (salary.EmployeeID == 0) { MessageBox.Show("Select an Employee"); } else { salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > oldsalary) { control = true; } SalaryBLL.AddSalary(salary, control); MessageBox.Show("Salary Added"); cmbMonth.SelectedIndex = -1; salary = new Salary(); } } else { DialogResult result = MessageBox.Show("Are you sure", "Warning", MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { Salary salary = new Salary(); salary.ID = detail.SalaryID; salary.EmployeeID = detail.EmployeeID; salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > detail.OldSalary) { control = true; } SalaryBLL.UpdateSalary(salary, control); MessageBox.Show("Salary Updated"); this.Close(); } } } }