public ActionResult DeleteRecord(String _pId) { DALUser objDal = new DALUser(); Int32 li_ReturnValue = 0; try { li_ReturnValue = objDal.DeleteRecordById(_pId); ViewData["SaveResult"] = li_ReturnValue; return PartialView("GridData"); } catch { return PartialView("GridData"); } }
public ActionResult SaveRecord(string ps_Code, string ps_Title, string ps_GroupId, string ps_Login, string ps_Password) { DALUser objDal = new DALUser(); Int32 li_ReturnValue = 0; try { SECURITY_User lrow_Data = new SECURITY_User(); if (String.IsNullOrEmpty(ps_Code)) { if (DALCommon.AutoCodeGeneration("SECURITY_User") == 1) { ps_Code = DALCommon.GetMaximumCode("SECURITY_User"); } } if (!String.IsNullOrEmpty(ps_Code)) { lrow_Data.User_Id = ps_Code; lrow_Data.User_Code = ps_Code; lrow_Data.UsrGrp_Id = ps_GroupId; lrow_Data.User_Title = ps_Title; lrow_Data.User_Login = ps_Login; lrow_Data.User_Password = ps_Password; lrow_Data.User_Active = 1; li_ReturnValue = objDal.SaveRecord(lrow_Data); ViewData["SaveResult"] = li_ReturnValue; } return PartialView("GridData"); } catch { return PartialView("GridData"); } }
// // GET: /UserRightsSetup/ public ActionResult Index() { List<sp_GetUserGroupListResult> userGroups = new DALUserGroup().GetAllData().ToList(); ViewData["ddl_UserGroups"] = new SelectList(userGroups, "UsrGrp_Id", "UsrGrp_Title"); List<sp_GetUserMenuRightsResult> MenuRights = new DALUserMenuRights().GetUserMenuRights("").Where(c => c.Mod_Id == SystemParameters.ModuleId && c.Mnu_Level != "0").ToList(); List<sp_GetUserLocationsByGroupIdResult> UserLocations = new DALUserMenuRights().GetUserLocationsByGroupId("").ToList(); List<sp_GetUserVoucherTypesByGroupIdResult> UserVouchers = new DALUserMenuRights().GetUserVoucherTypesByGroupId("").ToList(); List<sp_GetUserChartOfAccountByGroupIdResult> UserChartOfAccounts = new DALUserMenuRights().GetUserChartOfAccountByGroupId("").ToList(); List<sp_GetUserListResult> Users = new DALUser().GetAllData().ToList(); ViewData["UserMenuRights"] = MenuRights; ViewData["UserLocations"] = UserLocations; ViewData["UserVoucherTypes"] = UserVouchers; ViewData["UserChartOfAccount"] = UserChartOfAccounts; ViewData["AllUsers"] = Users; return View("UserRights"); }
public string GetUsersByGroupId(string GroupId, int selected) { List<SCMSDataLayer.DB.sp_GetUserListResult> users = new List<SCMSDataLayer.DB.sp_GetUserListResult>(); users = new SCMSDataLayer.DALUser().GetAllData(); if (!String.IsNullOrEmpty(GroupId)) { users = users.Where(u => u.UsrGrp_Id.Equals(GroupId)).ToList(); } string response = ""; bool firstRow = true; foreach (SCMSDataLayer.DB.sp_GetUserListResult user in users) { response += "<table id='UserGrid' class=' display' style='width: 100%; padding: 2px;'>"; response += "<tbody>"; if (firstRow == true && selected > 0) { response += "<tr id='" + user.User_Id + "|" + user.UsrGrp_Id + "' class='odd gradeX Background' style='line-height: 15px; cursor: pointer;'>"; firstRow = false; } else { response += "<tr id='" + user.User_Id + "|" + user.UsrGrp_Id + "' class='odd gradeX' style='line-height: 15px; cursor: pointer;'>"; } response += "<td style='vertical-align: middle; width: 25%;'>"; response += user.User_Code; response += "</td>"; response += "<td style='vertical-align: middle; width: 35%;'>"; response += user.User_Title; response += "</td>"; response += "<td style='vertical-align: middle; width: 30%;'>"; response += user.UsrGrp_Title; response += "</td>"; response += "<td style='vertical-align: middle; text-align: right; padding-right: 3px;'>"; response += "</td>"; response += "</tr>"; response += "</tbody>"; response += "</table>"; } return response; }
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; } }