private void FrmModificarRol_Load(object sender, EventArgs e) { roles nUsuarios = roles.Getallrol(FrmCategoriaRoles.Rol); txtRol.Text = nUsuarios.sNombre; txtDescripcion.Text = nUsuarios.sDescripcion; }
public ActionResult Edit(roles rolesEdit) { if (!ModelState.IsValid) { return(View()); } try { using (var db = new inventario2021Entities()) { roles user = db.roles.Find(rolesEdit.id); user.descripcion = rolesEdit.descripcion; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { ModelState.AddModelError("", "error " + ex); return(View()); } }
public async Task Put() { //Arrange var get = await controller.Get(1); var okgetResult = Assert.IsType <OkObjectResult>(get); var entity = Assert.IsType <roles>(okgetResult.Value); var newEntity = new roles(); newEntity.role_name = "admin"; newEntity.role_description = "administrator"; //should test the equals Equatable for all these too var huh = entity.Equals(newEntity); entity.role_name = "testEdit"; //Act var response = await controller.Put(1, entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <roles>(okResult.Value); Assert.Equal(entity.role_name, result.role_name); }
public void Modificar(roles rol, DataGridView dtgPermisos) { using (TransactionScope scope = new TransactionScope()) { try { int numFila = dtgPermisos.RowCount - 1; for (int i = 0; i < numFila; i++) { permisosDeRol permisosRol = new permisosDeRol { idrol = rol.idrol, idventana = Convert.ToInt32(dtgPermisos.Rows[i].Cells[0].Value), consultar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[2].Value), insertar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[3].Value), modificar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[4].Value), eliminar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[5].Value) }; new Cls_PermisosRol().Modificar(permisosRol); } rolDAL.ModificarRol(rol); scope.Complete(); } catch (Exception ex) { scope.Dispose(); throw ex; } } }
public async Task <IHttpActionResult> Putroles(int id, roles roles) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != roles.id) { return(BadRequest()); } db.Entry(roles).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!rolesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Edit(string id, [Bind("id,Role")] roles roles) { if (id != roles.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(roles); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!rolesExists(roles.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(roles)); }
/* * Efecto: elimina tupla de rol de tabla de roles * Requiere: código proyecto y cédula empleado * Modifica tabla roles en BD */ public void EraseRol(int codProyecto, string cedulaEmp) { roles roles = db.roles.Find(cedulaEmp, codProyecto); db.roles.Remove(roles); db.SaveChanges(); }
public static bool Delete(roles roles) { SqlConnection connection = plansoni_webstoreData.GetConnection(); string deleteProcedure = "[rolesDelete]"; SqlCommand deleteCommand = new SqlCommand(deleteProcedure, connection); deleteCommand.CommandType = CommandType.StoredProcedure; deleteCommand.Parameters.AddWithValue("@Oldid", roles.id); deleteCommand.Parameters.AddWithValue("@Oldname", roles.name); deleteCommand.Parameters.AddWithValue("@Olddescription", roles.description); deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int); deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output; try { connection.Open(); deleteCommand.ExecuteNonQuery(); int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value); if (count > 0) { return(true); } else { return(false); } } catch (SqlException) { return(false); } finally { connection.Close(); } }
private void GV_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { DataGrid dg = sender as DataGrid; _dr = dg.SelectedItem.ToString(); test = _dr.Split(new char[4] { '=', ',', '{', '}' }, StringSplitOptions.RemoveEmptyEntries); nameBeChange = test[3].TrimStart(' '); txtName.Text = test[3].TrimStart(' '); txtEmail.Text = test[5].TrimStart(' '); using (llblanca_lara1Entities db = new llblanca_lara1Entities()) { users user = db.users.Where(u => u.name == nameBeChange).FirstOrDefault(); role_user r_u = db.role_user.Where(u => u.user_id == user.id).FirstOrDefault(); roles role = db.roles.Where(r => r.id == r_u.role_id).FirstOrDefault(); var contacts = db.contacts.Join(db.contact_types, t => t.type_id, c => c.id, (t, c) => new { value = t.value, type = c.contact_type, t.user_id }).Where(r => r.user_id == user.id).Select(p => p.type + ": " + p.value); cmbRoles.ItemsSource = db.roles.Select(r => r.display_name).ToList(); cmbRoles.SelectedItem = db.roles.Where(u => u.display_name == role.display_name).FirstOrDefault().display_name; role_in_dataGrid = db.roles.Where(u => u.display_name == role.display_name).FirstOrDefault().display_name; lstContacts.ItemsSource = contacts.ToList(); FillingFromDBProjects(db); } }
public HttpResponseMessage RegisterUser(users u) { try { if (string.IsNullOrWhiteSpace(u.uname) == false && string.IsNullOrWhiteSpace(u.password) == false) { roles r = repo.Roles(); int i = repo.addUser(u, r.id); if (i > 0) // 1 means new user registered { return(Request.CreateResponse(HttpStatusCode.OK, 1)); } else // 0 means user already register { return(Request.CreateResponse(HttpStatusCode.Forbidden, 0)); } } else //3 means user password fields should not be empty { return(Request.CreateResponse(HttpStatusCode.Forbidden, 3)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
private void btnStart_Click(object sender, RoutedEventArgs e) { using (llblanca_lara1Entities db = new llblanca_lara1Entities()) { int id = Convert.ToInt32(_roleTest[1].TrimStart(' ')); roles role = db.roles.Where(u => u.id == id).FirstOrDefault(); db.roles.Attach(role); db.Entry(role).State = EntityState.Modified; db.SaveChanges(); role.name = txtName.Text; role.display_name = txtDisplayName.Text; role.description = txtDescription.Text; role.updated_at = DateTime.Now; try { db.roles.Add(role); MessageBox.Show($"Role {role.name} is update"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } this.Close(); }
public async Task <IActionResult> Putroles([FromRoute] int id, [FromBody] roles roles) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != roles.id) { return(BadRequest()); } _context.Entry(roles).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!rolesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(string id) { roles roles = db.roles.Find(id); db.roles.Remove(roles); db.SaveChanges(); return(RedirectToAction("Index")); }
private void SaveItem() { roles item = new roles(); item.Name = tbxName.Text.Trim(); item.Remark = tbxRemark.Text.Trim(); Core.Container.Instance.Resolve <IServiceRoles>().Create(item); }
private void btnEliminar_Click(object sender, EventArgs e) { roles deli = new roles(); deli.eliminar(Convert.ToInt32(dataGridView1.CurrentRow.Cells["pkRol"].Value)); cargardatos(); }
public ActionResult Details(int id) { using (var db = new inventario2021Entities()) { roles user = db.roles.Find(id); return(View(user)); } }
public bool QuiteRol(int codProyecto, string cedulaEmp) { roles rol = db.roles.Find(codProyecto, cedulaEmp); db.roles.Remove(rol); db.SaveChanges(); return(true); }
public dbUsers(DataRow row) { id_user = Convert.ToInt32(row["id_user"]); role_user = (roles)Convert.ToInt32(row["role"]); login = Convert.ToString(row["login"]); pass = Convert.ToString(row["pass"]); fio_user = Convert.ToString(row["fio"]); date = Convert.ToDateTime(row["datebirth"]); }
private void DoLogin() { SimpleAES enc = new SimpleAES(); dataset.yakkumdbTableAdapters.fa_rx_userTableAdapter ta = new dataset.yakkumdbTableAdapters.fa_rx_userTableAdapter(); dataset.yakkumdb.fa_rx_userDataTable dt = new dataset.yakkumdb.fa_rx_userDataTable(); var rv = ta.FillByNama(dt, this.txtUserSearch.Text); //string passwd = ta.GetPasswd(this.textBoxUser.Text); if (dt.Rows.Count == 0) { MessageBox.Show("Pengguna Tidak Diketahui.", "Error", MessageBoxButtons.OK); } else { string nid = dt.Rows[0]["vc_nid"].ToString(); //kirim parameter nid string passwd = dt.Rows[0]["vc_password"].ToString(); var pwd = enc.DecryptString(passwd); if (pwd == this.txtPass.Text) { string r = dt.Rows[0]["vc_role"].ToString(); switch (r) { case "dokter": this.UserRole = roles.dokter; break; case "sysadmin": this.UserRole = roles.sysadmin; break; case "drgigi": this.UserRole = roles.drgigi; break; default: break; } //this.DialogResult = DialogResult.OK; //this.usernik = nik; //_usernik = nik; //this.userNIK = nik; this.Hide(); //Eprescribe ep = new Eprescribe(nid,UserRole); //ep.ShowDialog(); MainMenu mm = new MainMenu(nid); mm.ShowDialog(); } else { MessageBox.Show("Password Salah.", "Error", MessageBoxButtons.OK); } } }
public ActionResult Details(int id) {//abriendo la conexion a la BD using (var db = new inventario2021Entities1()) { //buscar usuario por id roles user = db.roles.Find(id); return(View(user)); } }
public ActionResult DeleteConfirmed(int id) { roles roles = db.roles.Find(id); db.roles.Remove(roles); db.SaveChanges(); Request.Flash("success", "Rol Eliminado Correctamente"); return(RedirectToAction("Index")); }
public override void OnAuthorization(HttpActionContext actionContext) { string username = ""; int userLevel = 0; if (actionContext.Request.Headers == null || actionContext.Request.Headers.Authorization == null) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); } else { string id = HttpContext.Current.User.Identity.Name; UserModel userModel; if (GlobalVariable.logicType == 0) { userModel = new EntityUsersManager().GetOneUserById(id); } else if (GlobalVariable.logicType == 1) { userModel = new SqlUsersManager().GetOneUserById(id); } else if (GlobalVariable.logicType == 2) { userModel = new MySqlUsersManager().GetOneUserById(id); } else { userModel = new MongoUsersManager().GetOneUserById(id); } username = userModel.userNickName; userLevel = userModel.userLevel; value = (roles)userLevel; if (UserSecurity.Login(username, userLevel)) { if (value >= role) { Debug.WriteLine("OnAuthorization: " + value + ">=" + role); Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(username), null); } else { Debug.WriteLine("OnAuthorization: " + value + "<" + role); actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); } } else { Debug.WriteLine("OnAuthorization: " + username + " or " + userLevel + " is wrong"); actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); } } }
public void Eliminar(int id) { roles oRole = new roles { role_id = id, }; oRepositorio.Delete(oRole); oUnitOfWork.SaveChanges(); }
public bool UpdateRol(int codProyecto, string cedulaEmp) { roles rol = db.roles.Create(); rol.codigoProyectoFK = codProyecto; rol.cedulaFK = cedulaEmp; rol.rol = "desarrollador"; db.SaveChanges(); return(true); }
public ActionResult Edit([Bind(Include = "id_rol,rol,descripcion")] roles roles) { if (ModelState.IsValid) { db.Entry(roles).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(roles)); }
/* * Efecto: retorna string que representa cédula de líder de proyecto * Requiere: código del proyecto * No realiza modificaciones */ public string getLiderId(int codProyecto) { roles rol = db.roles.FirstOrDefault(r => r.codigoProyectoFK == codProyecto && r.rol == "Líder"); if (rol == null) { return(null); } return(rol.cedulaFK); }
private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); int id = GetQueryIntValue("id"); users current = Core.Container.Instance.Resolve <IServiceUsers>().GetEntity(id); //User item = DB.Users // .Include(u => u.Dept) // .Include(u => u.Roles) // .Include(u => u.Titles) // .Where(u => u.ID == id).FirstOrDefault(); //item.Name = tbxName.Text.Trim(); if (current == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } labName.Text = current.Name; labRealName.Text = current.ChineseName; labCompanyEmail.Text = current.CompanyEmail; labEmail.Text = current.Email; labCellPhone.Text = current.CellPhone; labOfficePhone.Text = current.OfficePhone; labOfficePhoneExt.Text = current.OfficePhoneExt; labHomePhone.Text = current.HomePhone; labRemark.Text = current.Remark; labEnabled.Text = current.Enabled ? "启用" : "禁用"; labGender.Text = current.Gender; // 用户所属角色 IList <ICriterion> qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("UserID", current.ID)); IList <roleusers> entityList = Core.Container.Instance.Resolve <IServiceRoleUsers>().GetAllByKeys(qryList); List <roles> roleList = new List <roles>(); foreach (roleusers obj in entityList) { roles entity = Core.Container.Instance.Resolve <IServiceRoles>().GetEntity(obj.RoleID); roleList.Add(entity); } labRole.Text = String.Join(",", roleList.Select(r => r.Name).ToArray()); // 用户所属的部门 if (current.DeptID != 0) { depts Dept = Core.Container.Instance.Resolve <IServiceDepts>().GetEntity(current.DeptID); labDept.Text = Dept.Name; } }
public ActionResult Edit([Bind(Include = "id_rol,nombre")] roles roles) { if (ModelState.IsValid) { db.Entry(roles).State = EntityState.Modified; db.SaveChanges(); Request.Flash("success", "Rol Editado Correctamente"); return(RedirectToAction("Index")); } return(View(roles)); }
public bool Update_roles(roles roles) { if (DbHelperSQL.Update(roles)) { return(true); } else { return(false); } }
public bool Del_roles(roles roles) { if (DbHelperSQL.Delete(roles)) { return(true); } else { return(false); } }