Exemplo n.º 1
0
        public void Respond(LeaveRespond t)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;

            try
            {
                conn = DALHelper.CreateSqlDbConnection();
                cmd = new SqlCommand("usp_RespondLeaveRequest", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@LeaveRequestId", t.LeaveRequestId);
                cmd.Parameters.AddWithValue("@ResponseStatus", t.ResponseStatus);
                cmd.Parameters.AddWithValue("@ResponseDate", t.ResponseDate);
                cmd.Parameters.AddWithValue("@Notes", t.Notes);
                cmd.Parameters.AddWithValue("@ResponderId", t.ResponderId);
                cmd.Parameters.AddWithValue("@RequestProcessedBy", t.RequestProcessedBy);

                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
Exemplo n.º 2
0
        public LeaveRespond CheckLeaveStatus(int leaveRequestId, RequestsProcessedByEnum en)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;

            try
            {
                conn = DALHelper.CreateSqlDbConnection();
                cmd = new SqlCommand("usp_CheckLeaveStatus", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@LeaveRequestId", leaveRequestId);
                cmd.Parameters.AddWithValue("@RequestProcessedBy", en);

                SqlDataReader rdr = cmd.ExecuteReader();
                LeaveRespond respond = new LeaveRespond();
                if(rdr.Read())
                {
                    respond.Id = Convert.ToInt32(rdr["Id"]);
                    respond.LeaveRequestId = leaveRequestId;
                }
                    return respond;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
Exemplo n.º 3
0
 protected void DeclineButton_Click(object sender, EventArgs e)
 {
     LeaveRespond respond = new LeaveRespond();
     respond.LeaveRequestId = Convert.ToInt32(Request.QueryString["LeaveRequestId"]);
     respond.Notes = "";
     respond.ResponderId = new UserMapper().GetUserByUserName(UserPrincipal.Current.SamAccountName).EmployeeId;
     respond.ResponseDate = DateTime.Now;
     respond.ResponseStatus = RequestsEnum.Declined;
     new LeaveRespondMapper().Respond(respond);
     Response.Redirect("/HRM/Dashboard.aspx");
 }
Exemplo n.º 4
0
        protected void ProceedButton_Click(object sender, EventArgs e)
        {
            LeaveRequestView view = new LeaveRequestMapper().Get(Convert.ToInt32(Request.QueryString["LeaveRequestId"]));

            //What about if the alternate manager and hr are the same problem / we have a problem
            #warning Warning of design concerns

            if (view.AlternateEmployee == view.ManagerEmployee)
            {
                AproveAsAlternateAndManager();
            }
            else
            {
                LeaveRespond respond = new LeaveRespond();
                respond.LeaveRequestId = Convert.ToInt32(Request.QueryString["LeaveRequestId"]);
                respond.Notes = "";
                respond.ResponderId = new UserMapper().GetUserByUserName(UserPrincipal.Current.SamAccountName).EmployeeId;
                respond.ResponseDate = DateTime.Now;
                respond.ResponseStatus = RequestsEnum.Processed;

                if (view.AlternateEmployee == UserPrincipal.Current.SamAccountName)
                {
                    respond.RequestProcessedBy = RequestsProcessedByEnum.Alternate;
                }
                if (view.ManagerEmployee == UserPrincipal.Current.SamAccountName)
                {
                    respond.RequestProcessedBy = RequestsProcessedByEnum.Manager;
                }
                else
                {
                    respond.RequestProcessedBy = RequestsProcessedByEnum.HRM;
                }
                new LeaveRespondMapper().Respond(respond);
            }

            Response.Redirect("/HRM/Dashboard.aspx");
        }
Exemplo n.º 5
0
        private void AproveAsAlternateAndManager()
        {
            LeaveRespond respond = new LeaveRespond();
            respond.LeaveRequestId = Convert.ToInt32(Request.QueryString["LeaveRequestId"]);
            respond.Notes = "";
            respond.ResponderId = new UserMapper().GetUserByUserName(UserPrincipal.Current.SamAccountName).EmployeeId;
            respond.ResponseDate = DateTime.Now;
            respond.ResponseStatus = RequestsEnum.Processed;

            respond.RequestProcessedBy = RequestsProcessedByEnum.Alternate;
            new LeaveRespondMapper().Respond(respond);

            respond = new LeaveRespond();
            respond.LeaveRequestId = Convert.ToInt32(Request.QueryString["LeaveRequestId"]);
            respond.Notes = "";
            respond.ResponderId = new UserMapper().GetUserByUserName(UserPrincipal.Current.SamAccountName).EmployeeId;
            respond.ResponseDate = DateTime.Now;
            respond.ResponseStatus = RequestsEnum.Processed;

            respond.RequestProcessedBy = RequestsProcessedByEnum.Manager;
            new LeaveRespondMapper().Respond(respond);
        }