-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employee Salaries Wages Allawance Form.cs
85 lines (76 loc) · 4.16 KB
/
Employee Salaries Wages Allawance Form.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
namespace Pre_School_Managment_System
{
public partial class Employee_Salaries_Wages_Allawance_Form : Form
{
private readonly OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["Pre_School_Managment_System.Properties.Settings.System_DatabaseConnectionString"].ConnectionString);
public Employee_Salaries_Wages_Allawance_Form()
{
InitializeComponent();
}
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 Employee_Salaries_Wages_Allawance_Form_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'system_DatabaseDataSet.Employee_Registration_Record_tbl' table. You can move, or remove it, as needed.
this.employee_Registration_Record_tblTableAdapter.Fill(this.system_DatabaseDataSet.Employee_Registration_Record_tbl);
Employee_Name_txt.Text = "";
Surname_txt.Text = "";
}
private void Employee_Name_txt_SelectedIndexChanged(object sender, EventArgs e)
{
string query = "Select [Surname] FROM [Employee_Registration_Record_tbl] WHERE First_Name = '" + Employee_Name_txt.Text.Trim() + "'";
OleDbDataAdapter sda = new OleDbDataAdapter(query, connection);
DataTable dtbl = new DataTable();
sda.Fill(dtbl);
if (dtbl.Rows.Count > 0)
{
Surname_txt.Text = dtbl.Rows[(dtbl.Rows.Count) - 1][0].ToString();
}
}
}
}