public static bool InsertUpdateUserPerm(string rolName, string userName, List <PermEx> rolePermList, string userID = "") { using (TransactionScope Scope = new TransactionScope()) { using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { if (rolName.IsNullEmpty()) { Context.ExecuteCommand("UPDATE usr.Users SET RoleName=null WHERE Kod={0}", userName); } else { Context.ExecuteCommand("UPDATE usr.Users SET RoleName={0} WHERE Kod={1}", rolName, userName); } foreach (PermEx rPerm in rolePermList) { Context.ExecuteCommand(@" IF (SELECT COUNT(UserName) FROM usr.UserPerm(Nolock) WHERE UserName={0} AND PermName={1})=0 INSERT INTO usr.UserPerm (UserName, PermName, Reading, Writing, Updating, Deleting, RecordUser, ModifiedUser) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {6}) ELSE UPDATE usr.UserPerm SET Reading={2}, Writing={3}, Updating={4}, Deleting={5}, ModifiedDate=GETDATE(), ModifiedUser={6} WHERE UserName={0} AND PermName={1}", userName, rPerm.PermName, rPerm.Reading, rPerm.Writing, rPerm.Updating, rPerm.Deleting, userID); } } Scope.Complete(); } return(true); }
public static bool InsertUpdateRolePerm(string rolName, List <PermEx> rolePermList, string userID = "") { using (TransactionScope Scope = new TransactionScope()) { using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { List <MUser> UserList = Context.ExecuteQuery <MUser>("SELECT Kod FROM usr.Users(Nolock) WHERE RoleName={0} AND Admin=0", rolName).ToList(); foreach (PermEx rPerm in rolePermList) { Context.ExecuteCommand(@"IF (SELECT COUNT(ID) FROM usr.RolePerm (Nolock) WHERE RoleName={0} AND PermName={1})=0 INSERT INTO usr.RolePerm (RoleName, PermName, Reading, Writing, Updating, Deleting, RecordUser, ModifiedUser) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {6}) ELSE UPDATE usr.RolePerm SET Reading={2}, Writing={3}, Updating={4}, Deleting={5}, ModifiedDate=Getdate(), ModifiedUser={6} WHERE RoleName={0} AND PermName={1}" , rolName, rPerm.PermName, rPerm.Reading, rPerm.Writing, rPerm.Updating, rPerm.Deleting, userID); foreach (var user in UserList) { Context.ExecuteCommand(@"IF (SELECT COUNT(UserName) FROM usr.UserPerm(Nolock) WHERE UserName={0} AND PermName={1})=0 INSERT INTO usr.UserPerm (UserName, PermName, Reading, Writing, Updating, Deleting, RecordUser, ModifiedUser) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {6}) ELSE UPDATE usr.UserPerm SET Reading={2}, Writing={3}, Updating={4}, Deleting={5}, ModifiedDate=GetDate(), ModifiedUser={6} WHERE UserName={0} AND PermName={1}" , user.Kod, rPerm.PermName, rPerm.Reading, rPerm.Writing, rPerm.Updating, rPerm.Deleting, userID); } } } Scope.Complete(); } return(true); }
public static bool UpdateRoles(string eskiRolAdi, string yeniRolAdi) { if (eskiRolAdi.IsNullEmpty() || yeniRolAdi.IsNullEmpty()) { Mesaj.Uyari("Rol adı boş yada geçersiz olamaz !"); return(false); } using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { Context.ExecuteCommand("UPDATE usr.Roles SET RoleName={0} WHERE RoleName={1}", yeniRolAdi, eskiRolAdi); } return(true); }
public static bool UpdatePerm(string permNameKey, Perm mIzin) { if (permNameKey.IsNullEmpty() || mIzin.PermName.IsNullEmpty()) { Mesaj.Uyari("İzin form adı boş yada geçersiz olamaz !"); return(false); } using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { Context.ExecuteCommand("UPDATE usr.Perm SET PermName={0}, Active={1}, Type={2}, [Group]={3} WHERE PermName={4}", mIzin.PermName, mIzin.Active, mIzin.Type, mIzin.Group, permNameKey); } return(true); }
public static bool UpdateUser(User eskiKul, User yeniKul) { if (eskiKul.Kod.IsNullEmpty() || yeniKul.Kod.IsNullEmpty()) { Mesaj.Uyari("Kullanıcı adı boş yada geçersiz olamaz !"); return(false); } using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { Context.ExecuteCommand(@"UPDATE BIRIKIM.usr.Users SET Kod={0}, Sifre={1}, AdSoyad={2}, EMail={3}, Aktif={4}, Admin={5}, Sirket={6} WHERE Kod={7} AND Tip={8} AND Sirket={9}", yeniKul.Kod, yeniKul.Sifre, yeniKul.AdSoyad, yeniKul.Email, yeniKul.Aktif, yeniKul.Admin, yeniKul.Sirket, eskiKul.Kod, eskiKul.Tip, eskiKul.Sirket); } return(true); }
public static bool DeleteRoles(string rolAdi) { if (rolAdi.IsNullEmpty()) { Mesaj.Uyari("Rol adı boş yada geçersiz olamaz !"); return(false); } if (DialogResult.Yes == Mesaj.Onay(string.Format("[{0}] adlı rolü silmek istediğinize emin misiniz ?", rolAdi))) { using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { Context.ExecuteCommand("DELETE usr.Roles WHERE RoleName={0}", rolAdi); } return(true); } else { return(false); } }
public static bool DeleteUser(string userName) { if (userName.IsNullEmpty()) { Mesaj.Uyari("Kullanıcı adı boş yada geçersiz olamaz !"); return(false); } if (DialogResult.Yes == Mesaj.Onay(string.Format("[{0}] adlı kullanıcıyı silmek istediğinize emin misiniz ?", userName))) { using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { Context.ExecuteCommand("DELETE BIRIKIM.usr.Users WHERE Kod={0}", userName); } return(true); } else { return(false); } }
public static bool DeletePerm(string permNameKey) { if (permNameKey.IsNullEmpty()) { Mesaj.Uyari("İzin form adı boş olamaz !"); return(false); } if (DialogResult.Yes == Mesaj.Onay(string.Format("[{0}] adlı izin formu silmek istediğinize emin misiniz ?", permNameKey))) { using (UserRoleDBDataContext Context = new UserRoleDBDataContext(ConStr)) { Context.ExecuteCommand("DELETE usr.Perm WHERE PermName={0}", permNameKey); } return(true); } else { return(false); } }