private void changePassword_btn_Click(object sender, EventArgs e) { String getNIC = Login.setNIC; if (Login.setpassword == currentPassword_txt.Text) { if (newPassword_txt.Text == confirmPassword_txt.Text) { con.Open(); cmd = new SqlCommand("update Staff_Mang_Table set password= '******' where NIC = @getNIC", con); cmd.Parameters.Add("@getNIC", SqlDbType.VarChar).Value = getNIC; cmd.ExecuteNonQuery(); SuccessfullMessageBox.ShowDialog("Password Update Successfully !!!", "Confirmation Message"); con.Close(); } else { ErrorDialogBox.ShowDialog("Confirm Password Does't macth with new Password!!!", "New Password Invaild"); newPassword_txt.Text = ""; confirmPassword_txt.Text = ""; } } else { ErrorDialogBox.ShowDialog("Current Password does not match.!!!", "Current Password Invaild"); } }
private void delete_Click(object sender, EventArgs e) { String temNic = ""; temNic = nictxt.Text; Boolean ans = checkNIC(temNic); if (temNic == "") { // MessageBox.Show("Pleace Insert NIC!!!"); ErrorDialogBox.ShowDialog("Pleace Insert NIC!!!", "Validation Error"); } else if (ans != true) { ErrorDialogBox.ShowDialog("Invalid NIC. Please enter Registerd NIC", "Validation Error"); } else { con.Open(); cmd = new SqlCommand("Delete from Staff_Mang_Table where NIC = '" + nictxt.Text + "'", con); cmd.ExecuteNonQuery(); SuccessfullMessageBox.ShowDialog("Delere Records Successfully!!!", "Confirmation Message"); // MessageBox.Show("Delere Records Successfully!!!"); con.Close(); display(); clearallData(); } }
//Update Recode void iIncome.UpdateIncomeRecode(cIncome Income) { if (Income.IncomeID > 0) { SqlCommand cmd = new SqlCommand("UPDATE incomePayment SET incomeUnitName = @IUName, incomeType = @IncomeType, incomeAmount = @IncomeAmount, incomeDate = @IncomeDate, incomeDescription = @IncomeDescription WHERE incomeID = @IID", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@IUName", Income.incomeUnitName); cmd.Parameters.AddWithValue("@IncomeType", Income.incomeType); cmd.Parameters.AddWithValue("@IncomeAmount", Income.incomeAmount); cmd.Parameters.AddWithValue("@IncomeDate", Income.incomeDate); cmd.Parameters.AddWithValue("@IncomeDescription", Income.incomeDescription); cmd.Parameters.AddWithValue("@IID", Income.IncomeID); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("A New Expenses Recode is Update Successfully", "Successfully Inserted"); InUC.Show(); } else { // InUC.Hide(); ErrorDialogBox.ShowDialog("Please Select a Expenses Recode to Update", "Error"); // InUC.Show(); } }
//Update Recode void iExpenses.UpdateExpensesRecode(cExpenses Expenses) { if (Expenses.expensesID > 0) { SqlCommand cmd = new SqlCommand("UPDATE expensesPayment SET expensesUnitName = @EUName, expensesType = @ExpensesType, expensesAmount = @ExpensesAmount, expensesDate = @ExpensesDate, expensesDescription = @ExpensesDescription WHERE expensesID = @EID", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@EUName", Expenses.expensesUnitName); cmd.Parameters.AddWithValue("@ExpensesType", Expenses.expensesType); cmd.Parameters.AddWithValue("@ExpensesAmount", Expenses.expensesAmount); cmd.Parameters.AddWithValue("@ExpensesDate", Expenses.expensesDate); cmd.Parameters.AddWithValue("@ExpensesDescription", Expenses.expensesDescription); cmd.Parameters.AddWithValue("@EID", Expenses.expensesID); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("A New Expenses Recode is Update Successfully", "Successfully Inserted"); InUC.Show(); } else { InUC.Hide(); ErrorDialogBox.ShowDialog("Please Select a Expenses Recode to Update", "Error"); InUC.Show(); } }
private void cancelbtn_Click(object sender, EventArgs e) { if (staffnicLabel.Text == null || typeLable.Text == null) { ErrorDialogBox.ShowDialog("Please double click one rquest from table First", "Invaild Data"); } else { con.Open(); cmd = new SqlCommand("Delete from staff_Temp_Request_Leaves where sid = @sid", con); cmd.Parameters.Add("@sid", SqlDbType.Int).Value = sid; cmd.ExecuteNonQuery(); con.Close(); SuccessfullMessageBox.ShowDialog("Request Cancle Successfully !!!", "Confirmation Message"); String cancleby = Login.setNIC; con.Open(); cmd = new SqlCommand("insert into staff_cancle_Leaves (NIC, type, reason, date, cancleby)values('" + staffnicLabel.Text + "', '" + typeLable.Text + "', '" + reasonLable.Text + "', '" + dateLable.Text + "', @approveby)", con); cmd.Parameters.Add("@approveby", SqlDbType.VarChar).Value = cancleby; cmd.ExecuteNonQuery(); con.Close(); cleareText(); } }
private void btnEnd_Click(object sender, EventArgs e) { SqlCommand cmd3 = new SqlCommand("UPDATE StaffAttendance1 SET swipeOutTime = @SwipeOutTime WHERE userID = @IDNumber AND date = @AttendDate", con); cmd3.Parameters.AddWithValue("@IDNumber", txtUserId.Text); cmd3.Parameters.AddWithValue("@AttendDate", AttendDate); cmd3.Parameters.AddWithValue("@SwipeOutTime", AttendTime); con.Open(); cmd3.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("Attendance Leave Time Successfully", "Successfully Inserted"); InUC.Show(); }
//Insert Recode void iIncome.InsertIncomeRecode(cIncome Income) { SqlCommand cmd = new SqlCommand("INSERT INTO incomePayment VALUES (@IUName, @IncomeType, @IncomeAmount, @IncomeDate, @IncomeDescription)", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@IUName", Income.incomeUnitName); cmd.Parameters.AddWithValue("@IncomeType", Income.incomeType); cmd.Parameters.AddWithValue("@IncomeAmount", Income.incomeAmount); cmd.Parameters.AddWithValue("@IncomeDate", Income.incomeDate); cmd.Parameters.AddWithValue("@IncomeDescription", Income.incomeDescription); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("A New Expenses Recode is Insert Successfully", "Successfully Inserted"); InUC.Show(); }
//Insert Recode void iExpenses.InsertExpensesRecode(cExpenses Expenses) { SqlCommand cmd = new SqlCommand("INSERT INTO expensesPayment VALUES (@EUName, @ExpensesType, @ExpensesAmount, @ExpensesDate, @ExpensesDescription)", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@EUName", Expenses.expensesUnitName); cmd.Parameters.AddWithValue("@ExpensesType", Expenses.expensesType); cmd.Parameters.AddWithValue("@ExpensesAmount", Expenses.expensesAmount); cmd.Parameters.AddWithValue("@ExpensesDate", Expenses.expensesDate); cmd.Parameters.AddWithValue("@ExpensesDescription", Expenses.expensesDescription); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("A New Expenses Recode is Insert Successfully", "Successfully Inserted"); InUC.Show(); }
private void btnStart_Click(object sender, EventArgs e) { GetDate(); if (DBUserID == null) { SqlCommand cmd2 = new SqlCommand("INSERT INTO StaffAttendance1 VALUES(@IDNumber, @AttendDate, @SwipeInTime, null) ", con); cmd2.CommandType = CommandType.Text; cmd2.Parameters.AddWithValue("@IDNumber", txtUserId.Text); cmd2.Parameters.AddWithValue("@AttendDate", AttendDate); cmd2.Parameters.AddWithValue("@SwipeInTime", AttendTime); con.Open(); cmd2.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("Attendance Start Time Successfully", "Successfully Inserted"); InUC.Show(); } }
//Delete Recode void iIncome.DeleteIncomeRecode(cIncome Income) { if (Income.IncomeID > 0) { SqlCommand cmd = new SqlCommand("DELETE FROM incomePayment WHERE incomeID = @IID", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@IID", Income.IncomeID); con.Open(); cmd.ExecuteNonQuery(); con.Close(); InUC.Hide(); SuccessfullMessageBox.ShowDialog("Expenses Recode is Delete Successfully", "Successfully Deleted"); InUC.Show(); } else { InUC.Hide(); ErrorDialogBox.ShowDialog("Please Select a Expenses Recode to Delete", "Error"); InUC.Show(); } }
public void updateData() { // ======= Validation =========== if (fnametxt.Text == "") { fnametxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("First name is Requied.", "Validation Error"); fnametxt.Focus(); return; } if (lnametxt.Text == "") { lnametxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Last name is Requied.", "Validation Error"); lnametxt.Focus(); return; } if (tpnotxt.Text == "") { tpnotxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Telephone No is Requied.", "Validation Error"); tpnotxt.Focus(); return; } else { Regex regtp = new Regex(@"^\d{10}$"); if (!regtp.IsMatch(tpnotxt.Text)) { tpnotxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Telephone must containt 10 numbers and NO Alpebetic Letters", "Validation Error"); tpnotxt.Focus(); return; } } if (emailtxt.Text == "") { emailtxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Email is Requied.", "Validation Error"); emailtxt.Focus(); return; } else { Regex regEmail = new Regex(@"^(([^<>()[\]\\.,;:\s@\""]+" + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@" + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+" + @"[a-zA-Z]{2,}))$", RegexOptions.Compiled); if (!regEmail.IsMatch(emailtxt.Text)) { emailtxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Please Insert Valid Email Requied.", "Validation Error"); emailtxt.Focus(); return; } } if (address1txt.Text == "") { address1txt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Addres line 01 is Requied.", "Validation Error"); address1txt.Focus(); return; } if (address2txt.Text == "") { address2txt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Addres line 02 is Requied.", "Validation Error"); address2txt.Focus(); return; } if (address3txt.Text == "") { address3txt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Addres line 03 is Requied.", "Validation Error"); address3txt.Focus(); return; } if (nictxt.Text == "") { nictxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("NIC is Requied.", "Validation Error"); nictxt.Focus(); return; } else { Regex regNIC = new Regex(@"^[0-9]{9}[vV]$"); if (!regNIC.IsMatch(nictxt.Text)) { nictxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("NIC must containt 9 numbers and 'V' or 'v' at the last.", "Validation Error"); nictxt.Focus(); return; } } if (passwordtxt.Text == "") { passwordtxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Password is Requied.", "Validation Error"); passwordtxt.Focus(); return; } String temNic = nictxt.Text; Boolean ans = checkNIC(temNic); if (ans != true) { ErrorDialogBox.ShowDialog("Invalid NIC. Please enter Registerd NIC", "Validation Error"); } else { MemoryStream ms = new MemoryStream(); profile_picxtxt.Image.Save(ms, profile_picxtxt.Image.RawFormat); byte[] image = ms.ToArray(); con.Open(); cmd = new SqlCommand("update Staff_Mang_Table set title = '" + titletxt.Text + "', fname = '" + fnametxt.Text + "', lname = '" + lnametxt.Text + "', gender = '" + gendertxt.Text + "',tpno = '" + tpnotxt.Text + "', email = '" + emailtxt.Text + "', address1 = '" + address1txt.Text + "', address2 = '" + address2txt.Text + "', address3 = '" + address3txt.Text + "', qualification = '" + qualificationtxt.Text + "', accountType = '" + atypetxt.Text + "', password = '******', startdate = '" + sdatetxt.Text + "', photo = @photo where NIC = '" + nictxt.Text + "'", con); cmd.Parameters.Add("@photo", SqlDbType.VarBinary).Value = image; cmd.ExecuteNonQuery(); SuccessfullMessageBox.ShowDialog("Update Successfully !!!", "Confirmation Message"); // MessageBox.Show("Update Successfully !!!"); con.Close(); display(); clearallData(); } }
//Insert Data to the DataBase private void Insert_Click(object sender, EventArgs e) { // ======= Validation =========== if (fnametxt.Text == "") { fnametxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("First name is Requied.", "Validation Error"); fnametxt.Focus(); return; } if (lnametxt.Text == "") { lnametxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Last name is Requied.", "Validation Error"); lnametxt.Focus(); return; } if (tpnotxt.Text == "") { tpnotxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Telephone No is Requied.", "Validation Error"); tpnotxt.Focus(); return; } else { Regex regtp = new Regex(@"^\d{10}$"); if (!regtp.IsMatch(tpnotxt.Text)) { tpnotxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Telephone must containt 10 numbers and NO Alpebetic Letters", "Validation Error"); tpnotxt.Focus(); return; } } if (emailtxt.Text == "") { emailtxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Email is Requied.", "Validation Error"); emailtxt.Focus(); return; } else { Regex regEmail = new Regex(@"^(([^<>()[\]\\.,;:\s@\""]+" + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@" + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+" + @"[a-zA-Z]{2,}))$", RegexOptions.Compiled); if (!regEmail.IsMatch(emailtxt.Text)) { emailtxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Please Insert Valid Email Requied.", "Validation Error"); emailtxt.Focus(); return; } } if (address1txt.Text == "") { address1txt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Addres line 01 is Requied.", "Validation Error"); address1txt.Focus(); return; } if (address2txt.Text == "") { address2txt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Addres line 02 is Requied.", "Validation Error"); address2txt.Focus(); return; } if (address3txt.Text == "") { address3txt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Addres line 03 is Requied.", "Validation Error"); address3txt.Focus(); return; } if (nictxt.Text == "") { nictxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("NIC is Requied.", "Validation Error"); nictxt.Focus(); return; } else { Regex regNIC = new Regex(@"^[0-9]{9}[vV]$"); if (!regNIC.IsMatch(nictxt.Text)) { nictxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("NIC must containt 9 numbers and 'V' or 'v' at the last.", "Validation Error"); nictxt.Focus(); return; } } if (passwordtxt.Text == "") { passwordtxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Password is Requied.", "Validation Error"); passwordtxt.Focus(); return; } //Image MemoryStream ms = new MemoryStream(); profile_picxtxt.Image.Save(ms, profile_picxtxt.Image.RawFormat); image = ms.ToArray(); String temNic = nictxt.Text; Boolean ans = checkNIC(temNic); if (ans == true) { ErrorDialogBox.ShowDialog("This Employee Already Registered!!!Pleace Register another Employee.", "Validation Error"); } else { con.Open(); cmd = new SqlCommand("INSERT INTO Staff_Mang_Table VALUES('" + nictxt.Text + "','" + titletxt.Text + "','" + fnametxt.Text + "','" + lnametxt.Text + "','" + gendertxt.Text + "','" + tpnotxt.Text + "','" + emailtxt.Text + "','" + address1txt.Text + "','" + address2txt.Text + "','" + address3txt.Text + "','" + qualificationtxt.Text + "','" + atypetxt.Text + "','" + passwordtxt.Text + "','" + sdatetxt.Text + "', @photo)", con); cmd.Parameters.Add("@photo", SqlDbType.VarBinary).Value = image; cmd.ExecuteNonQuery(); SuccessfullMessageBox.ShowDialog("Registration Successfully.", "Confirmation Message"); con.Close(); display(); } }
private void requestlvbtn_Click(object sender, EventArgs e) { if (reasontxt.Text == "") { reasontxt.BackColor = Color.Red; ErrorDialogBox.ShowDialog("Reason is Requied.", "Validation Error"); reasontxt.Focus(); return; } if (typetxt.Text == "Casual_Leave") { if (casual > 0) { con.Open(); cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con); cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2; cmd.ExecuteNonQuery(); con.Close(); displayleave(); SuccessfullMessageBox.ShowDialog("Casual Leave Request is Applly Successfully !!!", "Confirmation Message"); } else { ErrorDialogBox.ShowDialog("Sorry!!! All alocated Casual Leaves Are Used this Month.", "No Leaves"); // MessageBox.Show("Sorry!!! All alocated Casual Leaves Are Used."); } } else if (typetxt.Text == "HalfDay_Leave") { if (casual > 0) { con.Open(); cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con); cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2; cmd.ExecuteNonQuery(); // MessageBox.Show("Leaves Pending!!!"); con.Close(); displayleave(); // MessageBox.Show("Half Day Leave Request is Applly Successfully !!!"); SuccessfullMessageBox.ShowDialog("Half Day Leave Request is Applly Successfully !!!", "Confirmation Message"); } else { ErrorDialogBox.ShowDialog("Sorry!!! All alocated Half Day Leaves Are Used this Month.", "No Leaves"); //MessageBox.Show("Sorry!!! All alocated Half Day Leaves Are Used this Month."); } } else if (typetxt.Text == "Medical_Leave") { if (medical > 0) { con.Open(); cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con); cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2; cmd.ExecuteNonQuery(); con.Close(); displayleave(); SuccessfullMessageBox.ShowDialog("Medical_Leave Leave Request is Applly Successfully !!!", "Confirmation Message"); // MessageBox.Show("Medical Leave Request is Applly Successfully !!!"); // Payment.SuccessDialogBox.ShowDialog("Medical_Leave Request is Applly Successfully !!!", "Successfull Message"); } else { ErrorDialogBox.ShowDialog("Sorry!!! All alocated Medical Leaves Are Used this Month.", "No Leaves"); // MessageBox.Show("Sorry!!! All alocated Medical Leaves Are Used this Month."); } } else if (typetxt.Text == "Short_Leave") { if (shortleave > 0) { con.Open(); cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con); cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2; cmd.ExecuteNonQuery(); // MessageBox.Show("Leaves Pending!!!"); con.Close(); displayleave(); //Payment.SuccessDialogBox.ShowDialog("shortleaves Request is Applly Successfully !!!", "Successfull Message"); // MessageBox.Show("shortleaves Request is Applly Successfully !!!"); SuccessfullMessageBox.ShowDialog("shortleaves Leave Request is Applly Successfully !!!", "Confirmation Message"); } else { ErrorDialogBox.ShowDialog("Sorry!!! All alocated shortleaves Leaves Are Used this Month.", "No Leaves"); // MessageBox.Show("Sorry!!! All alocated Half Day Leaves Are Used this Month."); } } else { ErrorDialogBox.ShowDialog("Sorry!!! No ", " Invaild Type"); MessageBox.Show("Invaild type !!!"); } reasontxt.Text = ""; typetxt.SelectedIndex = -1; }
private void confirmbtn_Click(object sender, EventArgs e) { if (staffnicLabel.Text == null || typeLable.Text == null) { ErrorDialogBox.ShowDialog("Please double click one rquest from table First", "Invaild Data"); } else { String approveby = Login.setNIC; con.Open(); cmd = new SqlCommand("insert into staff_Approve_Leaves values('" + staffnicLabel.Text + "', '" + typeLable.Text + "', '" + reasonLable.Text + "', '" + dateLable.Text + "', @approveby)", con); cmd.Parameters.Add("@approveby", SqlDbType.VarChar).Value = approveby; cmd.ExecuteNonQuery(); SuccessfullMessageBox.ShowDialog("Leave Approved", "Confirmation Message"); con.Close(); con.Open(); cmd = new SqlCommand("Delete from staff_Temp_Request_Leaves where sid = @sid", con); cmd.Parameters.Add("@sid", SqlDbType.Int).Value = sid; cmd.ExecuteNonQuery(); con.Close(); displayleaveReuest(); getLeaves(); if (typeLable.Text == "Casual_Leave") { casual = casual - 1; con.Open(); cmd = new SqlCommand("update staff_Leaves set Casual_Leave = @Casual_Leave where NIC = '" + staffnicLabel.Text + "' ", con); cmd.Parameters.Add("@Casual_Leave", SqlDbType.Int).Value = (int)casual; cmd.ExecuteNonQuery(); con.Close(); } else if (typeLable.Text == "Medical_Leave") { medical = medical - 1; con.Open(); cmd = new SqlCommand("update staff_Leaves set Medical_Leave = @Medical_Leave where NIC = '" + staffnicLabel.Text + "' ", con); cmd.Parameters.Add("@Medical_Leave", SqlDbType.Int).Value = (int)medical; cmd.ExecuteNonQuery(); con.Close(); } else if (typeLable.Text == "Short_Leave") { shortleave = shortleave - 1; con.Open(); cmd = new SqlCommand("update staff_Leaves set Short_Leave = @Short_Leave where NIC = '" + staffnicLabel.Text + "' ", con); cmd.Parameters.Add("@Short_Leave", SqlDbType.Int).Value = (int)shortleave; cmd.ExecuteNonQuery(); con.Close(); } else if (typeLable.Text == "HalfDay_Leave") { halfday = halfday + 1; con.Open(); cmd = new SqlCommand("update staff_Leaves set HalfDay_Leave = @HalfDay_Leave where NIC = '" + staffnicLabel.Text + "' ", con); cmd.Parameters.Add("@HalfDay_Leave", SqlDbType.Int).Value = (int)halfday; cmd.ExecuteNonQuery(); con.Close(); /////////////////// if (halfday % 2 == 0) { casual = casual - 1; con.Open(); cmd = new SqlCommand("update staff_Leaves set Casual_Leave = @Casual_Leave where NIC = '" + staffnicLabel.Text + "' ", con); cmd.Parameters.Add("@Casual_Leave", SqlDbType.Int).Value = (int)casual; cmd.ExecuteNonQuery(); con.Close(); } } } cleareText(); }