public User LogIn(string username, string password, TypeUser type) { List <User> auxUserList = new List <User>(); switch (type) { case TypeUser.Student: auxUserList = usersStudent; break; case TypeUser.Orientador: auxUserList = usersOrientador; break; case TypeUser.Admin: auxUserList = usersAdmin; break; } for (int i = 0; i < auxUserList.Count; i++) { if (auxUserList[i].username == username) { return(auxUserList[i]); } } return(null); }
public List <User> GetAllUserInListUser() { List <User> users = new List <User>(); DataTable dt = new DataTable(); using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand("GetAllUserWithIdTypeUser", connection)) { command.CommandType = CommandType.StoredProcedure; using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command)) { dataAdapter.Fill(dt); } } connection.Close(); } foreach (DataRow dr in dt.Rows) { TypeUser typeUser = new TypeUser(); users.Add( new User { Id = Convert.ToInt32(dr["Id"]), Name = Convert.ToString(dr["Name"]), Surname = Convert.ToString(dr["Surname"]), Email = Convert.ToString(dr["Email"]), Password = Convert.ToString(dr["Password"]), IdTypeUser = (TypeUser)Convert.ToInt32(dr["IdTypeUser"]) //IdTypeUser = Enum.Parse(typeof(TypeUser), Convert.ToInt32[(dr["IdTypeUser"])]) }); } return(users); }
public void InitUI() { // set banners color //panelBanner.BackColor = Configurations.PartieInfo.PrimaryColor; //statusStripBanner.BackColor = Configurations.PartieInfo.SecondaryColor; comboBoxProvince.BeginUpdate(); comboBoxProvince.Items.Clear(); comboBoxTypeUser.BeginUpdate(); comboBoxTypeUser.Items.Clear(); //foreach (var user in _userContext.VoteDbContext.Users.Where(user => user.OwnerId == _userContext.User.Id || user.Id == _userContext.User.Id).OrderBy(user => user.Name)) //{ // listBoxUsers.Items.Add(new DisplayItem<User>(user)); //} UpdateUserView(); foreach (Province province in _userContext.VoteDbContext.Provinces) { comboBoxProvince.Items.Add(new DisplayItem <Province>(province)); } foreach (string item in Enum.GetNames(typeof(TypeUser))) { TypeUser obj = (TypeUser)Enum.Parse(typeof(TypeUser), item); DisplayItem <TypeUser> displayItem = new DisplayItem <TypeUser>(obj) { DisplayProperty = item, }; comboBoxTypeUser.Items.Add(displayItem); } comboBoxProvince.EndUpdate(); comboBoxTypeUser.EndUpdate(); }
private void ComboBoxTypeUser_SelectedIndexChanged(object sender, EventArgs e) { TypeUser typeUser = ((DisplayItem <TypeUser>)comboBoxTypeUser.SelectedItem).Item; comboBoxProvince.Enabled = typeUser == TypeUser.Admin; if (comboBoxProvince.Enabled && comboBoxProvince.Items.Count > 0) { comboBoxProvince.SelectedIndex = 0; } }
public bool Update(long Id, PersonaBE Be) { try { var flag = false; if (Be != null) { if (TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 1 || TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 2) { Be.id_plan = 20; } var entity = Factory.FactoryPersona.GetInstance().CreateEntity(Be); if (entity.usuarios != null) { foreach (var item in entity.usuarios) { if (item.modulos_usuarios != null) { foreach (var mod in item.modulos_usuarios) { _unitOfWork.Modulo_Usuario_repository.Update(mod, new List <string>() { "id_modulo", "id_usuario", "alta", "baja", "modificacion", "consulta" }); } } item.modulos_usuarios = null; //_unitOfWork.UsuarioRepository.Update(item, new List<string>() { "nombre_usuario", "clave","habilitado","email","cambia_clave" }); } } entity.usuarios = null; _unitOfWork.PersonaRepository.Update(entity, new List <string>() { "id_plan", "nombre", "apellido", "direccion", "telefono", "fecha_nac", "legajo", "tipo_persona" }); _unitOfWork.Commit(); flag = true; return(flag); } else { throw new ApiBusinessException(1012, "No se pudo Modificar por que la entidad no esta completa", System.Net.HttpStatusCode.NotFound, "Http"); } } catch (Exception ex) { throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex); } }
private async Task <TypeUser> CheckType(string Type) { var Types = _dataContext.TypeUsers.FirstOrDefault(x => x.Type == Type); if (Types == null) { var type = new TypeUser { Type = Type }; _dataContext.TypeUsers.Add(type); await _dataContext.SaveChangesAsync(); return(type); } return(Types); }
private void btnLogin_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtPassword.Text)) { DataBase db = new DataBase(); Classes.Login login = new Classes.Login(); login.Email = txtEmail.Text; login.Password = txtPassword.Text; User user = new User(); user = db.GetUserFromLogin(login); if (user.IdTypeUser != 0) { TypeUser typeUser = user.IdTypeUser; switch (typeUser) { case TypeUser.Organizzatore: AddParticipants addParticipants = new AddParticipants(); addParticipants.Show(); this.Hide(); break; case TypeUser.Invitato: Partecipant guest = new Partecipant(); guest.Show(); this.Hide(); break; case TypeUser.Utente: Activity activity = new Activity(); activity.Show(); this.Hide(); break; } } else { MessageBox.Show("Dati errati"); } } else { MessageBox.Show("Compila tutti i campi"); } }
public long Create(PersonaBE Be) { try { if (Be != null) { Be.legajo = GetLastLegajo(); Be.Usuarios[0].nombre_usuario = GetLastLegajo().ToString(); if (TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 1 || TypeUser.GetInstance().GetTyperUser(Be.tipo_persona) == 2) { Be.id_plan = 20; } DataModel.personas entity = Factory.FactoryPersona.GetInstance().CreateEntity(Be); Expression <Func <DataModel.personas, Boolean> > predicate = x => (x.telefono == entity.telefono); DataModel.personas verify = _unitOfWork.PersonaRepository.GetOneByFilters(predicate, new string[] { "usuarios.modulos_usuarios" }); if (verify != null) { throw new ApiBusinessException(1012, "Ya existe un usuario con ese numero de telefono", System.Net.HttpStatusCode.Forbidden, "Http"); } var email = entity.usuarios.FirstOrDefault().email.ToString(); Expression <Func <DataModel.usuarios, Boolean> > predicateuser = x => (x.email == email); DataModel.usuarios usur = _unitOfWork.UsuarioRepository.GetOneByFilters(predicateuser, new string[] { "modulos_usuarios" }); if (usur != null) { throw new ApiBusinessException(1012, "Ya existe un usuario con ese email", System.Net.HttpStatusCode.Forbidden, "Http"); } _unitOfWork.PersonaRepository.Insert(entity); _unitOfWork.Commit(); return(entity.id_persona); } else { throw new ApiBusinessException(1012, "No se pudo crear el plan", System.Net.HttpStatusCode.NotFound, "Http"); } } catch (Exception ex) { throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex); } }
/** * Author | Arcelia Aguirre * Description | Inicializar el form * Date | 23-02-2018 * Parameters | object sender, EventArgs e */ private void frm_signIn_Load(object sender, EventArgs e) { TypeUser typeUser = new TypeUser(); TypeNotStudent typeNotStudent = new TypeNotStudent(); Career career = new Career(); UserCICE userCICE = new UserCICE(); Student.Student student = new Student.Student(); try { /*Combobox*/ typeUser.load_cmbbxTypeUser(ds, cmbbx_typeUser); typeNotStudent.load_cmbbxReport(ds, cmbbx_report); typeNotStudent.load_cmbbxReport(ds, cmbbx_type); typeNotStudent.load_cmbbxReport(ds, cmbbx_typeRegister); career.load_cmbbxCarrer(ds, cmbbx_carrer); career.load_cmbbxCarrer(ds, cmbbox_careerStudent); DataTable dt = cmbbx_typeRegister.DataSource as DataTable; DataRow row = dt.NewRow(); row["description_typeNotStudent"] = "Alumno"; dt.Rows.Add(row); cmbbx_typeRegister.SelectedIndex = cmbbx_typeRegister.Items.Count - 1; /*Grid*/ career.load_dtgdCareer(ds, dtgd_career); typeNotStudent.load_dtgdTypeNotStudent(ds, dtgd_typeNotStudent); typeUser.load_dtgdTypeUser(ds, dtgd_typeUser); userCICE.load_dtgdUser(ds, dtgd_user); student.load_dtgdStudent(ds, dtgd_student); /*DataBase*/ DataBaseSettings dataBaseSettings = new DataBaseSettings(); btn_create.Enabled = dataBaseSettings.ifExist().Rows.Count == 0 ? true : false; btn_drop.Enabled = !btn_create.Enabled; } catch { Button[] component = { btn_create, btn_drop, btn_seeder, btn_delete, btn_deleteDuplicate }; PROPS.enableButton(component); //PROPS.messageError(""); } }
public void ChangeTypeOfUser(int typeUser) { switch (typeUser) { case 1: _typeUser = TypeUser.Student; break; case 2: _typeUser = TypeUser.Orientador; break; case 3: _typeUser = TypeUser.Admin; break; } }
public static void DecryptionCommand(string command, out TypeUser typeUser, out int lesson, out string dayOfWeek) { lesson = Convert.ToInt32(command.Substring(2, 1)); dayOfWeek = command.Split("_").First().Substring(3); string user = command.Substring(1, 1); if (user == "p") { typeUser = TypeUser.Pupil; } else if (user == "t") { typeUser = TypeUser.Teacher; } else { typeUser = TypeUser.Pupil; // TODO: this } }
/** * Author | Arcelia Aguirre * Description | Agregar nuevo tipo usuario * Date | 23-02-2018 * Parameters | object sender, EventArgs e */ private void btn_typeUserSave_Click(object sender, EventArgs e) { TextBox[] component = { txt_typeUserName }; TypeUser typeUser = new TypeUser(); if (!PROPS.emptyComponent(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX)) { return; } component = new TextBox[] { txt_idTypeUser, txt_typeUserName }; if (txt_idTypeUser.Text == PROPS.EMPTY) { typeUser.save(txt_typeUserName.Text); } else { typeUser.update(Int32.Parse(txt_idTypeUser.Text), txt_typeUserName.Text); } PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); typeUser.load_dtgdTypeUser(ds, dtgd_typeUser); }
/** * Author | Arcelia Aguirre * Description | Datos para eliminar y modificar Tipo Usuario * Date | 27-02-2018 * Parameters | object sender, DataGridViewCellEventArgs e */ private void dtgd_typeUser_CellContentClick(object sender, DataGridViewCellEventArgs e) { TextBox[] component = { txt_idTypeUser, txt_typeUserName }; TypeUser typeUser = new TypeUser(); PROPS.clear(component, (int)PROPS.COMPONENT.COMPONENT_TEXT_BOX); if (this.dtgd_typeUser.Columns[e.ColumnIndex].Name.Equals("delete_typeUser")) { if (MessageBox.Show("¿Seguro que quieres borrar el Tipo de Usuario?", "Borrar", MessageBoxButtons.YesNo) == DialogResult.Yes) { typeUser.delete(Int32.Parse(dtgd_typeUser.CurrentRow.Cells["id_typeUser"].Value.ToString())); } typeUser.load_dtgdTypeUser(ds, dtgd_typeUser); return; } else if (this.dtgd_typeUser.Columns[e.ColumnIndex].Name.Equals("edit_typeUser")) { txt_idTypeUser.Text = dtgd_typeUser.CurrentRow.Cells["id_typeUser"].Value.ToString(); txt_typeUserName.Text = dtgd_typeUser.CurrentRow.Cells["description_typeUser"].Value.ToString(); } }
public new AdministrativeEmployee Map(DbDataReader dbDataReader) { string id, firstName, secondName, lastName, secondLastName, cellphone, email, address, username, passwordname; id = dbDataReader.GetString(0); firstName = dbDataReader.GetString(1); secondName = dbDataReader.GetString(2); lastName = dbDataReader.GetString(3); secondLastName = dbDataReader.GetString(4); cellphone = dbDataReader.GetString(5); email = dbDataReader.GetString(6); address = dbDataReader.GetString(7); username = dbDataReader.GetString(8); passwordname = dbDataReader.GetString(9); string typeUserStr = dbDataReader.GetString(10); TypeUser typeUser = (typeUserStr == "S") ? TypeUser.SuperUser : ((typeUserStr == "D") ? TypeUser.Dispatcher : TypeUser.Administrator); return(new AdministrativeEmployee(id, firstName, secondName, lastName, secondLastName, cellphone, email, address, new User(username, passwordname, typeUser))); }
private void InitUI(TypeUser typsUser) { LayoutButtons(); if (typsUser == TypeUser.SuperAdmin) { labelProvince.Enabled = false; labelProvince.Visible = false; comboBoxProvince.Enabled = false; comboBoxProvince.Visible = false; } else { using (voteAppEntities dbContext = new voteAppEntities()) { foreach (Province province in dbContext.Provinces) { comboBoxProvince.Items.Add(new DisplayItem <Province>(province)); } } } }
public User(string name = "Guest", string pass = "", TypeUser loaiUser = TypeUser.KHACH) { Name = name; Pass = pass; LoaiUser = loaiUser; }
private async Task <User> CheckUserAsync(string document, TypeDocument TypeDocument, string firstName, string lastName, string email, string phone, string address, bool state, TypeUser role) { var user = await _userHelper.GetUserByEmailAsync(email); if (user == null) { user = new User { FirstName = firstName, TypeDocument = TypeDocument, LastName = lastName, Email = email, UserName = email, PhoneNumber = phone, Address = address, Document = document, TypeUser = role, State = state }; await _userHelper.AddUserAsync(user, "123456"); await _userHelper.AddUserToRoleAsync(user, role.Type); } return(user); }
public UserCreateVM() { user = new User(); TypeUsers = TypeUser.GetAllTypeUsers(); }
public UserEditVM(long ID_USER) { user = User.GetUser(ID_USER); TypeUsers = TypeUser.GetAllTypeUsers(); }
private void buttonAddUser_Click(object sender, EventArgs e) { // Add standard user to same province as logged in user. string userName = textBoxUserName.Text.Trim(); string fullName = textBoxFullName.Text.Trim(); string password = textBoxPassword.Text.Trim(); string passwordConfirm = textBoxConfirmPassword.Text.Trim(); if (_userContext.VoteDbContext.Users.Any(u => u.Name.Equals(userName, StringComparison.Ordinal))) { // user exits MessageBox.Show("Users already exits!"); return; } if (!DataValidator.IsValidUserName(userName)) { MessageBox.Show("Invalid user name!"); // notify error return; } if (string.IsNullOrEmpty(fullName)) { MessageBox.Show("Invalid Full-Name"); return; } if (!DataValidator.IsValidFullName(fullName)) { MessageBox.Show("Invalid user name!"); textBoxFullName.Focus(); return; } if (!password.Equals(passwordConfirm, StringComparison.Ordinal)) { MessageBox.Show("Invalid password!"); return; } if (comboBoxTypeUser.SelectedItem == null) { MessageBox.Show("Select type user!"); comboBoxTypeUser.Focus(); return; } Province province = ((DisplayItem <Province>)comboBoxProvince.SelectedItem).Item; TypeUser typeUser = ((DisplayItem <TypeUser>)comboBoxTypeUser.SelectedItem).Item; (string hashPassword, string salt) = PwdUtils.GetSaltyPassword(password); User user = new User { Enabled = true, Name = userName, FullName = fullName, Password = hashPassword, DateCreation = DateTime.Now, Type = typeUser, ProvinceId = comboBoxProvince.Enabled ? province.Id : 0,// 0 is none for non-admin users OwnerId = _userContext.ID, Salt = salt }; _userContext.VoteDbContext.Users.Add(user); _userContext.VoteDbContext.SaveChanges(); MessageBox.Show("User added"); UpdateUserView(); }
public UsersVM(long ID_USER) { Users = User.GetAllUsers(ID_USER); TypeUsers = TypeUser.GetAllTypeUsers(); }
public User(string user, string password, TypeUser typeUser) { AccessData = new AccessData(user, password); TypeUser = typeUser; }