private void Build_btn_Click(object sender, System.EventArgs e) { try { if (Activity_Name_txt.Text == "") { MessageBox.Show("Activity Name is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Activity_Name_txt.Focus(); } else if (Location_txt.Text == "") { MessageBox.Show("Location is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Location_txt.Focus(); } else if (School_Term_txt.Text == "") { MessageBox.Show("School Term is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); School_Term_txt.Focus(); } else if (Activity_Description_txt.Text == "") { MessageBox.Show(" Activity Description is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Activity_Description_txt.Focus(); } else if (Cash_txt.Value == 0) { MessageBox.Show("Cash Payment is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Cash_txt.Focus(); } else { connection.Open(); OleDbCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "insert into [Activity_Managment_tbl] (Activity_Name,Location,School_Term,From_Date,To_Date,Activity_Description,Cash_Fees,Accountant) values ('" + Activity_Name_txt.Text.Trim() + "','" + Location_txt.Text.Trim() + "','" + School_Term_txt.Text.Trim() + "','" + From_Date_dateTimePicker.Text.Trim() + "','" + To_Date_dateTimePicker.Text.Trim() + "','" + Activity_Description_txt.Text.Trim() + "','" + Cash_txt.Value + "','" + User_txt.Text.Trim() + "')"; command.ExecuteNonQuery(); connection.Close(); MessageBox.Show(Activity_Name_txt.Text.Trim() + " will be at " + Location_txt.Text.Trim() + ".\nFrom ;\t\t" + From_Date_dateTimePicker.Value + "\nTo ;\t\t" + To_Date_dateTimePicker.Value + "\n\n\t*****Enjoy Yourself :)*****", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); Activity_Name_txt.Text = ""; Location_txt.Text = ""; School_Term_txt.Text = ""; Activity_Description_txt.Text = ""; Cash_txt.Value = 0; Activity_Name_txt.Focus(); } } catch (Exception ex) { connection.Close(); 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); } }