Пример #1
0
 public int SaveUserMenu(Security_UserRight newSetupUserRightRow)
 {
     try
     {
         SCMSDataContext dbSCMS = Connection.Create();
         //Security_UserRight existingSetupUserMenuRow = dbSCMS.Security_UserRights.Where(c => c.UsrSec_Id.Equals(newSetupUserRightRow.UsrGrp_Id)).SingleOrDefault();
         //if (existingSetupUserMenuRow != null)
         //{
         //existingSetupUserMenuRow.Cmp_Id = newSetupUserRightRow.Cmp_Id;
         //existingSetupUserMenuRow.Loc_Id = newSetupUserRightRow.Loc_Id;
         //existingSetupUserMenuRow.UsrGrp_Title = newSetupUserRightRow.UsrGrp_Title;
         //}
         //else
         //{
         dbSCMS.Security_UserRights.InsertOnSubmit(newSetupUserRightRow);
         //}
         dbSCMS.SubmitChanges();
         // return Convert.ToInt32(newSetupUserRightRow.UsrGrp_Id);
         return 1;
     }
     catch
     {
         return 0;
     }
 }
Пример #2
0
 // Insetion User Menu
 public ActionResult SaveUserMenu(String UserMenu, int UserGroup)
 {
     try
     {
         Security_UserRight setupUserMenuRow = new Security_UserRight();
         //if (String.IsNullOrEmpty(Code))
         //{
         //    Code = DALCommon.GetMaximumCode("SECURITY_UserGroup", "UsrGrp_Id");
         //}
         //String UserGroupId = "0";
         //if (!String.IsNullOrEmpty(Code))
         //{
         setupUserMenuRow.UsrSec_Code = UserGroup.ToString();
         setupUserMenuRow.Grp_Id = UserGroup;
         setupUserMenuRow.Mnu_Id = Convert.ToInt32(UserMenu);
         setupUserMenuRow.UsrSec_Active = 1;
         UserMenuId = objDalUserMenu.SaveUserMenu(setupUserMenuRow).ToString();
         ViewData["UserGroupId"] = UserMenuId;
         //}
         return PartialView("GridData");
     }
     catch
     {
         return PartialView("GridData");
     }
 }
Пример #3
0
 public string SaveUserRights(int GroupId, int? UserId, bool isGroup, string UserMenus)
 {
     try
     {
         string[] UserMenuIds = UserMenus.Split(',');
         DALUserMenuRights objUserMenuRights = new DALUserMenuRights();
         int Success = objUserMenuRights.DeleteRecordByGroupId(GroupId, UserId, SystemParameters.ModuleId);
         if (Success >= 0)
         {
             foreach (string userMenuId in UserMenuIds)
             {
                 Security_UserRight userRightRow = new Security_UserRight();
                 string Code = "";
                 if (DALCommon.AutoCodeGeneration("Security_UserRights") == 1)
                 {
                     Code = DALCommon.GetMaximumCode("Security_UserRights");
                 }
                 userRightRow.UsrSec_Code = Code;
                 userRightRow.Grp_Id = GroupId;
                 if (UserId != null)
                 {
                     userRightRow.UsrSec_UserId = UserId.ToString();
                 }
                 string[] cols = userMenuId.Split('~');
                 userRightRow.Mnu_Id = Convert.ToInt32(cols[0]);
                 userRightRow.UsrSec_Add = Convert.ToBoolean(cols[1]);
                 userRightRow.UsrSec_Edit = Convert.ToBoolean(cols[2]);
                 userRightRow.UsrSec_Delete = Convert.ToBoolean(cols[3]);
                 userRightRow.UsrSec_Print = Convert.ToBoolean(cols[4]);
                 userRightRow.UsrSec_Import = Convert.ToBoolean(cols[5]);
                 userRightRow.Mod_Id = SystemParameters.ModuleId;
                 objUserMenuRights.SaveRecord(userRightRow);
             }
         }
         return "1";
     }
     catch
     {
         return "0";
     }
 }
Пример #4
0
        public int SaveRecord(Security_UserRight pRow_NewData)
        {
            int li_ReturnValue = 0;

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

            return li_ReturnValue;
        }
Пример #5
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;
            }
        }