Esempio n. 1
0
        public int SetUserLocations(Security_UserLocation pRow_NewData)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                dbSCMS.Security_UserLocations.InsertOnSubmit(pRow_NewData);
                dbSCMS.SubmitChanges();
                li_ReturnValue = Convert.ToInt32(pRow_NewData.UserLoc_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }
Esempio n. 2
0
 public string SetUserLocations(string GroupId, string UserId, bool isGroup, string UserLocations)
 {
     try
     {
         string[] UserLocationIds = UserLocations.Split(',');
         DALUserMenuRights objUserMenuRights = new DALUserMenuRights();
         int Success = objUserMenuRights.DeleteLocationsByGroupId(GroupId, UserId);
         if (Success >= 0)
         {
             foreach (string userLocationId in UserLocationIds)
             {
                 Security_UserLocation userLocationRow = new Security_UserLocation();
                 userLocationRow.UsrGrp_Id = GroupId.ToString();
                 if (UserId != null)
                 {
                     userLocationRow.User_Id = UserId.ToString();
                 }
                 userLocationRow.Loc_Id = userLocationId;
                 objUserMenuRights.SetUserLocations(userLocationRow);
             }
         }
         return "1";
     }
     catch
     {
         return "0";
     }
 }
Esempio n. 3
0
        public int CopyUserRights(string CurrentUserId, string NewUserId, string SelectedTab)
        {
            try
            {
                string GroupId = "";
                GroupId = new DALUser().GetAllData().Where(c => c.User_Id.Equals(NewUserId)).SingleOrDefault().UsrGrp_Id;

                SCMSDataContext dbSCMS = Connection.Create();
                if (SelectedTab == "Menus")
                {
                    List<Security_UserRight> currentUserMenuRights = dbSCMS.Security_UserRights.Where(c => c.UsrSec_UserId.Equals(Convert.ToInt32(CurrentUserId))).ToList();

                    List<Security_UserRight> newUserMenuRights = dbSCMS.Security_UserRights.Where(c => c.UsrSec_UserId.Equals(Convert.ToInt32(NewUserId))).ToList();

                    if (newUserMenuRights != null && newUserMenuRights.Count > 0)
                    {
                        dbSCMS.Security_UserRights.DeleteAllOnSubmit(newUserMenuRights);
                        dbSCMS.SubmitChanges();
                    }

                    if (currentUserMenuRights != null && currentUserMenuRights.Count > 0)
                    {
                        foreach (Security_UserRight userRight in currentUserMenuRights)
                        {
                            Security_UserRight newUserRight = new Security_UserRight();

                            newUserRight.Grp_Id = Convert.ToInt32(GroupId); //userRight.Grp_Id;
                            newUserRight.Mnu_Id = userRight.Mnu_Id;
                            newUserRight.Mod_Id = userRight.Mod_Id;
                            newUserRight.UsrSec_UserId = Convert.ToInt32(NewUserId).ToString();
                            newUserRight.UsrSec_Add = userRight.UsrSec_Add;
                            newUserRight.UsrSec_Edit = userRight.UsrSec_Edit;
                            newUserRight.UsrSec_Delete = userRight.UsrSec_Delete;
                            newUserRight.UsrSec_Print = userRight.UsrSec_Print;
                            newUserRight.UsrSec_Import = userRight.UsrSec_Import;

                            SaveRecord(newUserRight);
                        }
                    }
                    else
                    {
                        return 0;
                    }
                }
                else if (SelectedTab == "Locations")
                {

                    List<Security_UserLocation> currentUserLocations = dbSCMS.Security_UserLocations.Where(c => c.User_Id.Equals(CurrentUserId)).ToList();

                    List<Security_UserLocation> newUserLocations = dbSCMS.Security_UserLocations.Where(c => c.User_Id.Equals(NewUserId)).ToList();

                    if (newUserLocations != null && newUserLocations.Count > 0)
                    {
                        dbSCMS.Security_UserLocations.DeleteAllOnSubmit(newUserLocations);
                        dbSCMS.SubmitChanges();
                    }

                    if (currentUserLocations != null && currentUserLocations.Count > 0)
                    {
                        foreach (Security_UserLocation userLocation in currentUserLocations)
                        {
                            Security_UserLocation newUserLocation = new Security_UserLocation();

                            newUserLocation.UsrGrp_Id = GroupId;
                            newUserLocation.User_Id = NewUserId;
                            newUserLocation.Loc_Id = userLocation.Loc_Id;

                            SetUserLocations(newUserLocation);
                        }
                    }
                    else
                    {
                        return 0;
                    }
                }
                else if (SelectedTab == "VoucherTypes")
                {
                    List<Security_UserVoucherType> currentVoucherTypes = dbSCMS.Security_UserVoucherTypes.Where(c => c.User_Id.Equals(CurrentUserId)).ToList();

                    List<Security_UserVoucherType> newVouchertTypes = dbSCMS.Security_UserVoucherTypes.Where(c => c.User_Id.Equals(NewUserId)).ToList();

                    if (newVouchertTypes != null && newVouchertTypes.Count > 0)
                    {
                        dbSCMS.Security_UserVoucherTypes.DeleteAllOnSubmit(newVouchertTypes);
                        dbSCMS.SubmitChanges();
                    }

                    if (currentVoucherTypes != null && currentVoucherTypes.Count > 0)
                    {
                        foreach (Security_UserVoucherType userVoucherType in currentVoucherTypes)
                        {
                            Security_UserVoucherType newUserVoucherType = new Security_UserVoucherType();

                            newUserVoucherType.UserGrp_Id = GroupId;
                            newUserVoucherType.User_Id = NewUserId;
                            newUserVoucherType.VchrType_Id = userVoucherType.VchrType_Id;

                            SetUserVoucherTypes(newUserVoucherType);
                        }
                    }
                    else
                    {
                        return 0;
                    }
                }
                else if (SelectedTab == "ChartOfAccounts")
                {
                    List<Security_UserChartOfAccount> currentChartOfAccounts = dbSCMS.Security_UserChartOfAccounts.Where(c => c.User_Id.Equals(CurrentUserId)).ToList();

                    List<Security_UserChartOfAccount> newChartOfAccounts = dbSCMS.Security_UserChartOfAccounts.Where(c => c.User_Id.Equals(NewUserId)).ToList();

                    if (newChartOfAccounts != null && newChartOfAccounts.Count > 0)
                    {
                        dbSCMS.Security_UserChartOfAccounts.DeleteAllOnSubmit(newChartOfAccounts);
                        dbSCMS.SubmitChanges();
                    }

                    if (currentChartOfAccounts != null && currentChartOfAccounts.Count > 0)
                    {
                        foreach (Security_UserChartOfAccount userChartOfAccount in currentChartOfAccounts)
                        {
                            Security_UserChartOfAccount newUserChartOfAccount = new Security_UserChartOfAccount();

                            newUserChartOfAccount.UserGrp_Id = GroupId;
                            newUserChartOfAccount.User_Id = NewUserId;
                            newUserChartOfAccount.ChrtAcc_Id = userChartOfAccount.ChrtAcc_Id;

                            SetUserChartOfAccount(newUserChartOfAccount);
                        }
                    }
                    else
                    {
                        return 0;
                    }
                }

                return 1;
            }
            catch
            {
                return 0;
            }
        }