Beispiel #1
0
    protected void gvAcceptedEstabRequests_SelectedIndexChanged(object sender, EventArgs e)
    {
        BloodPlateletRequestUser         selectedRequest      = userRequests[gvRequestInfo.PageSize * gvRequestInfo.PageIndex + gvRequestInfo.SelectedIndex];
        List <BplTransactionUserToEstab> allEstabTransactions = BplTransactionUserToEstabDB.getAllbpTransactionUserToEsta();

        foreach (BplTransactionUserToEstab m in allEstabTransactions)
        {
            if (m.bpMatchUsrEstID.bpRequestID.bplUserRequestID == selectedRequest.bplUserRequestID && m.status == "accepted")
            {
                estabsAccepted.Add(m);
            }
        }

        BplTransactionUserToEstab selectedTransaction = estabsAccepted[gvAcceptedEstabRequests.PageSize * gvAcceptedEstabRequests.PageIndex + gvAcceptedEstabRequests.SelectedIndex];

        selectedTransaction.status = "complete";
        BplTransactionUserToEstabDB.updateBPTranscationUserToEstab(selectedTransaction);
        gvAcceptedEstabRequests.DataBind();

        BPMatchUserToEstab currentMatch = selectedTransaction.bpMatchUsrEstID;

        currentMatch.status = "declined";
        BPMatchUserToEstabDB.updateBPMatchUserToEstab(currentMatch);

        if (selectedRequest.Units == selectedRequest.unitMatched)
        {
            selectedRequest.Status = "complete";
            BloodPlateletRequestUserDB.updateBloodPlateles(selectedRequest);
            gvRequestInfo.DataBind();
        }
    }
Beispiel #2
0
    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        BloodPlateletRequestUser bpr = BloodPlateletRequestUserDB.getUserBloodRequestsbyID(lblRID.Text);

        estabTransactions = BplTransactionUserToEstabDB.getAllbpTransactionUserToEsta();
        List <BplTransactionUserToEstab> allestabTransactions = new List <BplTransactionUserToEstab>();

        foreach (BplTransactionUserToEstab m in estabTransactions)
        {
            if (m.bpMatchUsrEstID.bpRequestID.bplUserRequestID == bpr.bplUserRequestID && m.status == "accepted")
            {
                allestabTransactions.Add(m);
            }
        }
        BplTransactionUserToEstab selectedTransaction = allestabTransactions[GridView2.PageSize * GridView2.PageIndex + e.RowIndex];

        selectedTransaction.status = "cancelled";
        BplTransactionUserToEstabDB.updateBPTranscationUserToEstab(selectedTransaction);

        BloodPlateletRequestUser selectedRequest = bpr;

        selectedRequest.unitMatched = selectedRequest.unitMatched - selectedTransaction.unit;
        BloodPlateletRequestUserDB.updateBloodPlateles(selectedRequest);
        Server.Transfer("DonateAndRequest.aspx");
    }
Beispiel #3
0
    //cancel the current donation which are not yet accept by any individual
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        BloodPlateletRequestUser bpr = BloodPlateletRequestUserDB.getUserBloodRequestsbyID(lblRID.Text);

        userTransactions = BplTransactionUserToUserDB.getAllbpTransUserToUser();
        List <BplTransactionUserToUser> alluserTransactions = new List <BplTransactionUserToUser>();

        foreach (BplTransactionUserToUser btu in userTransactions)
        {
            if (btu.bpMatchUsrUsr.bplUsrRequestID.bplUserRequestID == bpr.bplUserRequestID && btu.status == "accepted")
            {
                alluserTransactions.Add(btu);
            }
        }
        BplTransactionUserToUser selectedTransaction = alluserTransactions[GridView1.PageSize * GridView1.PageIndex + e.RowIndex];

        selectedTransaction.status = "cancelled";
        BplTransactionUserToUserDB.updateBPTranscationUserToUser(selectedTransaction);

        BloodPlateletRequestUser selectedRequest = bpr;

        selectedRequest.unitMatched = selectedRequest.unitMatched - selectedTransaction.unitsPossible;
        BloodPlateletRequestUserDB.updateBloodPlateles(selectedRequest);
        Server.Transfer("DonateAndRequest.aspx");
    }
Beispiel #4
0
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        BloodPlateletRequestUser bpru = BloodPlateletRequestUserDB.getUserBloodRequestsbyID(lblRID.Text);

        bpru.Status = "cancelled";
        int num = BloodPlateletRequestUserDB.updateBloodPlateles(bpru);

        if (num != 1)
        {
            lblOutput.Text = "Cannot Cancel Request Right Now!";
            return;
        }
        else
        {
            lblOutput.Text = "Cancel Successful! u can check history in the following table";
            //if donation cancel change the status of matching also
            List <BPMatchUserToUser> bpmuulist = BPMatchUserToUserDB.getAllUserBloodRequestsbyUserID(bpru.bplUserRequestID);
            foreach (BPMatchUserToUser b in bpmuulist)
            {
                b.status = "declined";
                BPMatchUserToUserDB.updateMatchUserToUser(b);
            }
            List <BPMatchUserToEstab> bpmuelist = BPMatchUserToEstabDB.getAllBloodRequestsMatchbyUserID(bpru.bplUserRequestID);
            foreach (BPMatchUserToEstab be in bpmuelist)
            {
                be.status = "declined";
                BPMatchUserToEstabDB.updateBPMatchUserToEstab(be);
            }
        }
    }
Beispiel #5
0
    protected void gvAcceptedUserRequests_SelectedIndexChanged(object sender, EventArgs e)
    {
        BloodPlateletRequestUser        selectedRequest     = userRequests[gvRequestInfo.PageSize * gvRequestInfo.PageIndex + gvRequestInfo.SelectedIndex];
        List <BplTransactionUserToUser> allUserTransactions = BplTransactionUserToUserDB.getAllbpTransUserToUser();

        foreach (BplTransactionUserToUser m in allUserTransactions)
        {
            if (m.bpMatchUsrUsr.bplUsrRequestID.bplUserRequestID == selectedRequest.bplUserRequestID && m.status == "accepted")
            {
                usersAccepted.Add(m);
            }
        }

        BplTransactionUserToUser selectedTransaction = usersAccepted[gvAcceptedUserRequests.PageSize * gvAcceptedUserRequests.PageIndex + gvAcceptedUserRequests.SelectedIndex];

        selectedTransaction.status = "complete";
        BplTransactionUserToUserDB.updateBPTranscationUserToUser(selectedTransaction);
        gvAcceptedUserRequests.DataBind();

        BPMatchUserToUser currentMatch = selectedTransaction.bpMatchUsrUsr;

        currentMatch.status = "declined";
        BPMatchUserToUserDB.updateMatchUserToUser(currentMatch);

        Users currentUser = currentMatch.matchID;
        List <LastDonationDate> allLastDates = LastDonationDateDB.getAllLastDonations();

        foreach (LastDonationDate ld in allLastDates)
        {
            if (ld.User.UserId == currentUser.UserId)
            {
                ld.LastDonation = DateTime.Today;
                ld.Type         = currentMatch.bplUsrRequestID.bloodOrPlatelet;
                ld.Status       = "Not in transaction";
                LastDonationDateDB.updateLastDonation(ld);
            }
        }

        if (selectedRequest.Units == selectedRequest.unitMatched)
        {
            selectedRequest.Status = "complete";
            BloodPlateletRequestUserDB.updateBloodPlateles(selectedRequest);
            gvRequestInfo.DataBind();
        }
    }
Beispiel #6
0
    protected void lbtnReport_Click(object sender, EventArgs e)
    {
        LinkButton  lbtn = (LinkButton)sender;
        GridViewRow gvr  = (GridViewRow)lbtn.NamingContainer;
        int         i    = Convert.ToInt32(gvr.RowIndex);
        BloodPlateletRequestUser        selectedRequest     = userRequests[gvRequestInfo.PageSize * gvRequestInfo.PageIndex + gvRequestInfo.SelectedIndex];
        List <BplTransactionUserToUser> allUserTransactions = BplTransactionUserToUserDB.getAllbpTransUserToUser();

        foreach (BplTransactionUserToUser m in allUserTransactions)
        {
            if (m.bpMatchUsrUsr.bplUsrRequestID.bplUserRequestID == selectedRequest.bplUserRequestID && m.status == "accepted")
            {
                usersAccepted.Add(m);
            }
        }
        BplTransactionUserToUser selectedTransaction = usersAccepted[i];
        Users reportedUser = selectedTransaction.bpMatchUsrUsr.matchID;

        reportedUser.MedicalStatus         = "cannot donate";
        reportedUser.MedicalStatusUpdateBy = ((Establishment)Session["establishment"]).ID;
        UsersDB.updateUser(reportedUser);
        List <LastDonationDate> allLastDates = LastDonationDateDB.getAllLastDonations();

        foreach (LastDonationDate ld in allLastDates)
        {
            if (ld.User.UserId == reportedUser.userId)
            {
                ld.LastDonation = DateTime.Today;
                ld.Type         = selectedRequest.bloodOrPlatelet;
                ld.Status       = "Not in transaction";
                LastDonationDateDB.updateLastDonation(ld);
            }
        }

        selectedTransaction.status = "cancelled";
        BplTransactionUserToUserDB.updateBPTranscationUserToUser(selectedTransaction);

        selectedTransaction.bpMatchUsrUsr.status = "declined";
        BPMatchUserToUserDB.updateMatchUserToUser(selectedTransaction.bpMatchUsrUsr);

        selectedRequest.unitMatched = selectedRequest.unitMatched - selectedTransaction.unitsPossible;
        BloodPlateletRequestUserDB.updateBloodPlateles(selectedRequest);
        Server.Transfer("UserDonations.aspx");
    }
    protected void btnUserSubmit_Click(object sender, EventArgs e)
    {
        Establishment             currentEstab    = (Establishment)Session["establishment"];
        List <BPMatchUserToEstab> allUserRequests = BPMatchUserToEstabDB.getAllbpMatchUserToEsta();
        List <BPMatchUserToEstab> userRequests    = new List <BPMatchUserToEstab>();

        foreach (BPMatchUserToEstab m in allUserRequests)
        {
            if (m.matchID.ID == currentEstab.ID && m.status == "pending" && m.bpRequestID.unitMatched < m.bpRequestID.Units)
            {
                userRequests.Add(m);
            }
        }
        BPMatchUserToEstab        currentMatch   = userRequests[gvUserRequests.PageSize * gvUserRequests.PageIndex + gvUserRequests.SelectedIndex];
        BloodPlateletRequestUser  r              = currentMatch.bpRequestID;
        BplTransactionUserToEstab newTransaction = new BplTransactionUserToEstab();
        int donateUnits = Convert.ToInt32(tbxUserUnits.Text);

        if (donateUnits > (currentMatch.bpRequestID.Units - currentMatch.bpRequestID.unitMatched))
        {
            lblUserOutput.Text = "Please enter a valid amount";
        }
        else
        {
            currentMatch.status = "accepted";
            BPMatchUserToEstabDB.updateBPMatchUserToEstab(currentMatch);
            newTransaction.bpMatchUsrEstID = currentMatch;
            newTransaction.unit            = donateUnits;
            newTransaction.status          = "accepted";
            BplTransactionUserToEstabDB.insertbptrans(newTransaction);
            r.unitMatched = r.unitMatched + donateUnits;
            BloodPlateletRequestUserDB.updateBloodPlateles(r);
            lblOutput.Text        = "Donation successfully accepted!";
            pnlAcceptUser.Visible = false;
            tbxUserUnits.Text     = "";
            Server.Transfer("IncomingRequests.aspx");
        }
    }