public LeaveDays SetLeaveDays(int CasualLeave, int SickLeave, int WorkingHours, string SessionId,
     string SessionValue)
 {
     var leaveDays = new LeaveDays {StatusText = "Session out, please login again"};
     CasualLeave = (CasualLeave == null) ? 0 : CasualLeave;
     SickLeave = (SickLeave == null) ? 0 : SickLeave;
     WorkingHours = (WorkingHours == null) ? 0 : WorkingHours;
     SessionId = LeaveRegisterUtils.DecryptPassword(SessionId);
     SessionValue = LeaveRegisterUtils.DecryptPassword(SessionValue);
     if (!DataBaseUtils.IsEmployeeLoggedIn(ConnectionString, SessionId, SessionValue))
     {
         return leaveDays;
     }
     var employeeid = DataBaseUtils.GetEmployeeId(ConnectionString, SessionId);
     if (!DataBaseUtils.IsAdminEmployee(ConnectionString, employeeid))
     {
         leaveDays.StatusText = "Leave configuration can be set only <b>Admin</b> employee";
         return leaveDays;
     }
     if (
         DataBaseUtils.SetLeaveConfigurationInformations(ConnectionString, SickLeave, CasualLeave, WorkingHours) !=
         "Success")
     {
         leaveDays.StatusText = "Some problem occure during setting the configuration, please try lator";
         return leaveDays;
     }
     return DataBaseUtils.GetLeaveConfigurationDetailes(ConnectionString);
 }
Beispiel #2
0
 /// <summary>
 /// Get leave configuration informations like casual, sick leaves and total working hours
 /// </summary>
 public static LeaveDays GetLeaveConfigurationDetailes(string ConnectionString)
 {
     var leavDays = new LeaveDays { StatusText = "Failed" };
     var con = new SqlConnection(ConnectionString);
     try
     {
         using (var cmd = new SqlCommand(StoreProcedureGetLeavesAndWorkingHours, con))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             con.Open();
             var dr = cmd.ExecuteReader();
             while (dr.Read())
             {
                 leavDays.CasualLeave = (int)dr["TotalCasualLeave"];
                 leavDays.SickLeave = (int)dr["ToatlSickLeave"];
                 leavDays.TotalWorkingHours = (int)dr["TotalWorkingHours"];
                 leavDays.StatusText = "Success";
             }
             con.Close();
         }
         return leavDays;
     }
     catch (Exception)
     {
         return leavDays;
     }
 }
 public LeaveDays GetLeaveDays(string SessionKey, string SessionValue)
 {
     var leaveDays = new LeaveDays {StatusText = "Session out, please login again"};
     SessionKey = LeaveRegisterUtils.DecryptPassword(SessionKey);
     SessionValue = LeaveRegisterUtils.DecryptPassword(SessionValue);
     if (!DataBaseUtils.IsEmployeeLoggedIn(ConnectionString, SessionKey, SessionValue))
     {
         return leaveDays;
     }
     var employeeId = DataBaseUtils.GetEmployeeId(ConnectionString, SessionKey);
     if (!DataBaseUtils.IsAdminEmployee(ConnectionString, employeeId))
     {
         leaveDays.StatusText = "Leave configuration data can be see only <b>Admin</b> employee";
         return leaveDays;
     }
     return DataBaseUtils.GetLeaveConfigurationDetailes(ConnectionString);
 }