示例#1
0
 public static string GetUsersEmailAdd(string RoleName, int Location)
 {
     try
     {
         string to = "";
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             var urs = from u in db.Users
                       where u.RoleName == RoleName && u.LocationID == Location
                       select u;
             if (urs.Count() > 0)
             {
                 foreach (User us in urs)
                 {
                     to += us.Email + ",";
                 }
                 to = to.TrimEnd(new char[] { ',' });
             }
         }
         return(to);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static bool UpdateUserById(int Id, bool status)
 {
     try
     {
         bool result = false;
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             var usr = (from p in db.Users
                        where p.ID == Id
                        select p).FirstOrDefault();
             if (status)
             {
                 usr.isActive = false;
             }
             else
             {
                 usr.isActive = true;
             }
             db.SaveChanges();
             result = true;
         }
         return(result);
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
示例#3
0
        public static string GetBatchID()
        {
            try
            {
                int bId = 0; string BatchID = "";
                using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
                {
                    var b = from p in db.Batches select p;
                    if (b.Count() > 0)
                    {
                        foreach (Batch bb in b)
                        {
                            bId            = bb.LastBatchNo.Value;
                            bb.LastBatchNo = bId + 1;
                            break;
                        }
                    }
                    else
                    {
                        Batch bbnew = new Batch();
                        bbnew.LastBatchNo = 1;
                        bId = 1;
                        db.Batches.Add(bbnew);
                    }
                    db.SaveChanges();
                }

                BatchID = "Batch " + bId.ToString().PadLeft(5, '0');
                return(BatchID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
 public static FleetLocation GetFleetLocation(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.FleetLocations.Find(Id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
 public static IEnumerable <FleetLocation> GetFleetLocationList()
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.FleetLocations.OrderBy(o => o.Name).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#6
0
 public static TrackerCompany GetTrackerCompany(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.TrackerCompanies.Find(Id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#7
0
 public static IEnumerable <TrackerCompany> GetTrackerCoyList()
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.TrackerCompanies.OrderBy(o => o.Name).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#8
0
 public static IEnumerable <VehicleMaker> GetVehicleMakerList()
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.VehicleMakers.OrderBy(o => o.Name).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#9
0
 public static Department GetDepartment(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.Departments.Find(Id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#10
0
 public static List <IncidentLog> GetIncidenceLogList(int location)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.IncidentLogs.Include("VehicleIncidenceType").Include("Driver").Include("Vehicle").Where(d => d.Vehicle.LocationID == location).OrderByDescending(d => d.DateAdded).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static Driver GetDriver(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.Drivers.Find(Id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static Vehicle GetVehicle(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.Vehicles.Find(Id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#13
0
 public static IncidentLog GetIncidence(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.IncidentLogs.Find(Id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static List <Trip> GetTripListByID(int Id)
 {
     try
     {
         using (var db = new FleetMgtSysDBEntities())
         {
             return(db.Trips.Include("User").Include("User1").Include("User2").Include("Vehicle.Driver").Include("Vehicle").Include("Department").Where(t => t.ID == Id).OrderByDescending(p => p.DateAdded).ToList());
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static User GetByID(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             return(db.Users.Find(Id));
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static Trip GetTripDetailByID(int Id)
 {
     try
     {
         using (var db = new FleetMgtSysDBEntities())
         {
             return(db.Trips.Find(Id));
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static List <User> GetUsersList()
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             var usrList = from p in db.Users.Include("FleetLocation") select p;
             return(usrList.ToList <User>());
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
示例#18
0
 public static bool AddSmsNotification(SmsNotification sms)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.SmsNotifications.Add(sms);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#19
0
 public static bool AddIncidence(IncidentLog incident)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.IncidentLogs.Add(incident);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         // Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static bool AddUser(User usr)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.Users.Add(usr);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
示例#21
0
 public static bool AddTrackerCompany(TrackerCompany coy)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.TrackerCompanies.Add(coy);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         // Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
示例#22
0
 public static bool AddDepartment(Department dept)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.Departments.Add(dept);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         // Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
示例#23
0
 public static bool AddDriverEmployer(DriverEmployer coy)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.DriverEmployers.Add(coy);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         // Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static bool AddVehicle(Vehicle vehicle)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.Vehicles.Add(vehicle);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         // Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static IEnumerable <Trip> GetFleetRequestApprovedByUser(int userId, int status)
 {
     try
     {
         using (var db = new FleetMgtSysDBEntities())
         {
             var q = from p in db.Trips.Include("User").Include("Department")
                     where p.ApproverIDLeve1 == userId && p.Status > status
                     select p;
             return(q.OrderByDescending(p => p.DateAdded).ToList());
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
示例#26
0
        public static List <User> GetUserDeptApprovers(string deptName, string username, int location)
        {
            try
            {
                using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
                {
                    var urs = from u in db.Users
                              where u.DepartmentName.Trim() == deptName.Trim() && u.RoleName == DeptApprRoleName && u.StaffID != username && u.LocationID == location
                              select u;

                    return(urs.ToList());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public static IEnumerable <Trip> GetFleetRequestByUser(string username)
 {
     try
     {
         using (var db = new FleetMgtSysDBEntities())
         {
             var q = from p in db.Trips.Include("User").Include("Department")
                     where p.InitiatorID == username
                     select p;
             return(q.ToList());
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static User GetUserByUserName(string username)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             var user = from usr in db.Users.Include("FleetLocation")
                        where usr.StaffID == username
                        select usr;
             return(user.FirstOrDefault <User>());
         }
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static List <User> GetUserByID(int Id)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             var user = from usr in db.Users.Include("FleetLocation")
                        where usr.ID == Id
                        select usr;
             return(user.ToList <User>());
         }
         // return null;
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
 public static bool UpdateUser(User usr)
 {
     try
     {
         bool retVal = false;
         using (var db = new FleetMgtSysDBEntities())
         {
             db.Entry(usr).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             retVal = true;
         }
         return(retVal);
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.InnerException);
         throw ex;
     }
 }