void Limpiar() { TxtCosto.Text = "0"; TxtID_Producto.Text = ""; Productos_A_Ingresar = new List <Clases.Productos>(); LlenarListaProdsToAdd(); TxtID_Producto.Focus(); TxtID_Producto.Enabled = true; }
private void CmdAgregar_Click(object sender, EventArgs e) { if (TxtID_Producto.Text == "") { // MessageBox.Show("Favor Ingrese el ID!", "Info!", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtID_Producto.Focus(); return; } else if (TxtCosto.Text.Trim() == "" || TxtCosto.Text.Trim() == "0") { Program.MensajeError("Verificar el precio de costo!"); return; } if (TxtCosto.Text == "") { MessageBox.Show("Favor Ingrese el precio de costo!", "Info!", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtCosto.Focus(); return; } try { var prd = new Clases.Productos() { ID_Producto = TxtID_Producto.Text.Trim() == "" ? null : TxtID_Producto.Text, Clase = (int)CmbClase.SelectedValue, NombreProducto = (int)CmbNombre.SelectedValue, Fecha_Ingreso = dtFechaIngreso.Value, Precio_Costo = decimal.Parse(TxtCosto.Text), }; if (!Productos_A_Ingresar.Exists(p => p.ID_Producto == prd.ID_Producto)) { Productos_A_Ingresar.Add(prd); } else { Program.MensageInfo("Producto ya registrado"); return; } TxtID_Producto.Text = ""; TxtID_Producto.Focus(); AddProd(prd); //LlenarListaProdsToAdd(); } catch (Exception es) { MessageBox.Show(es.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void TxtID_Producto_TextChanged(object sender, EventArgs e) { if (TxtID_Producto.Text.Length >= 9) { if (TxtCosto.Text.Trim() == "" || TxtCosto.Text.Trim() == 0.ToString()) { Program.MensajeError("Debe introducir el precio de costo"); } Program.wait(1); DB = new Clases.IM_DB_Entities(); if (DB.Productos.Any(p => p.ID_Producto.Trim() == TxtID_Producto.Text.Trim())) { Program.MensageInfo("Este código ya existe en su inventario"); TxtID_Producto.Text = ""; TxtID_Producto.Focus(); return; } CmdAgregar_Click(sender, e); } }