private void Save_btn_Click(object sender, EventArgs e) { try { if (Employee_Name_txt.Text == "") { MessageBox.Show("Employee Name is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Employee_Name_txt.Focus(); } else if (Surname_txt.Text == "") { MessageBox.Show("Surname is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Surname_txt.Focus(); } else if (Salary_txt.Value == 0 && Wage_txt.Value == 0 && Allawance_txt.Value == 0) { MessageBox.Show("Payment is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Salary_txt.Focus(); } else { connection.Open(); OleDbCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "insert into [Employee_Salaries_Wages_Allawance_Record_tbl] (Employee_Name,Employee_Surname,Pay_Period,Date,Salary,Wage,Allawance,Accountant) values ('" + Employee_Name_txt.Text.Trim() + "','" + Surname_txt.Text.Trim() + "','" + Pay_Period_txt.Text.Trim() + "','" + DateTime.Now + "','" + Salary_txt.Value + "','" + Wage_txt.Value + "','" + Allawance_txt.Value + "','" + User_txt.Text.Trim() + "')"; command.ExecuteNonQuery(); connection.Close(); MessageBox.Show(Employee_Name_txt.Text.Trim() + " " + Surname_txt.Text.Trim() + " is expected to receive ;\n\n" + "$" + Salary_txt.Value + "\t\tas Salary\n" + "$" + Wage_txt.Value + "\t\tas Wage\n" + "$" + Allawance_txt.Value + "\t\tas Allawance ", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); Employee_Name_txt.Text = ""; Surname_txt.Text = ""; Salary_txt.Value = 0; Wage_txt.Value = 0; Allawance_txt.Value = 0; Employee_Name_txt.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.StackTrace, "Error Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void Pay_btn_Click(object sender, EventArgs e) { string Payment_Type = ""; if (Salary_radioButton.Checked == true) { Payment_Type = Salary_radioButton.Text.Trim(); } else if (Wage_radioButton.Checked == true) { Payment_Type = Wage_radioButton.Text.Trim(); } else if (Allawance_radioButton.Checked == true) { Payment_Type = Allawance_radioButton.Text.Trim(); } else { MessageBox.Show("\tSalary, Wage and/or Allawance is empty.\t", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } try { if (Employee_Name_txt.Text == "") { MessageBox.Show("Employee Name is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Employee_Name_txt.Focus(); } else if (Surname_txt.Text == "") { MessageBox.Show("Surname is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Surname_txt.Focus(); } else if (Pay_Period_txt.Text == "") { MessageBox.Show("Pay Period is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Pay_Period_txt.Focus(); } else if (Cash_txt.Value == 0 && Transfer_txt.Value == 0 && Bank_txt.Value == 0) { MessageBox.Show("Payment is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Cash_txt.Focus(); } else { decimal Total = 0; decimal Outstanding_Balance = 0; Total = Cash_txt.Value + Transfer_txt.Value + Bank_txt.Value; Outstanding_Balance = Salary_Due_txt.Value - Total; connection.Open(); OleDbCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "insert into [Employee_Salary_tbl] (Employee_Name,Surname,Pay_Day,Pay_Description,Pay_Period,Cash_Amount,Transfer_Amount,Bank_Amount,Total_Amount_Paid,Outstanding_Balance,Accountant) values ('" + Employee_Name_txt.Text.Trim() + "','" + Surname_txt.Text.Trim() + "','" + DateTime.Now + "','" + Payment_Type + "','" + Pay_Period_txt.Text.Trim() + "','" + Cash_txt.Value + "','" + Transfer_txt.Value + "','" + Bank_txt.Value + "','" + Total + "','" + Outstanding_Balance + "','" + User_txt.Text.Trim() + "')"; command.ExecuteNonQuery(); connection.Close(); MessageBox.Show(Employee_Name_txt.Text.Trim() + " " + Surname_txt.Text.Trim() + " has received;\n\n " + "\t\t$" + Total + " as " + Payment_Type, "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); Employee_Name_txt.Text = ""; Surname_txt.Text = ""; Payment_Type = ""; Pay_Period_txt.Text = ""; Cash_txt.Value = 0; Transfer_txt.Value = 0; Bank_txt.Value = 0; Salary_radioButton.Checked = false; Wage_radioButton.Checked = false; Allawance_radioButton.Checked = false; Employee_Name_txt.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.StackTrace, "Error Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }