Esempio n. 1
0
 private bool CheckDeleteActionPermission(User _User)
 {
     if (_User.CanDelete == true)
         return true;
     else
         return false;
 }
Esempio n. 2
0
 private bool CheckCreateActionPermission(User _User)
 {
     if (_User.CanAdd == true)
         return true;
     else
         return false;
 }
Esempio n. 3
0
        public string CheckForUserRole(User user)
        {
            string val = "";
            using (var ctx = new TAS2013Entities())
            {
                string criteria = ctx.UserAccesses.Where(aa => aa.UserID == user.UserID).FirstOrDefault().Criteria;
                switch (criteria.Trim())
                {
                    case "Z":
                        val = "Zone";
                        break;

                    case "R":
                        val="Region";
                        break;
                    case "C":
                        val = "City";
                        break;
                    case "L":
                        val = "Location";
                        break;
                        case "S":
                        val = "SuperUser";
                        break;
                }
                ctx.Dispose();
            }
            return val;
        }
Esempio n. 4
0
 private bool CheckDetailActionPermission(User _User)
 {
     if (_User.CanView == true)
         return true;
     else
         return false;
 }
Esempio n. 5
0
 public static bool CheckforPermission(User _User, ReportName _report)
 {
     bool check = false;
     try
     {
         switch (_report)
         {
             case ReportName.Audit:
                 if (_User.MRAudit == true)
                     check = true;
                 break;
             case ReportName.Daily:
                 if (_User.MRDailyAtt == true)
                     check = true;
                 break;
             case ReportName.Detail:
                 if (_User.MRDetail == true)
                     check = true;
                 break;
             case ReportName.Employee:
                 if (_User.MREmployee == true)
                     check = true;
                 break;
             case ReportName.Grpah:
                 if (_User.MRGraph == true)
                     check = true;
                 break;
             case ReportName.Leave:
                 if (_User.MRLeave == true)
                     check = true;
                 break;
             case ReportName.ManualAtt:
                 if (_User.MRManualEditAtt == true)
                     check = true;
                 break;
             case ReportName.Monthly:
                 if (_User.MRMonthly == true)
                     check = true;
                 break;
             case ReportName.Summary:
                 if (_User.MRSummary == true)
                     check = true;
                 break;
         }
     }
     catch (Exception ex)
     {
         check = false;
     }
     return check;
 }
Esempio n. 6
0
        public string MakeCustomizeQuery(User _user)
        {
            string query = " where ";
            string subQuery = "";
            string subQueryLoc = "";
            List<string> _Criteria = new List<string>();
            List<string> _CriteriaForOr = new List<string>();
            List<string> _CriteriaForOrLoc = new List<string>();
               TAS2013Entities db = new TAS2013Entities();
            List<UserAccess> ulocs = new List<UserAccess>();
            ulocs = db.UserAccesses.Where(aa => aa.UserID == _user.UserID).ToList();
            foreach (var uloc in ulocs)
            {
                if(uloc.Criteria.Trim() == "Z")
                _CriteriaForOrLoc.Add(" ZoneID = " + uloc.CriteriaData + " ");
                if (uloc.Criteria.Trim() == "R")
                    _CriteriaForOrLoc.Add(" RegionID = " + uloc.CriteriaData + " ");
                if (uloc.Criteria.Trim() == "C")
                    _CriteriaForOrLoc.Add(" CityID = " + uloc.CriteriaData + " ");
                if (uloc.Criteria.Trim() == "L")
                    _CriteriaForOrLoc.Add(" LocID = " + uloc.CriteriaData + " ");
                if (uloc.Criteria.Trim() == "S")
                    query = "";
                if (uloc.Criteria.Trim() == "")
                {

                    query = "";
                return query;

                }
            }

            for (int i = 0; i < _CriteriaForOrLoc.Count - 1; i++)
            {
                subQueryLoc = subQueryLoc + _CriteriaForOrLoc[i] + " or ";
            }
            if(_CriteriaForOrLoc.Count>0)
            subQueryLoc = " ( " + subQueryLoc + _CriteriaForOrLoc[_CriteriaForOrLoc.Count - 1] + " ) ";

            //subQuery = " ( ";
            //for (int i = 0; i < _CriteriaForOr.Count - 1; i++)
            //{
            //    subQuery = subQuery + _CriteriaForOr[i] + " or ";
            //} if (_CriteriaForOr.Count > 0)
            //subQuery = subQuery + _CriteriaForOr[_CriteriaForOr.Count - 1];
            //subQuery = subQuery + " ) ";
            query = query + subQueryLoc;
            return query;
        }
Esempio n. 7
0
 public string QueryForCompanyFilters(User _User)
 {
     string query = "";
     switch (_User.RoleID)
     {
         case 1:
             break;
         case 2:
             query = " where CompanyID= 1 or CompanyID = 2 ";
             break;
         case 3:
             query = " where  CompanyID>= 3";
             break;
         case 4:
             query = " where  CompanyID = " + _User.CompanyID.ToString();
             break;
         case 5:
             break;
     }
     return query;
 }
Esempio n. 8
0
        public string MakeCustomizeQueryForUserAccess(User _user)
        {
            TAS2013Entities db = new TAS2013Entities();
            string query = "where";
            List<UserAccess> uAcc = new List<UserAccess>();
            uAcc = db.UserAccesses.Where(aa => aa.UserID == _user.UserID).ToList();
            foreach (var access in uAcc)
            {
                if (access.Criteria.Contains("L"))
                    query = query + " LocID = " + access.CriteriaData + " ";
                 if (access.Criteria.Contains("S"))
                       query = query + " LocID>0";

            }
            return query;
        }
Esempio n. 9
0
 private void LoadShiftGrid(User _loggedUser)
 {
     List<Shift> _objectList = new List<Shift>();
     _objectList = context.Shifts.Where(aa => aa.CompanyID == _loggedUser.CompanyID).ToList();
     //_Query = "SELECT * FROM TAS2013.dbo.EmpType where " + selectSQL;
     //grid_EmpType.DataSource = GetValuesFromDatabase(_Query, "EmpType");
     //grid_EmpType.DataBind();
     grid_Shift.DataSource = _objectList;
     grid_Shift.DataBind();
 }
Esempio n. 10
0
 private void LoadSectionGrid(User _loggedUser)
 {
     QueryBuilder qb = new QueryBuilder();
     string query = qb.QueryForCompanySegeration(_loggedUser);
     DataTable dt = qb.GetValuesfromDB("select * from ViewSection " + query);
     List<ViewSection> _View = dt.ToList<ViewSection>();
     grid_Section.DataSource = _View;
     grid_Section.DataBind();
 }
Esempio n. 11
0
 private void LoadShiftView(User _loggedUser)
 {
 }
Esempio n. 12
0
        public string QueryForUserAccess(User _User, string view)
        {
            string role="";
             string  query = "";
            using (var context = new TAS2013Entities())
                    {
                        role = context.UserRoles.Where(aa => aa.RoleID == _User.RoleID).FirstOrDefault().RoleName;
                    }

            switch (view)
            {
                case "Region":  query= UserAcccessGetRegion(_User,role);
                    return query;
                case "Zone": query = UserAcccessGetZone(_User, role);
                    return query;
                case "Location": query = UserAcccessGetLocation(_User, role);
                    return query;
                case "City": query = UserAccessGetCity(_User, role);
                    return query;
                case "SuperUser": query = "CompanyID >0";
                    return query;

            }
            return query;
        }
Esempio n. 13
0
        internal string QueryForReportsCity(User LoggedInUser, string p)
        {
            string query = " where ";
            TAS2013Entities db = new TAS2013Entities();
            List<UserAccess> uAcc = new List<UserAccess>();
            uAcc = db.UserAccesses.Where(aa => aa.UserID == LoggedInUser.UserID).ToList();
            List<Region> regions = db.Regions.ToList();
            List<City> cities = db.Cities.ToList();
            List<Location> locs = db.Locations.ToList();
            List<string> queryList = new List<string>();
            foreach (var access in uAcc)
            {
                switch (LoggedInUser.RoleID)
                {
                    case 1://Super ADmin
                        query = "";
                        break;
                    case 4://Zone
                        List<City> city = db.Cities.Where(aa => aa.Region.ZoneID== access.CriteriaData).ToList();
                        foreach (var c in city)
                        {
                            queryList.Add(" CityID =" + c.CityID);
                        }

                        break;
                    case 5://REgion
                        city = db.Cities.Where(aa => aa.RegionID == access.CriteriaData).ToList();
                        foreach (var c in city)
                        {
                            queryList.Add(" CityID =" + c.CityID);
                        }
                        break;
                    case 6://City
                        string cityID = cities.Where(aa => aa.CityID == access.CriteriaData).FirstOrDefault().CityID.ToString();
                        queryList.Add(" CityID =" + cityID);
                        break;
                    case 7://Location
                        string cityIDForLoc = locs.Where(aa => aa.LocID == access.CriteriaData).FirstOrDefault().CityID.ToString();
                        queryList.Add(" CityID =" + cityIDForLoc);
                        break;
                }
            }
            if (queryList.Count == 1)
            {
                query = query + queryList[0];
            }
            else if (queryList.Count > 1)
            {
                for (int i = 0; i < queryList.Count - 1; i++)
                {
                    query = query + queryList[i] + " or ";
                }
                query = query + queryList[queryList.Count - 1];
            }

            return query;
        }
Esempio n. 14
0
 public string QueryForCompanyFilters(User _User)
 {
     string query = "";
     //switch (_User.RoleID)
     //{
     //    case 1:
     //        break;
     //    case 2:
     //        query = " where CompanyID= 1 or CompanyID = 2 ";
     //        break;
     //    case 3:
     //        query = " where  CompanyID>= 3";
     //        break;
     //    case 4:
     //        query = " where  CompanyID = " + _User.ToString();
     //        break;
     //    case 5:
     //        break;
     //}
     return query;
 }
Esempio n. 15
0
 public string QueryForCompanyViewLinq(User _User)
 {
     string query = "";
     switch (_User.RoleID)
     {
         case 1: query = "CompID > 0";
             break;
         case 2:
             query = "CompID= 1 or CompID = 2 ";
             break;
         case 3:
             query = "CompID>= 3";
             break;
         case 4:
             query = "CompID = " + _User.CompanyID.ToString();
             break;
         case 5:
             break;
     }
     return query;
 }
Esempio n. 16
0
 public string QueryForCompanyViewLinq(User _User)
 {
     string query = "";
        //switch (_User.RoleID)
        // {
        //     case 1: query ="CompID > 0";
        //         break;
        //     case 2:
        //         query = "CompID= 1 or CompID = 2 ";
        //         break;
        //     case 3:
        //         query = "CompID>= 3";
        //         break;
        //     case 4:
        //         query = "CompID = " + _User.ToString();
        //         break;
        //     case 5:
        //         break;
        // }
     return query;
 }
Esempio n. 17
0
 public string QueryForLocationFilters(User _user)
 {
     TAS2013Entities db = new TAS2013Entities();
     //List<UserLocation> ulocs = new List<UserLocation>();
     //List<string> _CriteriaForOrLoc = new List<string>();
     //ulocs = db.UserLocations.Where(aa => aa.UserID == _user.UserID).ToList();
     string query = "";
     //foreach (var uloc in ulocs)
     //{
     //    _CriteriaForOrLoc.Add(" LocID = " + uloc.LocationID + " ");
     //}
     //for (int i = 0; i < _CriteriaForOrLoc.Count - 1; i++)
     //{
     //    query = query + _CriteriaForOrLoc[i] + " or ";
     //}
     //query = query + _CriteriaForOrLoc[_CriteriaForOrLoc.Count - 1];
     return query;
 }
Esempio n. 18
0
        public string MakeCustomizeQuery(User _user)
        {
            string query = " where ";
            string subQuery = "";
            string subQueryLoc = "";
            List<string> _Criteria = new List<string>();
            List<string> _CriteriaForOr = new List<string>();
            List<string> _CriteriaForOrLoc = new List<string>();
               //if (_user.ViewLocation == true)
               // {
               //     _Criteria.Add(" LocID = " + _user.LocationID.ToString());
               // }
            TAS2013Entities db=  new TAS2013Entities();
            List<UserLocation> ulocs = new List<UserLocation>();
               ulocs = db.UserLocations.Where(aa => aa.UserID == _user.UserID).ToList();
            foreach (var uloc in ulocs)
            {
                _CriteriaForOrLoc.Add(" LocID = " + uloc.LocationID + " ");
            }
            if (_user.ViewContractual == true)
            {
                _CriteriaForOr.Add(" CatID = 3 ");
            }
            if (_user.ViewPermanentMgm == true)
            {
                _CriteriaForOr.Add(" CatID = 2  ");
            }
            if (_user.ViewPermanentStaff == true)
            {
                _CriteriaForOr.Add(" CatID = 4  ");
            }
            _CriteriaForOr.Add(" CatID=1 ");

            switch (_user.RoleID)
            {
                case 1:
                    break;
                case 2:
                    _Criteria.Add(" CompanyID= 1 or CompanyID = 2 ");
                    break;
                case 3:
                    _Criteria.Add(" CompanyID>= 3");
                    break;
                case 4:
                    _Criteria.Add(" CompanyID = "+_user.CompanyID.ToString());
                    break;
                case 5:
                    break;
            }
            for (int i = 0; i < _Criteria.Count; i++ )
            {
                query = query + _Criteria[i] + " and ";
            }
            for (int i = 0; i < _CriteriaForOrLoc.Count-1; i++)
            {
                subQueryLoc = subQueryLoc + _CriteriaForOrLoc[i] + " or ";
            }
            if(_CriteriaForOrLoc.Count !=0)
            subQueryLoc = " and  ( " + subQueryLoc + _CriteriaForOrLoc[_CriteriaForOrLoc.Count-1] + " ) ";
            //query = query + " ) and (";
            //query = query + _Criteria[_Criteria.Count-1];

            subQuery = " ( ";
            for (int i = 0; i < _CriteriaForOr.Count - 1; i++)
            {
                subQuery = subQuery + _CriteriaForOr[i] + " or ";
            }
            subQuery = subQuery + _CriteriaForOr[_CriteriaForOr.Count - 1];
            subQuery = subQuery + " ) ";
            query = query + subQuery + subQueryLoc;
            return query;
        }
Esempio n. 19
0
        public string MakeCustomizeQuery(User _user)
        {
            string RoleQuery = "";
            string CatQuery = "";
            TAS2013Entities db = new TAS2013Entities();
            List<UserRoleData> userRoleData = new List<UserRoleData>();
            List<string> UserRoleString = new List<string>();
            List<string> CategoryUser = new List<string>();
            CategoryUser.Add(" where (CatID=1 ");
            if (_user.ViewContractual == true)
            {
                CategoryUser.Add(" CatID = 4 ");
            }
            if (_user.ViewPermanentMgm == true)
            {
                CategoryUser.Add(" CatID = 2  ");
            }
            if (_user.ViewPermanentStaff == true)
            {
                CategoryUser.Add(" CatID = 3  ");
            }
            userRoleData = db.UserRoleDatas.Where(aa => aa.RoleUserID == _user.UserID).ToList();
            switch (_user.UserRoleD)
            {
                case "A"://Admin

                    break;
                case "C"://City
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" CityID = " + urd.RoleDataValue + " ");
                    }
                    break;
                case "D"://Department
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" DeptID = " + urd.RoleDataValue + " ");
                    }
                    break;
                case "E"://Single Employee
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" EmpID = " + urd.RoleDataValue + " ");
                    }
                    break;
                case "L"://Location
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" LocID = " + urd.RoleDataValue + " ");
                    }
                    break;
                case "R"://Region
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" RegionID = " + urd.RoleDataValue + " ");
                    }
                    break;
                case "S"://Section
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" SecID = " + urd.RoleDataValue + " ");
                    }
                    break;
                case "V"://Division
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" DivID = " + urd.RoleDataValue + " ");
                    }
                    break;
                case "W"://Crew
                    foreach (var urd in userRoleData)
                    {
                        UserRoleString.Add(" CrewID = " + urd.RoleDataValue + " ");
                    }
                    break;
            }
            if (UserRoleString.Count == 1)
            {
                RoleQuery = " and (" + RoleQuery + UserRoleString[0] + " ) ";
            }
            else if(UserRoleString.Count>1)
            {
                RoleQuery = RoleQuery + " and ( ";
                for (int i = 0; i < UserRoleString.Count - 1; i++)
                {
                    RoleQuery = RoleQuery + UserRoleString[i] + " or ";
                }
                RoleQuery = RoleQuery + UserRoleString[UserRoleString.Count - 1] + " ) ";
            }
            if (CategoryUser.Count == 1)
                CatQuery = CatQuery + CategoryUser[0]+" ) ";
            else if(CategoryUser.Count>1)
            {
                for (int i = 0; i < CategoryUser.Count-1; i++)
                {
                    CatQuery = CatQuery + CategoryUser[i] + " or ";
                }
                CatQuery = CatQuery + CategoryUser[CategoryUser.Count - 1] + " ) ";
            }

            return CatQuery + RoleQuery;
        }
Esempio n. 20
0
 internal string QueryForLocationTableSegerationForLinq(User LoggedInUser)
 {
     TAS2013Entities db = new TAS2013Entities();
     //List<UserLocation> ulocs = new List<UserLocation>();
     //List<string> _CriteriaForOrLoc = new List<string>();
     //ulocs = db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList();
     String query = "";
     //foreach (var uloc in ulocs)
     //{
     //    _CriteriaForOrLoc.Add(" LocID = " + uloc.LocationID + " ");
     //}
     //for (int i = 0; i < _CriteriaForOrLoc.Count - 1; i++)
     //{
     //    query = query + _CriteriaForOrLoc[i] + " or ";
     //}
     //if (_CriteriaForOrLoc.Count != 0)
     //    query = query + _CriteriaForOrLoc[_CriteriaForOrLoc.Count - 1];
     //else
     //    query = "LocID > 0";
     return query;
 }
Esempio n. 21
0
 public string QueryForCompanySegeration(User _user)
 {
     string query = "";
     if (query != "")
     {
         query = " where " + query;
     }
     return query;
 }
Esempio n. 22
0
 private bool CheckEditActionPermission(User _User)
 {
     if (_User.CanEdit == true)
         return true;
     else
         return false;
 }
Esempio n. 23
0
 public string QueryForLocationTableSegeration(User _user)
 {
     TAS2013Entities db = new TAS2013Entities();
     List<UserLocation> ulocs = new List<UserLocation>();
     List<string> _CriteriaForOrLoc = new List<string>();
     ulocs = db.UserLocations.Where(aa => aa.UserID == _user.UserID).ToList();
     string query = " where ";
     foreach (var uloc in ulocs)
     {
         _CriteriaForOrLoc.Add(" LocID = " + uloc.LocationID + " ");
     }
     for (int i = 0; i < _CriteriaForOrLoc.Count - 1; i++)
     {
         query = query + _CriteriaForOrLoc[i] + " or ";
     }
     query = query + _CriteriaForOrLoc[_CriteriaForOrLoc.Count - 1];
     return query;
 }
Esempio n. 24
0
        public ActionResult Login(User u)
        {
            try
            {
                //using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "fatima-group.com"))
                //{
                //  //validate the credentials
                // //bool isValid = pc.ValidateCredentials("ffl.ithelpdesk", "fatima@0202");
                //  bool isValid = pc.ValidateCredentials(u.UserName, u.Password);
                //  if (isValid)
                //  {
                      if (ModelState.IsValid) // this is check validity
                      {
                          using (TAS2013Entities dc = new TAS2013Entities())
                          {
                              var v = dc.Users.Where(a => a.UserName.Equals(u.UserName) && a.Status == true).FirstOrDefault();
                              if (v != null)
                              {
                                  Session["MDevice"] = "0";
                                  Session["MHR"] = "0";
                                  Session["MDevice"] = "0";
                                  Session["MLeave"] = "0";
                                  Session["MEditAtt"] = "0";
                                  Session["MUser"] = "******";
                                  Session["LogedUserFullname"] = "";
                                  Session["UserCompany"] = "";
                                  Session["MRDailyAtt"] = "0";
                                  Session["MRLeave"] = "0";
                                  Session["MRMonthly"] = "0";
                                  Session["MRAudit"] = "0";
                                  Session["MRManualEditAtt"] = "0";
                                  Session["MREmployee"] = "0";
                                  Session["MRDetail"] = "0";
                                  Session["MRSummary"] = "0";
                                  Session["LogedUserID"] = v.UserID.ToString();
                                  Session["LogedUserFullname"] = v.UserName;
                                  Session["LoggedUser"] = v;
                                  Session["UserCompany"] = v.CompanyID.ToString();
                                  if (v.MHR == true)
                                      Session["MHR"] = "1";
                                  if (v.MDevice == true)
                                      Session["MDevice"] = "1";
                                  if (v.MLeave == true)
                                      Session["MLeave"] = "1";
                                  if (v.MEditAtt == true)
                                      Session["MEditAtt"] = "1";
                                  if (v.MUser == true)
                                      Session["MUser"] = "******";
                                  if (v.MRDailyAtt == true)
                                      Session["MRDailyAtt"] = "1";
                                  if (v.MRLeave == true)
                                      Session["MRLeave"] = "1";
                                  if (v.MRMonthly == true)
                                      Session["MRMonthly"] = "1";
                                  if (v.MRAudit == true)
                                      Session["MRAudit"] = "1";
                                  if (v.MRManualEditAtt == true)
                                      Session["MRManualEditAtt"] = "1";
                                  if (v.MProcess == true)
                                      Session["MProcess"] = "1";
                                  if (v.MREmployee == true)
                                      Session["MREmployee"] = "1";
                                  if (v.MRDetail == true)
                                      Session["MRDetail"] = "1";
                                  if (v.MRSummary == true)
                                      Session["MRSummary"] = "1";
                                  else
                                      Session["MRSummary"] = "0";
                                  if (v.MRoster == true)
                                      Session["MRoster"] = "1";
                                  if(v.MRGraph==true)
                                      Session["MGraph"] = "1";
                                  else
                                      Session["MGraph"] = "0";
                                  HelperClass.MyHelper.SaveAuditLog(v.UserID, (byte)MyEnums.FormName.LogIn, (byte)MyEnums.Operation.LogIn, DateTime.Now);

                                  return RedirectToAction("AfterLogin");
                              }
                              else
                              {
                                  int LoginCount = 0;
                                  bool successOnConversion = int.TryParse(Session["LoginCount"] as string, out LoginCount);
                                  if (successOnConversion == true)
                                  {
                                      LoginCount++;
                                      Session["LoginCount"] = LoginCount + "";
                                  }
                                  else
                                  {
                                      Session["LoginCount"] = "1";
                                  }

                              }
                          }
                      }
                  //}
                  else
                  {
                      int LoginCount = 0;
                      bool successOnConversion = int.TryParse(Session["LoginCount"] as string, out LoginCount);
                      if (successOnConversion == true)
                      {
                          LoginCount++;
                          Session["LoginCount"] = LoginCount + "";
                      }
                      else
                      {
                          Session["LoginCount"] = "1";
                      }

                  }
                  return RedirectToAction("index");

                }

                //using (var context = new PrincipalContext(ContextType.Domain, "fatima-group.com", "*****@*****.**", "fatima@0202"))
                //{
                //    using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
                //    {
                //        foreach (var result in searcher.FindAll())
                //        {
                //            DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry;
                //            string name = result.Name;
                //            //label1.Text += "Name:    " + result.Name;
                //            //label1.Text += "      account name   :    " + result.UserPrincipalName;
                //            //label1.Text += "      Server:    " + result.Context.ConnectedServer + "\r";

                //        }
                //    }
                //}
                // this action is for handle post (login)

            //}
            catch (Exception ex)
            {
                ViewBag.Message = "There seems to be a problem with the network. Please contact your network administrator";
                return RedirectToAction("Index");
            }
        }
Esempio n. 25
0
        internal string QueryForEmployeeReports(User LoggedInUser)
        {
            string query = " where ";
            TAS2013Entities db = new TAS2013Entities();
            List<UserAccess> uAcc = new List<UserAccess>();
            uAcc = db.UserAccesses.Where(aa => aa.UserID == LoggedInUser.UserID).ToList();
            List<Region> regions = db.Regions.ToList();
            List<City> cities = db.Cities.ToList();
            List<Location> locs = db.Locations.ToList();
            List<string> queryList = new List<string>();
            foreach (var access in uAcc)
            {
                switch (LoggedInUser.RoleID)
                {
                    case 1://Super ADmin
                        query = "";
                        break;
                    case 4://Zone
                        queryList.Add(" ZoneID =" + access.CriteriaData.ToString());
                        break;
                    case 5://REgion
                        queryList.Add(" RegionID =" + access.CriteriaData.ToString());
                        break;
                    case 6://City

                        queryList.Add(" CityID =" + access.CriteriaData.ToString());
                        break;
                    case 7://Location
                        queryList.Add(" LocID =" + access.CriteriaData.ToString());
                        break;
                }
            }
            if (queryList.Count == 1)
            {
                query = query + queryList[0];
            }
            else if (queryList.Count > 1)
            {
                for (int i = 0; i < queryList.Count - 1; i++)
                {
                    query = query + queryList[i] + " or ";
                }
                query = query + queryList[queryList.Count - 1];
            }

            return query;
        }
Esempio n. 26
0
        public ActionResult Login(User u)
        {
            try
            {
                      if (ModelState.IsValid) // this is check validity
                      {
                          using (TAS2013Entities dc = new TAS2013Entities())
                          {
                              var v = dc.Users.Where(a => a.UserName.Equals(u.UserName) && a.Password==u.Password && a.Status == true).FirstOrDefault();
                              if (v != null)
                              {
                                  Session["MDevice"] = "0";
                                  Session["MHR"] = "0";
                                  Session["MDevice"] = "0";
                                  Session["MLeave"] = "0";
                                  Session["MEditAtt"] = "0";
                                  Session["MUser"] = "******";
                                  Session["LogedUserFullname"] = "";
                                  Session["UserCompany"] = "";
                                  Session["MRDailyAtt"] = "0";
                                  Session["MRLeave"] = "0";
                                  Session["MRMonthly"] = "0";
                                  Session["MRAudit"] = "0";
                                  Session["MRManualEditAtt"] = "0";
                                  Session["MREmployee"] = "0";
                                  Session["MRDetail"] = "0";
                                  Session["MRSummary"] = "0";
                                  Session["LogedUserID"] = v.UserID.ToString();
                                  Session["LogedUserFullname"] = v.UserName;
                                  Session["LoggedUser"] = v;
                                  Session["UserCompany"] = v.CompanyID.ToString();
                                  if (v.MHR == true)
                                      Session["MHR"] = "1";
                                  if (v.MDevice == true)
                                      Session["MDevice"] = "1";
                                  if (v.MLeave == true)
                                      Session["MLeave"] = "1";
                                  if (v.MEditAtt == true)
                                      Session["MEditAtt"] = "1";
                                  if (v.MUser == true)
                                      Session["MUser"] = "******";
                                  if (v.MRDailyAtt == true)
                                      Session["MRDailyAtt"] = "1";
                                  if (v.MRLeave == true)
                                      Session["MRLeave"] = "1";
                                  if (v.MRMonthly == true)
                                      Session["MRMonthly"] = "1";
                                  if (v.MRAudit == true)
                                      Session["MRAudit"] = "1";
                                  if (v.MRManualEditAtt == true)
                                      Session["MRManualEditAtt"] = "1";
                                  if (v.MProcess == true)
                                      Session["MProcess"] = "1";
                                  if (v.MREmployee == true)
                                      Session["MREmployee"] = "1";
                                  if (v.MRDetail == true)
                                      Session["MRDetail"] = "1";
                                  if (v.MRSummary == true)
                                      Session["MRSummary"] = "1";
                                  else
                                      Session["MRSummary"] = "0";
                                  if (v.MRoster == true)
                                      Session["MRoster"] = "1";
                                  if(v.MRGraph==true)
                                      Session["MGraph"] = "1";
                                  else
                                      Session["MGraph"] = "0";
                                  HelperClass.MyHelper.SaveAuditLog(v.UserID, (byte)MyEnums.FormName.LogIn, (byte)MyEnums.Operation.LogIn, DateTime.Now);

                                  return RedirectToAction("AfterLogin");
                              }
                              else
                              {
                                  int LoginCount = 0;
                                  bool successOnConversion = int.TryParse(Session["LoginCount"] as string, out LoginCount);
                                  if (successOnConversion == true)
                                  {
                                      LoginCount++;
                                      Session["LoginCount"] = LoginCount + "";
                                  }
                                  else
                                  {
                                      Session["LoginCount"] = "1";
                                  }

                              }
                          }
                      }
                  return RedirectToAction("index");

            }
            catch (Exception ex)
            {
                ViewBag.Message = "There seems to be a problem with the network. Please contact your network administrator";
                return RedirectToAction("Index");
            }
        }
Esempio n. 27
0
 internal string QueryForShiftForLinq(User LoggedInUser)
 {
     TAS2013Entities db = new TAS2013Entities();
     List<UserLocation> ulocs = new List<UserLocation>();
     List<string> _CriteriaForOrLoc = new List<string>();
     ulocs = db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList();
     string query = "";
     foreach (var uloc in ulocs)
     {
         _CriteriaForOrLoc.Add(" LocationID = " + uloc.LocationID + " ");
     }
     for (int i = 0; i < _CriteriaForOrLoc.Count - 1; i++)
     {
         query = query + _CriteriaForOrLoc[i] + " or ";
     }
     query = query + _CriteriaForOrLoc[_CriteriaForOrLoc.Count - 1];
     return query;
 }
Esempio n. 28
0
 private void LoadEmpGrid(User _loggedUser)
 {
     QueryBuilder qb = new QueryBuilder();
     string query = qb.MakeCustomizeQuery(_loggedUser);
     DataTable dt = qb.GetValuesfromDB("select * from EmpView " + query + " and (Status=1)");
     List<EmpView> _View = dt.ToList<EmpView>();
     grid_Employee.DataSource = _View;
     grid_Employee.DataBind();
 }
Esempio n. 29
0
        private string UserAccessGetCity(User _User, string role)
        {
            string query = "";
            TAS2013Entities ctx = new TAS2013Entities();
            List<UserAccess> uAcc = new List<UserAccess>();
            uAcc = ctx.UserAccesses.Where(aa => aa.UserID == _User.UserID).ToList();
            switch (role)
            {
                case "Region":
                    foreach (var uaccess in uAcc)
                    {
                        Region region = ctx.Regions.Where(aa => aa.RegionID == uaccess.CriteriaData).FirstOrDefault();
                        List<City> cities = ctx.Cities.Where(aa => aa.CityID == region.RegionID).ToList();

                        foreach (var city in cities)
                        {
                            query = query + "CityID=" + city.CityID + " or ";

                        }

                    }
                    query = query.Substring(0, query.Length - 4);
                    return query;
                case "City": foreach (var uaccess in uAcc)
                    {

                        query = query + "CityID=" + uaccess.CriteriaData + " or ";

                    }
                    query = query.Substring(0, query.Length - 4);
                    return query;
                case "Zone": foreach (var uaccess in uAcc)
                    {
                        Zone zone = ctx.Zones.Where(aa => aa.ZoneID == uaccess.CriteriaData).FirstOrDefault();
                        List<Region> region = ctx.Regions.Where(aa => aa.ZoneID == zone.ZoneID).ToList();
                        foreach (var re in region)
                        {
                            List<City> cities = ctx.Cities.Where(aa => aa.RegionID == re.RegionID).ToList();
                            foreach (var city in cities)
                            {
                                query = query + "CityID=" + city.CityID + " or ";

                            }

                        }

                    }
                    query = query.Substring(0, query.Length - 4);
                    return query;
                case "Location": foreach (var uaccess in uAcc)
                    {
                        Location loc = ctx.Locations.Where(aa => aa.LocID == uaccess.CriteriaData).FirstOrDefault();
                        City city = ctx.Cities.Where(aa => aa.CityID == loc.CityID).FirstOrDefault();
                        query = query + "CityID=" + city.CityID + " or ";

                    } query = query.Substring(0, query.Length - 4);
                    return query;
                case "SuperUser": query = "CityID>0";
                    return query;

            } return query;
        }
Esempio n. 30
0
 private void LoadLocationGrid(User _loggedUser)
 {
     List<Location> _objectList = new List<Location>();
     _objectList = context.Locations.ToList();
     //_Query = "SELECT * FROM TAS2013.dbo.EmpType where " + selectSQL;
     //grid_EmpType.DataSource = GetValuesFromDatabase(_Query, "EmpType");
     //grid_EmpType.DataBind();
     grid_Location.DataSource = _objectList;
     grid_Location.DataBind();
 }