private void LeaveRequestbtn_Click(object sender, RoutedEventArgs e) { try { Console.WriteLine("in leave btn click"); /* int leaveRequestId; * leaveRequestId = Convert.ToInt32(txtLeaveId.Text);*/ string leaveType = txtLeaveType.Text; int noOfDays = Convert.ToInt32(txtNoOfDays.Text); int leaveBalance = Convert.ToInt32(txtLeaveBalance.Text); DateTime leaveDateFrom = LeaveDateFrom.SelectedDate.Value; //DateTime leaveDateFrom = new DateTime(2020, 09, 10); DateTime leaveDateTo = LeaveDateTo.SelectedDate.Value; string leaveStatus = "Pending"; int employeeId = Convert.ToInt32(txtEmployeeId.Text); int managerId = Convert.ToInt32(txtManagerId.Text); // asign value to leave class // leaveEntity.LeaveRequestID = leaveRequestId; LeaveEntity.LeaveType = leaveType; LeaveEntity.NoOfDays = noOfDays; LeaveEntity.LeaveBalance = leaveBalance; LeaveEntity.Leave_Date_From = leaveDateFrom; LeaveEntity.LeaveDateTo = leaveDateTo; LeaveEntity.LeaveStatus = leaveStatus; LeaveEntity.EmployeeID = employeeId; LeaveEntity.ManagerID = EmployeeEntity.ManagerID; Console.WriteLine(leaveEntity); bool requestStatus = leaveBLL.LeaveRequestBLL(leaveEntity); if (requestStatus == true) { this.Close(); MessageBox.Show("Leave Requested Successfully"); } else { MessageBox.Show("Something is wrong..check your details again.."); } Console.WriteLine(leaveDateFrom); } catch (Exception exception) { Console.WriteLine("Something Went Wrong." + exception.Message); } }