private void actualizarControlesAdmin() { List <AppUser> listau = AppUserDao.getListaUsu(); cmbEliminarUsu.DataSource = null; cmbEliminarUsu.DisplayMember = "iduser"; cmbEliminarUsu.DataSource = listau; dgvVerUsuarios.DataSource = listau; List <Business> listab = BusinessDAO.getListaBusiness(); cmbEliminarNegocio.DataSource = null; cmbEliminarNegocio.DisplayMember = "idbusiness"; cmbEliminarNegocio.DataSource = listab; dataGridView1.DataSource = listab; cmbAddProduct.DataSource = null; cmbAddProduct.DisplayMember = "idbusiness"; cmbAddProduct.DataSource = listab; List <Product> listap = ProductDAO.GetListaProducts(); combEliminarProd.DataSource = null; combEliminarProd.DisplayMember = "idproduct"; combEliminarProd.DataSource = listap; dgvVerProductos.DataSource = listap; List <AppOrder> listao = AppOrderDAO.getListaOrders(); dgvVerOrdenes.DataSource = listao; }
private void UpdateCmbBusiness() { cmbBusiness.DataSource = null; cmbBusiness.ValueMember = nameof(Business.IdBusiness); cmbBusiness.DisplayMember = nameof(Business.Name); cmbBusiness.DataSource = BusinessDAO.GetBusiness(); }
private void PoblarControles() { comboBox1.DataSource = null; comboBox1.ValueMember = "idBusiness"; comboBox1.DisplayMember = "name"; comboBox1.DataSource = BusinessDAO.getLista(); }
private void btnDeleteBusiness_Click(object sender, EventArgs e) { if (cmbBusiness.Items.Count == 0) { MessageBox.Show("Actualmente no hay negocios registrados.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { var business = (Business)cmbBusiness.SelectedItem; if (MessageBox.Show($"¿Desea borrar el negocio {business.Name}?", "Hugo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BusinessDAO.DeleteBusiness(business); UpdateCmbBusiness(); MessageBox.Show($"{business.Name} ha sido eliminado con éxito.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("La operación ha sido abortada.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnCreateBusiness_Click(object sender, EventArgs e) { if (txtBusinessName.Text.Equals("") || txtBusinessDescription.Text.Equals("")) { MessageBox.Show("Debe llenar los campos.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { Business business = new Business(); business.Name = txtBusinessName.Text; business.Description = txtBusinessDescription.Text; BusinessDAO.CreateBusiness(business); MessageBox.Show("El negocio ha sido ingresado con éxito.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Information); UpdateCmbBusiness(); } catch (Exception exception) { MessageBox.Show("Ha ocurrido un error.", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } txtBusinessDescription.Clear(); txtBusinessName.Clear(); }
public BusinessManage() { InitializeComponent(); this.dataGridView1.DataSource = BusinessDAO.SelectFromBusiness(); business = BusinessDAO.GetList(); removeTextInit = this.label5.Text; resetComboBox2(); }
private void button2_Click(object sender, EventArgs e) { int num = this.comboBox2.SelectedIndex; if (num != -1) { BusinessDAO.RemoveBusiness(business[num].id); resetComboBox2(); this.dataGridView1.DataSource = BusinessDAO.SelectFromBusiness(); } else { MessageBox.Show("Selecciona una opcion antes de eliminar"); } }
private void button1_Click(object sender, EventArgs e) { if (!this.textBox1.Text.Equals("") && !this.textBox2.Text.Equals("")) { BusinessDAO.AddNew($"'{this.textBox1.Text}','{this.textBox2.Text}'"); this.textBox1.Text = ""; this.textBox2.Text = ""; this.dataGridView1.DataSource = BusinessDAO.SelectFromBusiness(); resetComboBox2(); } else { MessageBox.Show("Completa los campos"); } }
private void resetComboBox2() { business = BusinessDAO.GetList(); var names = new object[business.Count]; int n = 0; foreach (var i in business) { names[n] = i.id + " - " + i.name; n++; } this.comboBox2.SelectedIndex = -1; this.comboBox2.Items.Clear(); this.comboBox2.Items.AddRange(names); }
private void btnEliminarNegocio_Click(object sender, EventArgs e) { try { BusinessDAO.EliminarBus(Convert.ToInt32(txtBusID.Text)); MessageBox.Show("Eliminado con exito", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); ActualizarControles(); } catch (Exception exception) { MessageBox.Show("El negocio no existe.", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private void btnAddNegocio_Click(object sender, EventArgs e) { try { BusinessDAO.CrearNuevo(txtBusName.Text, txtBusDesc.Text); MessageBox.Show("Ingresado con exito", "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information); ActualizarControles(); } catch (Exception exception) { MessageBox.Show(exception.Message, "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
public ProductsManage() { InitializeComponent(); this.dataGridView1.DataSource = ProductDAO.SelectFromProduct(); removeTextInit = this.label5.Text; business = BusinessDAO.GetList(); var names = new object[business.Count]; int n = 0; foreach (var i in business) { names[n] = i.id + " - " + i.name; n++; } this.comboBox1.Items.AddRange(names); this.comboBox2.Items.AddRange(names); }
private void UpdateCmbBusiness() { //ComboBox de pestaña negocios cmbBusiness.DataSource = null; cmbBusiness.ValueMember = "IdBusiness"; cmbBusiness.DisplayMember = "Name"; cmbBusiness.DataSource = BusinessDAO.GetBusiness(); //ComboBox de agregar producto cmbProductBusiness.DataSource = null; cmbProductBusiness.ValueMember = "IdBusiness"; cmbProductBusiness.DisplayMember = "Name"; cmbProductBusiness.DataSource = BusinessDAO.GetBusiness(); //ComboBox de borrar producto cmbDeleteProductBusiness.DataSource = null; cmbDeleteProductBusiness.ValueMember = "IdBusiness"; cmbDeleteProductBusiness.DisplayMember = "Name"; cmbDeleteProductBusiness.DataSource = BusinessDAO.GetBusiness(); UpdateCmbProduct(cmbDeleteProductBusiness.Items.Count > 0? ((Business)cmbDeleteProductBusiness.SelectedItem).IdBusiness:0); }
private void btnEliminarNegocio_Click(object sender, EventArgs e) { try { if (cmbEliminarNegocio.Text.Length > 0) { BusinessDAO.eliminarNegocio(Convert.ToInt32(cmbEliminarNegocio.Text)); MessageBox.Show("¡Negocio eliminado exitosamente!", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Information); actualizarControlesAdmin(); } else { MessageBox.Show("Favor seleccione un negocio ", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception) { MessageBox.Show("El negocio que ha seleccionado, no se encuentra disponible.", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAgregarNegocio_Click(object sender, EventArgs e) { try { if (txtNegocio.Text.Length > 5 && txtDescripcion.Text.Length > 5) { BusinessDAO.insertarNegocio(txtNegocio.Text, txtDescripcion.Text); MessageBox.Show("¡Negocio agregado exitosamente!.", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Information); actualizarControlesAdmin(); } else { MessageBox.Show("Favor digite un negocio (longitud minima, 5 caracteres)", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception) { MessageBox.Show("El negocio que ha digitado, no se encuentra disponible.", "SourceCode", MessageBoxButtons.OK, MessageBoxIcon.Error); } }