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 Save_btn_Click(object sender, EventArgs e) { string Marital_Status; if (Single_radioButton.Checked == true) { Marital_Status = Single_radioButton.Text.Trim(); } else if (Married_radioButton.Checked == true) { Marital_Status = Married_radioButton.Text.Trim(); } else if (Divoced_radioButton.Checked == true) { Marital_Status = Divoced_radioButton.Text.Trim(); } else { Marital_Status = "Personal and Complicated"; } string Sex; if (Male_radioButton.Checked == true) { Sex = Male_radioButton.Text.Trim(); } else if (Female_radioButton.Checked == true) { Sex = Female_radioButton.Text.Trim(); } else { Sex = "Too Complicated"; } try { if (National_ID_txt.Text == "" || National_ID_txt.Text == "NULL") { MessageBox.Show("National ID is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); National_ID_txt.Focus(); } else if (First_Name_txt.Text == "") { MessageBox.Show("First Name is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); First_Name_txt.Focus(); } else if (Surname_txt.Text == "") { MessageBox.Show("Surname is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Surname_txt.Focus(); } else if (House_Address_txt.Text == "") { MessageBox.Show("House Address is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); House_Address_txt.Focus(); } else if (Contact_Details_txt.Text == "") { MessageBox.Show("Contact Details is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Contact_Details_txt.Focus(); } else if (Description_and_Criminal_Record_txt.Text == "") { MessageBox.Show("Description and Criminal Record is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Description_and_Criminal_Record_txt.Focus(); } else { try { OleDbCommand Employee_Command = new OleDbCommand { CommandType = CommandType.Text, CommandText = "INSERT INTO [Employee_Registration_Record_tbl] ([First_Name],[Surname],[House_Address],[Contact_Details],[National_Id],[Marital_Status],[Employee_Description],[Sex],[D_O_B],[Accountant])" + "VALUES (?,?,?,?,?,?,?,?,?,?)" }; Employee_Command.Parameters.AddWithValue("@First_Name", First_Name_txt.Text.Trim()); Employee_Command.Parameters.AddWithValue("@Surname", Surname_txt.Text.Trim()); Employee_Command.Parameters.AddWithValue("@House_Address", House_Address_txt.Text.Trim()); Employee_Command.Parameters.AddWithValue("@Contact_Details", Contact_Details_txt.Text.Trim()); Employee_Command.Parameters.AddWithValue("@National_Id", National_ID_txt.Text.Trim()); Employee_Command.Parameters.AddWithValue("@Marital_Status", Marital_Status.Trim()); Employee_Command.Parameters.AddWithValue("@Employee_Description", Description_and_Criminal_Record_txt.Text.Trim()); Employee_Command.Parameters.AddWithValue("@Sex", Sex.Trim()); Employee_Command.Parameters.AddWithValue("@D_O_B", Student_dateTimePicker.Text.Trim()); Employee_Command.Parameters.AddWithValue("@Accountant", User_txt.Text.Trim()); Employee_Command.Connection = connection; connection.Open(); Employee_Command.ExecuteNonQuery(); connection.Close(); } catch (Exception ex) { connection.Close(); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.StackTrace, "Error Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } MessageBox.Show(First_Name_txt.Text.Trim() + " has been successfully added into the School Database", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); First_Name_txt.Text = ""; Surname_txt.Text = ""; House_Address_txt.Text = ""; Contact_Details_txt.Text = ""; National_ID_txt.Text = ""; Married_radioButton.Checked = false; Single_radioButton.Checked = false; Divoced_radioButton.Checked = false; Description_and_Criminal_Record_txt.Text = ""; Male_radioButton.Checked = false; Female_radioButton.Checked = false; Student_dateTimePicker.Value = DateTime.Now; National_ID_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 Save_btn_Click(object sender, System.EventArgs e) { string Sex = ""; if (Boy_radioButton.Checked == true) { Sex = Boy_radioButton.Text.Trim(); } else if (Girl_radioButton.Checked == true) { Sex = Girl_radioButton.Text.Trim(); } try { if (First_Name_txt.Text == "") { MessageBox.Show("First Name is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); First_Name_txt.Focus(); } else if (Surname_txt.Text == "") { MessageBox.Show("Surname is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Surname_txt.Focus(); } else if (House_Address_txt.Text == "") { MessageBox.Show("House Address is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); House_Address_txt.Focus(); } else if (Contact_Details_txt.Text == "") { MessageBox.Show("Contact Details is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Contact_Details_txt.Focus(); } else if (Parent_Gaurdian_txt.Text == "") { MessageBox.Show("Parent or Gaurdian is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Parent_Gaurdian_txt.Focus(); } else if (Health_Record_txt.Text == "") { MessageBox.Show("Health Record is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Health_Record_txt.Focus(); } else if (Description_and_Special_needs_txt.Text == "") { MessageBox.Show("Description and Special Needs is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Description_and_Special_needs_txt.Focus(); } else { try { OleDbCommand Student_Command = new OleDbCommand { CommandType = CommandType.Text, CommandText = "INSERT INTO [Student_Registration_Record_tbl] ([First_Name],[Surname],[House_Address],[Contact_Details],[Parent_Gaurdian],[Health_Record],[Description_Special_Needs],[Sex],[D_O_B],[Accountant])" + "VALUES (?,?,?,?,?,?,?,?,?,?)" }; Student_Command.Parameters.AddWithValue("@First_Name", First_Name_txt.Text.Trim()); Student_Command.Parameters.AddWithValue("@Surname", Surname_txt.Text.Trim()); Student_Command.Parameters.AddWithValue("@House_Address", House_Address_txt.Text.Trim()); Student_Command.Parameters.AddWithValue("@Contact_Details", Contact_Details_txt.Text.Trim()); Student_Command.Parameters.AddWithValue("@Parent_Gaurdian", Parent_Gaurdian_txt.Text.Trim()); Student_Command.Parameters.AddWithValue("@Health_Record", Health_Record_txt.Text.Trim()); Student_Command.Parameters.AddWithValue("@Description_Special_Needs", Description_and_Special_needs_txt.Text.Trim()); Student_Command.Parameters.AddWithValue("@Sex", Sex.Trim()); Student_Command.Parameters.AddWithValue("@D_O_B", Student_dateTimePicker.Text.Trim()); Student_Command.Parameters.AddWithValue("@Accountant", User_txt.Text.Trim()); Student_Command.Connection = connection; connection.Open(); Student_Command.ExecuteNonQuery(); connection.Close(); } catch (Exception ex) { connection.Close(); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.StackTrace, "Error Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } MessageBox.Show(First_Name_txt.Text.Trim() + " " + Surname_txt.Text.Trim() + " has been successfully added into the School Database", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); First_Name_txt.Text = ""; Surname_txt.Text = ""; House_Address_txt.Text = ""; Contact_Details_txt.Text = ""; Parent_Gaurdian_txt.Text = ""; Health_Record_txt.Text = ""; Description_and_Special_needs_txt.Text = ""; Boy_radioButton.Checked = false; Girl_radioButton.Checked = false; Student_dateTimePicker.Value = DateTime.Now; First_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); } }