private void btnAdduser_Click(object sender, EventArgs e) { bool equals = true; foreach (Appuser a in AppuserDAO.getLista()) { if (a.username.Equals(txtUsername.Text)) { equals = true; } else { equals = false; } } if (!equals) { AppuserDAO.CreateUser(txtnewUser.Text, txtUsername.Text, txtUsername.Text, rdioAdSi.Checked); MessageBox.Show("¡User has been added!", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); updatecontrols(); } else { MessageBox.Show("¡User already exist!", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); updatecontrols(); } }
private void btnDelateuser_Click(object sender, EventArgs e) { AppuserDAO.delateUser(Convert.ToInt32(cmbUsers.SelectedValue.ToString())); MessageBox.Show("¡User has been deleted!", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); updatecontrols(); }
private void updatecontrols() { txtnewUser.Clear(); txtUsername.Clear(); cmbUsers.DataSource = null; cmbUsers.ValueMember = "idUser"; cmbUsers.DisplayMember = "username"; cmbUsers.DataSource = AppuserDAO.getLista(); txtDescription.Clear(); txtNameB.Clear(); cmbBusiness.DataSource = null; cmbBusiness.ValueMember = "idBusiness"; cmbBusiness.DisplayMember = "name"; cmbBusiness.DataSource = BussinessDAO.getLista(); cmbCreatP.DataSource = null; cmbCreatP.ValueMember = "idBusiness"; cmbCreatP.DisplayMember = "name"; cmbCreatP.DataSource = BussinessDAO.getLista(); cmbBussinesP.DataSource = null; cmbBussinesP.ValueMember = "idBusiness"; cmbBussinesP.DisplayMember = "name"; cmbBussinesP.DataSource = BussinessDAO.getLista(); cmbProductsex.DataSource = null; txtProduct.Clear(); actualizarDatagrid(); }
private void ChangePassword_Load(object sender, EventArgs e) { cmbUsername.DataSource = null; cmbUsername.ValueMember = "password"; cmbUsername.DisplayMember = "username"; cmbUsername.DataSource = AppuserDAO.getLista(); }
private void btnCambiarContra_Click(object sender, EventArgs e) { bool actualIgual = txtActual.Text.Equals(cmbUsuario.SelectedValue.ToString()); bool nuevaIgual = txtNueva.Text.Equals(txtRepetir.Text); bool nuevaValida = txtNueva.Text.Length > 0; if (actualIgual && nuevaIgual && nuevaValida) { try { Appuser u = (Appuser)cmbUsuario.SelectedItem; AppuserDAO.updateAppuser(u.IdUser, txtNueva.Text); MessageBox.Show("¡Contraseña actualizada exitosamente!", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { MessageBox.Show("¡Contraseña no actualizada! Favor intente mas tarde.", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("¡¡Favor verifique que los datos sean correctos!", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void UpdateControls() { cmbUsername.DataSource = null; cmbUsername.ValueMember = "password"; cmbUsername.DisplayMember = "username"; cmbUsername.DataSource = AppuserDAO.getLista(); txtPassword.Clear(); }
private void poblarControles() { // Actualizar ComboBox cmbUsuario.DataSource = null; cmbUsuario.ValueMember = "Password"; cmbUsuario.DisplayMember = "Username"; cmbUsuario.DataSource = AppuserDAO.getLista(); }
private void actualizarDatagrid() { var dt = AppuserDAO.allusers(); dtvusers.DataSource = dt; var dtTable = AppOrderDAO.ordertable(); dtvOrders.DataSource = dtTable; }
private void button1_Click_1(object sender, EventArgs e) { Appuser u = (Appuser)cmbAlterAppuser.SelectedItem; if (MessageBox.Show("¿Seguro que desea eliminar al usuario ?", "Hugo App", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { AppuserDAO.delete(u.IdUser); MessageBox.Show("¡Usuario eliminado exitosamente!", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); } actualizarControles(); }
private void btnChangeP_Click(object sender, EventArgs e) { Appuser u = (Appuser)cmbUsername.SelectedItem; bool actualIgual = txtCurrent.Text.Equals(cmbUsername.SelectedValue.ToString()); bool nuevaIgual = txtNew.Text.Equals(txtConfirm.Text); bool nuevavalida = false; try { if (txtNew.Text.Length < 3) { throw new InvalidPasswordException(); } else { nuevavalida = true; } } catch (InvalidPasswordException) { MessageBox.Show("¡Ups! the password is too short!.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (actualIgual && nuevaIgual && nuevavalida) { try { AppuserDAO.updatePassword(u.idUser, txtNew.Text); MessageBox.Show("¡The password has been changed succesfully!", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { MessageBox.Show("¡Ups! Please try later.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("¡Verify if the password is correct!", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void button2_Click(object sender, EventArgs e) { Appuser u = new Appuser(); u.Fullname = txtAdminUserFull.Text; u.Username = txtAdminUserName.Text; u.Password = "******"; u.UserType = chbAdmin.Checked; if (MessageBox.Show("¿Seguro que desea agregar al usuario ?", "Hugo App", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { AppuserDAO.addAppuser(u); MessageBox.Show("¡Usuario agregado exitosamente; la contrasena es password!", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); } actualizarControles(); }
private void actualizarControles() { //tabla negocios dgvBusiness.DataSource = null; dgvBusiness.DataSource = BusinessDAO.getLista(); //dgvProducts dgvProducts.DataSource = null; dgvProducts.DataSource = ProductDAO.getLista(); //cmbRemoveBusiness cmbRemoveBusiness.DataSource = null; cmbRemoveBusiness.ValueMember = "IdBusiness"; cmbRemoveBusiness.DisplayMember = "Name"; cmbRemoveBusiness.DataSource = BusinessDAO.getLista(); //cmbAddProductBusiness cmbAddProductBusiness.DataSource = null; cmbAddProductBusiness.ValueMember = "IdBusiness"; cmbAddProductBusiness.DisplayMember = "Name"; cmbAddProductBusiness.DataSource = BusinessDAO.getLista(); //cmbRmvProdc Business b = (Business)cmbAddProductBusiness.SelectedItem; cmbRmvProdc.DataSource = null; cmbRmvProdc.ValueMember = "IdProduct"; cmbRmvProdc.DisplayMember = "Name"; cmbRmvProdc.DataSource = ProductDAO.getLista(b); //cmbAlterAppuser cmbAlterAppuser.DataSource = null; cmbAlterAppuser.ValueMember = "IdUser"; cmbAlterAppuser.DisplayMember = "Username"; cmbAlterAppuser.DataSource = AppuserDAO.getLista(); //dgvAdminOrders dgvAdminOrders.DataSource = null; dgvAdminOrders.DataSource = AppuserDAO.getLista(); poblarGrafico(); }