Exemple #1
0
    protected void btnMostrarPedidos_Click(object sender, EventArgs e)
    {
        try
        {
            if ((Convert.ToInt32(ddlEstadoPedido.SelectedValue)) == 0)
            {
                Int64 oRUC    = Convert.ToInt64(gvListadoMedicamento.SelectedRow.Cells[1].Text.Trim());
                int   oCodigo = Convert.ToInt32(gvListadoMedicamento.SelectedRow.Cells[2].Text.Trim());

                List <Pedido> oLista = new List <Pedido>();
                oLista = null;
                oLista = LogicaPedido.ListarPedidosXMedicamento(oRUC, oCodigo);

                gvListadoPedidos.DataSource = oLista;
                gvListadoPedidos.DataBind();

                Session["ListaPedidos"] = oLista;

                if (oLista.Count == 0)
                {
                    lblError.Text = "Este medicamento (" + (Convert.ToString(gvListadoMedicamento.SelectedRow.Cells[3].Text.Trim()))
                                    + ", Codigo " + (Convert.ToString(gvListadoMedicamento.SelectedRow.Cells[2].Text.Trim())) + ") no tiene pedidos asociados";
                }
                else
                {
                    lblError.Text = "";
                }
            }
            else if ((Convert.ToInt32(ddlEstadoPedido.SelectedValue)) == 1)
            {
                Int64 oRUC    = Convert.ToInt64(gvListadoMedicamento.SelectedRow.Cells[1].Text.Trim());
                int   oCodigo = Convert.ToInt32(gvListadoMedicamento.SelectedRow.Cells[2].Text.Trim());

                List <Pedido> oLista = new List <Pedido>();
                oLista = null;
                oLista = LogicaPedido.ListarPedidosGeneradosXMedicamento(oRUC, oCodigo);

                gvListadoPedidos.DataSource = oLista;
                gvListadoPedidos.DataBind();

                Session["ListaPedidos"] = oLista;

                if (oLista.Count == 0)
                {
                    lblError.Text = "Este medicamento (" + (Convert.ToString(gvListadoMedicamento.SelectedRow.Cells[3].Text.Trim()))
                                    + ", Codigo " + (Convert.ToString(gvListadoMedicamento.SelectedRow.Cells[2].Text.Trim())) + ") no tiene pedidos asociados en estado Generado";
                }
                else
                {
                    lblError.Text = "";
                }
            }
            else
            {
                Int64 oRUC    = Convert.ToInt64(gvListadoMedicamento.SelectedRow.Cells[1].Text.Trim());
                int   oCodigo = Convert.ToInt32(gvListadoMedicamento.SelectedRow.Cells[2].Text.Trim());

                List <Pedido> oLista = new List <Pedido>();
                oLista = null;
                oLista = LogicaPedido.ListarPedidosEnviadosXMedicamento(oRUC, oCodigo);

                gvListadoPedidos.DataSource = oLista;
                gvListadoPedidos.DataBind();

                Session["ListaPedidos"] = oLista;

                if (oLista.Count == 0)
                {
                    lblError.Text = "Este medicamento (" + (Convert.ToString(gvListadoMedicamento.SelectedRow.Cells[3].Text.Trim()))
                                    + ", Codigo " + (Convert.ToString(gvListadoMedicamento.SelectedRow.Cells[2].Text.Trim())) + ") no tiene pedidos asociados en estado Enviado";
                }
                else
                {
                    lblError.Text = "";
                }
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }