protected void lbtnRestar_Click(object sender, EventArgs e) { Ldet.Eliminar_Detalles(txtCodigoproducto.Text); txtCodigoproducto.Enabled = true; lbtnRestar.Enabled = false; txtCodigoproducto.Text = ""; txtCantidad_Producto_Devolucion.Text = ""; txtNombre_Producto_Devolucion.Text = ""; GvDetDevC.DataSource = Ldet.Consultar_Detalles(); GvDetDevC.DataBind(); LblMensaje.Text = ""; lbtnRestar.Visible = false; }
protected void lbtnAgregar_Click(object sender, EventArgs e) { bool res = true; if (txtCodigoproducto.Text == "") { LblMensaje.Visible = true; LblMensaje.Text = "Por favor seleccione el producto"; res = false; if (txtCantidad_Producto_Devolucion.Text == "") { LblMensaje.Visible = true; LblMensaje.Text = "Por favor ingrese el codigo de producto,la cantidad y el consecutivo"; res = false; } if (txtConsecutivo_Devolucion.Text == "") { LblMensaje.Visible = true; LblMensaje.Text = "Por favor ingrese el el consecutivo de la venta"; res = false; } } Minimo = Lpro.ProductoCod(txtCodigoproducto.Text); if (res) { int cantidad = 0; Actuales = 0; bool Productos = true; cantidad = Convert.ToInt32(txtCantidad_Producto_Devolucion.Text); foreach (GridViewRow row in GvVentas.Rows) { Actuales = Convert.ToInt32(row.Cells[5].Text); if (row.Cells[3].Text == txtCodigoproducto.Text) { if (Actuales < cantidad) { LblMensaje.Visible = true; LblMensaje.Text = "No se puede devolver más de los que se compró"; Ldet.Eliminar_Detalles(txtCodigoproducto.Text); Productos = false; } else { Productos = true; LblMensaje.Visible = false; } } } if (Productos) { bool Funcion = true; foreach (GridViewRow Det in GvDetDevC.Rows) { if (Det.Cells[1].Text == txtCodigoproducto.Text) { LblMensaje.Visible = true; LblMensaje.Text = "No se puede agregar mas productos de la referencia "; Funcion = false; } } if (Funcion) { Ldet.Registrar_detalles(txtCodigoproducto.Text, Convert.ToInt32(cantidad), 0); GvDetDevC.DataSource = Ldet.Consultar_Detalles(); GvDetDevC.DataBind(); txtCodigoproducto.Text = ""; txtCantidad_Producto_Devolucion.Text = ""; txtNombre_Producto_Devolucion.Text = ""; txtCodigoproducto.Focus(); txtCodigoproducto.Enabled = true; lbtnRestar.Enabled = false; } } } lbtnRegistrarDevolucion.Enabled = true; }