Ejemplo n.º 1
0
 /// <summary>
 /// Get all home page updates in repect to email id
 /// </summary>
 public static Updates[] GetEmployeeUpdates(string ConnectionString, string EmployeeId)
 {
     var con = new SqlConnection(ConnectionString);
     try
     {
         using (var cmd = new SqlCommand(StoreProcedureGetUpdates, con))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@EmployeeID", SqlDbType.VarChar).Value = EmployeeId;
             con.Open();
             var totalUpdates = 0;
             var updatesList = cmd.ExecuteReader();
             while (updatesList.Read())
             {
                 totalUpdates += 1;
             }
             con.Close();
             var updates = new Updates[totalUpdates];
             con.Open();
             var dr = cmd.ExecuteReader();
             var i = 0;
             while (dr.Read())
             {
                 var update = new Updates
                 {
                     LeaveStatus = dr["LeaveStatus"].ToString(),
                     LeaveType = dr["LeaveAppliedType"].ToString(),
                     LeaveApproved = dr["LeaveApproved"].ToString(),
                     LeaveFrom = dr["LeaveAppliedFrom"].ToString(),
                     LeaveTill = dr["LeaveAppliedTo"].ToString(),
                     Status = "Success"
                 };
                 updates[i] = update;
                 i += 1;
             }
             return updates;
         }
     }
     catch (Exception)
     {
         var updates = new Updates[1];
         updates[0].Status = "Failed";
         return updates;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Get update by Id
 /// </summary>
 public static Updates GetUpdateById(string ConnectionString, int Id)
 {
     var con = new SqlConnection(ConnectionString);
     try
     {
         using (var cmd = new SqlCommand(StoreProcedureGetUpdateItemById, con))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@ID", SqlDbType.Int).Value = Id;
             con.Open();
             var dr = cmd.ExecuteReader();
             var update = new Updates();
             while (dr.Read())
             {
                 update.LeaveAppliedBy = dr["LeaveAppliedBy"].ToString();
                 update.LeaveType = dr["LeaveAppliedType"].ToString();
                 update.LeaveTill = dr["LeaveAppliedTo"].ToString();
                 update.LeaveFrom = dr["LeaveAppliedFrom"].ToString();
                 update.LeaveStatus = dr["LeaveStatus"].ToString();
                 update.TotalDays = (int)dr["TotalDays"];
                 update.Status = "Success";
             }
             con.Close();
             return update;
         }
     }
     catch (Exception)
     {
         return new Updates { Status = "Failed" };
     }
 }