private void crearBotones() { NegocioCategorias negCat = new NegocioCategorias(); ArrayList categorias = negCat.getCate(); foreach (Cate item in categorias) { Button e = new Button(); int width = panel1.Width; if (i > width) { i = 0; top += 70; } e.Name = item._ID_Cate + ""; e.Text = item._nombre; e.Left = i; e.Top = top; e.Height = 62; e.Width = 62; e.TextAlign = ContentAlignment.MiddleCenter; i += 70; panel1.Controls.Add(e); } top = 0; i = 0; }
private void btnEliminar_Click(object sender, EventArgs e) { NegocioCategorias negCate = new NegocioCategorias(); Cate categoria = negCate.buscarCategoriaString(cmbCategoria.SelectedItem.ToString()); if (cmbCategoria.SelectedItem != null) { DialogResult opcion = 0; opcion = MessageBox.Show("¿Estás Seguro Que Quieres Eliminar Esta Categoría?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (opcion == DialogResult.Yes) { NegocioCategorias negCategoria = new NegocioCategorias(); Cate cate = negCategoria.buscarCategoriaString(cmbCategoria.SelectedItem.ToString()); negCategoria.eliminarCategoria(cate._ID_Cate); this.Close(); MessageBox.Show("La Categoría Fue Eliminada Correctamente", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Error Debe Seleccionar Una Categoría Antes de Modificar el Nombre", "Error"); } }
private void llenarCombo() { NegocioCategorias negCat = new NegocioCategorias(); ArrayList cat = negCat.getCate(); foreach (Cate item in cat) { cmbCategoria.Items.Add(item._nombre); } }
public void cargarProductos() { NegocioCategorias negCli = new NegocioCategorias(); System.Collections.IEnumerator mostrar = negCli.getCate().GetEnumerator(); while (mostrar.MoveNext()) { Cate ca = (Cate)mostrar.Current; TabPage tab = new TabPage(); tab.Text = ca._nombre; tab.Name = ca._ID_Cate + ""; tbcProducts.Controls.Add(tab); } NegocioProducto negPro = new NegocioProducto(); IEnumerator tabpages = tbcProducts.TabPages.GetEnumerator(); while (tabpages.MoveNext()) { int izq = 10; int ar = 10; TabPage tab = (TabPage)tabpages.Current; ArrayList productos = negPro.getProductosxcate(int.Parse(tab.Name)); foreach (Producto itpro in productos) { Label lbl = new Label(); lbl.Name = itpro._ID_Producto + ""; lbl.Text = itpro._nombre; lbl.TextAlign = ContentAlignment.MiddleCenter; lbl.Width = 50; lbl.Left = izq; if (izq > tab.Width) { izq = 0; ar += 20; } lbl.Top = ar; AsignarEventos(lbl); tab.Controls.Add(lbl); izq += 50; } } }
private void NombreCategoria_Load(object sender, EventArgs e) { timer1.Start(); this.txtNombreCategoria.Select(); switch (Categoria.seleccion) { //Agregar Nueva Categoria case 1: cmbCategoria.Visible = false; btnModificar.Visible = false; btnEliminar.Visible = false; break; //Modificar Categoria case 2: cmbCategoria.Visible = true; btnModificar.Visible = true; btnAceptar.Visible = false; btnEliminar.Visible = false; NegocioCategorias negCategoria = new NegocioCategorias(); Cate categoria = negCategoria.buscarCategoria(Convert.ToInt32(lblID.Text)); cmbCategoria.SelectedValue = categoria; break; //Eliminar Categoria case 3: cmbCategoria.Visible = true; btnAceptar.Visible = false; btnModificar.Visible = false; NegocioCategorias negCategorias = new NegocioCategorias(); Cate categorias = negCategorias.buscarCategoria(Convert.ToInt32(lblID.Text)); cmbCategoria.SelectedValue = categorias; break; } ArrayList nombreBotones = Categoria.nombotones; foreach (string item in nombreBotones) { cmbCategoria.Items.Add(item); } }
protected void btn_Aceptar_Click(object sender, EventArgs e) { if (txt_NombreSucursal.Text.Trim().Length == 0 || txt_Descripcion.Text.Trim().Length == 0 || txt_Direccion.Text.Trim().Length == 0) { lblAgregarSucursal.Text = "No se aceptan campos vacios"; } else { Sucursal suc = new Sucursal(); NegocioCategorias neg = new NegocioCategorias(); suc.NombreSucursal = txt_NombreSucursal.Text; suc.DescripcionSucursal = txt_Descripcion.Text; suc.DireccionSucursal = txt_Direccion.Text; suc.Id_ProvinciaSucursal = ddl_Provincias.SelectedValue; neg.GuardarSucursal(suc); lblAgregarSucursal.Text = "Agregado con éxito"; } }
private void btnAceptar_Click(object sender, EventArgs e) { if (txtNombreCategoria.Text.Equals("")) { MessageBox.Show("Debe Ingresar un nombre para la categoria", "Error de Ingreso"); } else { lblID.Text = (i).ToString(); NegocioCategorias negCategoria = new NegocioCategorias(); NegocioProducto negProducto = new NegocioProducto(); Cate categoria = negCategoria.buscarCategoriaString(txtNombreCategoria.Text.Trim()); if (categoria._nombre.Equals(txtNombreCategoria.Text.Trim())) { MessageBox.Show("Ya existe una categoria con el nombre " + txtNombreCategoria.Text); } else { Cate cate = new Cate(); Producto pro = new Producto(); nombreCategoria = txtNombreCategoria.Text.Trim(); MessageBox.Show(nombreCategoria); cate._nombre = nombreCategoria; cate._ID_Cate = Convert.ToInt32(lblID.Text); pro._categoria = Convert.ToInt32(lblID.Text); negCategoria.insertarCategoria(cate); this.Close(); } } }