Beispiel #1
0
    protected void btnPedir_Click(object sender, EventArgs e)
    {
        try
        {
            //VERIFICACIONES
            if ((Medicamento)Session["MEDICAMENTO"] == null)
            {
                throw new Exception("Debe seleccionar un medicamento.");
            }
            int cantidad;

            try
            {
                cantidad = Convert.ToInt32(txtCantidad.Text);
            }
            catch { throw new Exception("La cantidad debe ser un numero."); }

            if (cantidad < 1)
            {
                throw new Exception("La cantidad debe ser mayor a cero.");
            }

            Pedido       pedido       = new Pedido((Cliente)Session["USUARIO"], (Medicamento)Session["MEDICAMENTO"], cantidad, "GENERADO");
            LogicaPedido logicaPedido = new LogicaPedido();
            logicaPedido.AltaPedido(pedido);

            lblERROR.ForeColor = System.Drawing.Color.Green;
            lblERROR.Text      = "Pedido generado con exito.";
        }
        catch (Exception ex)
        {
            lblERROR.ForeColor = System.Drawing.Color.Red;
            lblERROR.Text      = ex.Message;
        }
    }