void limpiar() { TxtFechaCaducidad.Clear(); TxtNombre.Clear(); TxtCosto.Clear(); TxtPrecioMin.Clear(); TxtprecioVenta.Clear(); TxtIva.Clear(); TxtStock.Clear(); TxtStockMin.Clear(); TxtDescripcion.Clear(); cbidPromocio.Visible = false; lblselecpromo.Visible = false; cbpromocion.DataSource = null; cbProveedor.DataSource = null; CbMedida.DataSource = null; CbFamilia.DataSource = null; TxtCodigoBarra.Clear(); }
//Este Metodo Limpia los campos private void Limpiar() { TxtBuscar.Clear(); TxtNombre.Clear(); TxtId.Clear(); TxtDescripcion.Clear(); BtnInsertar.Visible = true; TxtImagen.Clear(); TxtStock.Clear(); TxtPrecio_Venta.Clear(); BtnActualizar.Visible = false; Erroricono.Clear(); //Limpiar para seleccionar DgvListado.Columns[0].Visible = false; BtnActivar.Visible = false; BtnDesactivar.Visible = false; BtnEliminar.Visible = false; ChkSeleccionar.Checked = false; }
private void Limpiar() { TxtNombre.Clear(); TxtDescripcion.Clear(); TxtBuscar.Clear(); TxtId.Clear(); TxtCodigo.Clear(); TxtStock.Clear(); PicImagen.Image = null; TxtPrecioVenta.Clear(); TxtImagen.Clear(); BtnInsertar.Visible = true; BtnActualizar.Visible = false; ErrorIcono.Clear(); DgvListado.Columns[0].Visible = false; BtnActivar.Visible = false; BtnDesactivar.Visible = false; BtnEliminar.Visible = false; ChkSeleccionar.Checked = false; }
bool validartxt() { try { if (cbidPromocio.SelectedText != null) { if (TxtCodigoBarra.Text != "") { if (TxtNombre.Text != "") { if (TxtDescripcion.Text != "") { if (TxtStock.Text != "" && TxtStock.Text != "0") { if (TxtStockMin.Text != "" && TxtStockMin.Text != "0") { if (TxtCosto.Text != "") { if (TxtPrecioMin.Text != "") { if (TxtprecioVenta.Text != "") { if (TxtIva.Text != "") { if (CbMedida.SelectedValue != null) { if (CbFamilia.SelectedValue != null) { if (cbpromocion.SelectedText != null) { if (cbProveedor.SelectedValue != null) { if (CbEstatus.SelectedText != null) { if (TxtFechaCaducidad.Text != null) { return(true); } } } } } } } else { TxtIva.Focus(); } } else { TxtprecioVenta.Focus(); } } else { TxtPrecioMin.Focus(); } } else { TxtCosto.Focus(); } } else { TxtStockMin.Focus(); } } else { TxtStock.Focus(); } } else { TxtDescripcion.Focus(); } } else { TxtNombre.Focus(); } } else { TxtCodigoBarra.Focus(); } } } catch (Exception e) { MessageBox.Show("Error consulte con su administrador error:" + e.ToString(), "Error"); } return(false); }
private void BtnSave_Click(object sender, RoutedEventArgs e) { try { if ((TxtNameItem.Text == "") || (TxtStock.Text == "") || (TxtPrice.Text == "")) { if (TxtNameItem.Text == "") { MessageBox.Show("Name Item Is Required", "Caution", MessageBoxButton.OK); TxtNameItem.Focus(); } else if (TxtStock.Text == "") { MessageBox.Show("Stock Item Is Required", "Caution", MessageBoxButton.OK); TxtStock.Focus(); } else if (TxtPrice.Text == "") { MessageBox.Show("Price Item is Required", "Caution", MessageBoxButton.OK); TxtPrice.Focus(); } } else { if (TxtNameItem.Text != null) { int Stock = Convert.ToInt32(TxtStock.Text); int Price = Convert.ToInt32(TxtPrice.Text); var supplier = myContext.Suppliers.Where(w => w.Id == supplierid).FirstOrDefault(); var itemname = myContext.Items.Where(i => i.Name == TxtNameItem.Text).FirstOrDefault(); //var priceitem = myContext.Items.Where(i => i.Price == TxtPriceItem.Text).FirstOrDefault(); if (itemname != null) { var stockrecent = itemname.Stock; var pricerecent = itemname.Price; var supplierrecent = itemname.Supplier.ToString(); if (TxtPrice.Text == pricerecent.ToString()) { int updStock = Stock + stockrecent; itemname.Stock = Convert.ToInt32(updStock); var result2 = myContext.SaveChanges(); if (result2 > 0) { MessageBox.Show("Stock Has Been Updated"); } else { MessageBox.Show("Stock Cant be Updated"); } GridItem.ItemsSource = myContext.Items.ToList(); } else { int Stock2 = Convert.ToInt32(TxtStock.Text); int Price2 = Convert.ToInt32(TxtPrice.Text); var supplier2 = myContext.Suppliers.Where(w => w.Id == supplierid).FirstOrDefault(); var pushStock = new Item(TxtNameItem.Text, Stock2, Price2, supplier2); myContext.Items.Add(pushStock); var result = myContext.SaveChanges(); if (result > 0) { MessageBox.Show("New Item has been inserted"); } else { MessageBox.Show("New item cant be inserted"); } GridItem.ItemsSource = myContext.Items.ToList(); } } else { int Stock2 = Convert.ToInt32(TxtStock.Text); int Price2 = Convert.ToInt32(TxtPrice.Text); var supplier2 = myContext.Suppliers.Where(w => w.Id == supplierid).FirstOrDefault(); var pushStock = new Item(TxtNameItem.Text, Stock2, Price2, supplier2); myContext.Items.Add(pushStock); var result = myContext.SaveChanges(); if (result > 0) { MessageBox.Show("New Item has been inserted"); } else { MessageBox.Show("New item cant be inserted"); } GridItem.ItemsSource = myContext.Items.ToList(); } } } ComboItem.ItemsSource = myContext.Items.ToList(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButton.OK); } }