private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { security_role security_role = security_roleViewSource.View.CurrentItem as security_role; if (security_role != null) { if (security_rolesecurity_curdViewSource != null) { if (security_rolesecurity_curdViewSource.View != null) { security_rolesecurity_curdViewSource.View.Filter = i => { security_curd security_curd = (security_curd)i; string TranslatedName = entity.Brillo.Localize.StringText(security_curd.id_application.ToString()); if (TranslatedName.ToUpper().Contains(txtsearch.Text.ToUpper())) { return(true); } else { return(false); } }; } } } }
private void add_MissingRecords() { if (security_rolesecurity_curdViewSource.View != null) { security_role security_role = (security_role)security_roleDataGrid.SelectedItem; List <security_curd> security_curd = dbContext.security_curd.Where(x => x.id_role == security_role.id_role).ToList(); List <entity.App.Names> _DbApplication = security_curd.Select(x => x.id_application).ToList(); List <entity.App.Names> Application = Enum.GetValues(typeof(entity.App.Names)).Cast <entity.App.Names>().ToList(); List <entity.App.Names> finalapplicaiton = Enumerable.Except <entity.App.Names>(Application, (IEnumerable <entity.App.Names>)_DbApplication).ToList(); foreach (entity.App.Names AppName in finalapplicaiton) { security_curd _security_curd = new security_curd(); _security_curd.id_application = AppName; _security_curd.can_update = false; _security_curd.can_read = false; _security_curd.can_delete = false; _security_curd.can_create = false; _security_curd.can_approve = false; _security_curd.can_annul = false; security_role.security_curd.Add(_security_curd); } security_rolesecurity_curdViewSource.View.Refresh(); security_rolesecurity_role_privilageViewSource.View.Refresh(); } }
public Security(App.Names AppName) { view = true; create = true; edit = true; delete = true; approve = true; annul = true; if (CurrentSession.UserRole == null) { db db = new entity.db(); security_role security_role = new security_role(); security_role.name = "Master"; security_role.is_active = true; security_role.is_master = true; db.security_role.Add(security_role); db.SaveChanges(); CurrentSession.UserRole = security_role; } if (CurrentSession.UserRole.is_master == false) { if (CurrentSession.Security_CurdList.Where(x => x.id_application == AppName).FirstOrDefault() != null) { security_curd security_curd = CurrentSession.Security_CurdList.Where(x => x.id_application == AppName).FirstOrDefault(); view = security_curd.can_read; create = security_curd.can_create; edit = security_curd.can_update; delete = security_curd.can_delete; approve = security_curd.can_approve; annul = security_curd.can_annul; } } }
private void toolBar_btnCancel_Click(object sender) { security_role security_role = (security_role)security_roleDataGrid.SelectedItem; security_role.IsSelected = false; security_role.State = EntityState.Unchanged; dbContext.Entry(security_role).State = EntityState.Unchanged; }
private void add_Privallge() { List <entity.App.Names> Application = Enum.GetValues(typeof(entity.App.Names)).Cast <entity.App.Names>().ToList(); List <entity.Privilage.Privilages> Privilages = Enum.GetValues(typeof(entity.Privilage.Privilages)).Cast <entity.Privilage.Privilages>().ToList(); security_role security_role = (security_role)security_roleDataGrid.SelectedItem; foreach (entity.App.Names Names in Application) { if (Names == entity.App.Names.SalesInvoice) { foreach (entity.Privilage.Privilages Privilage in Privilages) { if (dbContext.security_privilage.Where(x => x.name == Privilage).Count() == 0) { if ((int)Privilage >= 3) { security_privilage security_privilage = new security_privilage(); security_privilage.id_application = entity.App.Names.ProductionExecution; security_privilage.name = Privilage; dbContext.security_privilage.Add(security_privilage); } else { security_privilage security_privilage = new security_privilage(); security_privilage.id_application = Names; security_privilage.name = Privilage; dbContext.security_privilage.Add(security_privilage); } } } } } List <entity.App.Names> PreferenceList = Enum.GetValues(typeof(entity.App.Names)).Cast <entity.App.Names>().ToList(); List <security_privilage> security_privilageList = dbContext.security_privilage.ToList(); List <security_role_privilage> security_role_privilage = new List <security_role_privilage>(); security_role_privilage = dbContext.security_role_privilage.Where(x => x.id_role == security_role.id_role).ToList(); foreach (security_privilage security_privilage in security_privilageList) { if (security_privilage.id_application == entity.App.Names.SalesInvoice || security_privilage.id_application == entity.App.Names.ProductionExecution) { if (security_role_privilage.Where(x => x.id_privilage == security_privilage.id_privilage).Count() == 0) { security_role_privilage _security_role_privilage = new security_role_privilage(); _security_role_privilage.id_privilage = security_privilage.id_privilage; _security_role_privilage.security_privilage = security_privilage; _security_role_privilage.id_role = security_role.id_role; _security_role_privilage.security_role = security_role; dbContext.security_role_privilage.Add(_security_role_privilage); } } } }
private void sync_Users() { try { security_role security_role = new security_role(); security_role.is_active = true; security_role.name = "Administrador"; security_role.id_company = id_company; dbContext.security_role.Add(security_role); dbContext.SaveChanges(); DataTable dt = exeDT("SELECT * FROM USUARIO"); foreach (DataRow row in dt.Rows) { security_user security_user = new security_user(); if (row["DESUSUARIO"].ToString() != "") { security_user.name = row["DESUSUARIO"].ToString(); } else { security_user.name = "name"; } if (row["PASSUSUARIO"].ToString() != "") { security_user.password = row["PASSUSUARIO"].ToString(); } else { security_user.password = "******"; } if (row["NOMBRE"].ToString() != "") { security_user.name_full = row["NOMBRE"].ToString(); } else { security_user.name_full = "name"; } security_user.id_company = id_company; security_user.is_active = true; security_user.id_role = security_role.id_role; security_user.security_role = security_role; dbContext.security_user.Add(security_user); } dt.Clear(); IEnumerable <DbEntityValidationResult> validationresult = dbContext.GetValidationErrors(); if (validationresult.Count() == 0) { dbContext.SaveChanges(); } } catch { throw; } }
private void New_Click(object sender) { security_role security_role = new security_role(); security_role.State = EntityState.Added; security_role.IsSelected = true; dbContext.security_role.Add(security_role); security_roleViewSource.View.Refresh(); security_roleViewSource.View.MoveCurrentToLast(); add_Privallge(); add_MissingRecords(); }
private void toolBar_btnEdit_Click(object sender) { if (security_roleDataGrid.SelectedItem != null) { add_Privallge(); security_role security_role = (security_role)security_roleDataGrid.SelectedItem; security_role.IsSelected = true; security_role.State = EntityState.Modified; dbContext.Entry(security_role).State = EntityState.Modified; add_MissingRecords(); } else { toolBar.msgWarning("Please Select a record"); } }