private void LlenarGrilla() { this.dgvProductos.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.dgvProductos.MultiSelect = false; this.dgvProductos.ReadOnly = true; ManProducto man = new ManProducto(); dgvProductos.DataSource = man.TodosProductos(); }
private void CargarDatos() { ManProducto man = new ManProducto(); DataTable dtFamilia = man.GetFamiliaProducto(); if (dtFamilia == null) { lbMsg.Text = "problema al cargar familia"; } else { for (int i = 0; i < dtFamilia.Rows.Count; i++) { DataRow row = dtFamilia.Rows[i]; cbxFamilia.Items.Add(row[1]); } } cbxFamilia.Items.Insert(0, "-Seleccione-"); cbxFamilia.SelectedIndex = 0; DataTable dtTipo = man.GetTipoProducto(); if (dtTipo == null) { lbMsg.Text = "problema al cargar Tipo"; } else { for (int i = 0; i < dtTipo.Rows.Count; i++) { DataRow row = dtTipo.Rows[i]; cbxTipo.Items.Add(row[1]); } } cbxTipo.Items.Insert(0, "-Seleccione-"); cbxTipo.SelectedIndex = 0; DataTable dtMarca = man.GetMarcaProducto(); if (dtMarca == null) { lbMsg.Text = "problema al cargar Marca"; } else { for (int i = 0; i < dtMarca.Rows.Count; i++) { DataRow row = dtMarca.Rows[i]; cbxMarca.Items.Add(row[1]); } } cbxMarca.Items.Insert(0, "-Seleccione-"); cbxMarca.SelectedIndex = 0; }
private void btnIngresoProd_Click(object sender, EventArgs e) { ManProducto man = new ManProducto(); string familia = ""; string tipo = ""; string marca = ""; if (string.IsNullOrEmpty(txPrecioEst.Text)) { lbMsg.Text = ("Ingrese Precio Estimado."); txPrecioEst.Focus(); return; } if (string.IsNullOrEmpty(txtSctockCri.Text)) { lbMsg.Text = ("Ingrese Stock Critico."); txtSctockCri.Focus(); return; } if (cbxFamilia.SelectedIndex == 0) { lbMsg.Text = ("Seleccione Familia de Producto"); cbxFamilia.Focus(); return; } else { familia = cbxFamilia.SelectedItem.ToString(); } if (cbxTipo.SelectedIndex == 0) { lbMsg.Text = ("Seleccione Tipo de Producto"); cbxTipo.Focus(); return; } else { tipo = cbxTipo.SelectedItem.ToString(); } if (cbxMarca.SelectedIndex == 0) { lbMsg.Text = ("Seleccione Marca de Producto"); cbxMarca.Focus(); return; } else { marca = cbxMarca.SelectedItem.ToString(); } PRODUCTO prod = new PRODUCTO(); prod.FAMILIA_PRODUCTO_ID = man.GetIDFamilia(familia); prod.TIPO_PRODUCTO_ID = man.GetIDTipo(tipo); prod.MARCA_ID = man.GetIDMarca(marca); prod.STOCK_CRITICO = int.Parse(txtSctockCri.Text); prod.PRECIO = int.Parse(txPrecioEst.Text); prod.STOCK = 0; prod.CODIGO_BARRA_ID = 1; try { using (EntitiesHostal con = new EntitiesHostal()) { con.PRODUCTO.Add(prod); con.SaveChanges(); } MessageBox.Show("Producto Ingresado Correctamente"); lbMsg.Text = ("Producto Ingresado Correctamente."); txPrecioEst.Text = ""; txtSctockCri.Text = ""; CargarDatos(); LlenarGrilla(); } catch (Exception ex) { lbMsg.Text = ("Producto No ingresado Reintente."); Console.WriteLine("PRODUCTO;;;; " + ex); return; } }