Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["email"] == null)
        {
            Server.Transfer("CommonLogin.aspx");
        }
        else
        {
            List <Establishment> elist = EstablishmentDB.getAllEstablishments();
            foreach (Establishment es in elist)
            {
                if (es.Type == "Hospital" || es.Type == "Blood Bank")
                {
                    ddlEstablish.Items.Add(es.Name);
                }
            }

            ddlEstablish.Items.Insert(0, "--Select--");
            lblAmount.Visible = false;
            u           = UsersDB.getUserbyEmail(Session["email"].ToString());
            pendinglist = new List <BloodPlateletRequestUser>();
            bplist      = BloodPlateletRequestUserDB.getUserBloodRequestsbyUserID(u.userId);
            foreach (BloodPlateletRequestUser b in bplist)
            {
                if (b.Status == "pending")
                {
                    pendinglist.Add(b);
                }
            }

            if (pendinglist.Count == 0)
            {
                lblSorry.Visible = true;
                Panel1.Visible   = false;
                Panel2.Visible   = false;
            }
            else
            {
                lblSorry.Visible  = false;
                Panel1.Visible    = true;
                gvUser.DataSource = pendinglist;
                gvUser.DataBind();
                Panel2.Visible = false;
            }
            lblee.Visible  = false;
            lbleeh.Visible = false;
            lbleu.Visible  = false;
            lbleuh.Visible = false;
        }
    }
Exemplo n.º 2
0
    protected void gvUser_SelectedIndexChanged(object sender, EventArgs e)
    {
        Panel2.Visible         = true;
        Panelusertrans.Visible = true;
        lblee.Visible          = false;
        pendinglist            = new List <BloodPlateletRequestUser>();
        u      = UsersDB.getUserbyEmail(Session["email"].ToString());
        bplist = BloodPlateletRequestUserDB.getUserBloodRequestsbyUserID(u.userId);
        foreach (BloodPlateletRequestUser b in bplist)
        {
            if (b.Status == "pending")
            {
                pendinglist.Add(b);
            }
        }
        int num = pendinglist.Count;

        lbleu.Visible = false;
        BloodPlateletRequestUser bpr = pendinglist[gvUser.PageSize * gvUser.PageIndex + gvUser.SelectedIndex];

        lblAmountshow.Text = bpr.Units.ToString();
        lblBT.Text         = bpr.Type;
        lblEst.Text        = bpr.Establishment.Name;
        DateTime dt = System.DateTime.Parse(bpr.Time.ToString());

        lblRD.Text  = string.Format("{0:dd/MM/yyyy}", dt);
        lblRID.Text = bpr.bplUserRequestID;
        lblDT.Text  = bpr.bloodOrPlatelet;
        List <BplTransactionUserToEstab> allestabTransactions = new List <BplTransactionUserToEstab>();
        List <BplTransactionUserToUser>  alluserTransactions  = new List <BplTransactionUserToUser>();

        estabTransactions = BplTransactionUserToEstabDB.getAllbpTransactionUserToEsta();
        userTransactions  = BplTransactionUserToUserDB.getAllbpTransUserToUser();
        int notrans = 0;

        //check the current user transaction which are accept
        foreach (BplTransactionUserToUser btu in userTransactions)
        {
            if (btu.bpMatchUsrUsr.bplUsrRequestID.bplUserRequestID == bpr.bplUserRequestID && btu.status == "accepted")
            {
                alluserTransactions.Add(btu);
            }
        }
        foreach (BplTransactionUserToUser btu in userTransactions)
        {
            if (btu.bpMatchUsrUsr.bplUsrRequestID.bplUserRequestID == bpr.bplUserRequestID && btu.status == "Complete")
            {
                notrans = 1;
                break;
            }
        }

        foreach (BplTransactionUserToEstab m in estabTransactions)
        {
            if (m.bpMatchUsrEstID.bpRequestID.bplUserRequestID == bpr.bplUserRequestID && m.status == "accepted")
            {
                allestabTransactions.Add(m);
            }
        }
        foreach (BplTransactionUserToEstab m in estabTransactions)
        {
            if (m.bpMatchUsrEstID.bpRequestID.bplUserRequestID == bpr.bplUserRequestID && m.status == "Complete")
            {
                notrans = 2;
                break;
            }
        }
        if (notrans == 1 || notrans == 2)
        {
            btnCancel.Visible = false;
        }
        else
        {
            btnCancel.Visible = true;
        }
        if (alluserTransactions.Count == 0)
        {
            lbleu.Visible          = true;
            Panelusertrans.Visible = false;
            lbleu.Visible          = true;
            lbleuh.Visible         = true;
        }
        else
        {
            Panelusertrans.Visible = true;
            lbleu.Visible          = false;
            lbleuh.Visible         = true;
            GridView1.DataSource   = alluserTransactions;
            GridView1.DataBind();
        }
        if (allestabTransactions.Count == 0)
        {
            lblee.Visible         = true;
            lbleeh.Visible        = true;
            Panelesttrans.Visible = false;
        }
        else
        {
            Panelesttrans.Visible = true;
            lblee.Visible         = false;
            lbleeh.Visible        = true;
            GridView2.DataSource  = allestabTransactions;
            GridView2.DataBind();
        }
    }