public static DeceasedOrganMatching getMatchByID(string id)
    {
        DeceasedOrganMatching m = new DeceasedOrganMatching();

        try
        {
            SqlCommand command = new SqlCommand("Select * from organMatchingDeceased where deceasedOrganMatch = @id");
            command.Parameters.AddWithValue("@id", id);
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                m.ID            = reader["deceasedOrganMatch"].ToString();
                m.DeceasedDonor = DeceasedDonorDB.getDonorByID(reader["deceasedOrganID"].ToString());
                m.Recipient     = OrganRecipientDB.getRecipientByID(reader["OrganWlID"].ToString());
                m.MatchScore    = Convert.ToInt32(reader["matchScore"]);
                m.Comments      = reader["comments"].ToString();
                m.Status        = reader["status"].ToString();
                m.Distance      = Convert.ToInt32(reader["distance"]);
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(m);
    }
    public static List <DeceasedOrganMatching> getAllMatches()
    {
        List <DeceasedOrganMatching> matches = new List <DeceasedOrganMatching>();

        try
        {
            SqlCommand command = new SqlCommand("Select * from organMatchingDeceased");
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                DeceasedOrganMatching m = new DeceasedOrganMatching();
                m.ID            = reader["deceasedOrganMatch"].ToString();
                m.DeceasedDonor = DeceasedDonorDB.getDonorByID(reader["deceasedOrganID"].ToString());
                m.Recipient     = OrganRecipientDB.getRecipientByID(reader["OrganWlID"].ToString());
                m.MatchScore    = Convert.ToInt32(reader["matchScore"]);
                m.Comments      = reader["comments"].ToString();
                m.Status        = reader["status"].ToString();
                m.Distance      = Convert.ToInt32(reader["distance"]);
                matches.Add(m);
            }
            reader.Close();
        }
        finally
        {
            connection.Close();
        }
        return(matches);
    }
    public static int insertMatch(DeceasedOrganMatching m)
    {
        int num = -1;

        try
        {
            SqlCommand command = new SqlCommand("insert into organMatchingDeceased values(@deceasedOrganID, @OrganWlID, @matchScore, @comments, @status, @distance)");
            command.Parameters.AddWithValue("@deceasedOrganID", m.DeceasedDonor.ID);
            command.Parameters.AddWithValue("@OrganWlID", m.Recipient.ID);
            command.Parameters.AddWithValue("@matchScore", m.MatchScore);
            command.Parameters.AddWithValue("@comments", m.Comments);
            command.Parameters.AddWithValue("@status", m.Status);
            command.Parameters.AddWithValue("@distance", m.Distance);
            command.Connection = connection;
            connection.Open();
            if (command.ExecuteNonQuery() > 0)
            {
                num = 1;
            }
        }
        finally
        {
            connection.Close();
        }
        return(num);
    }
Beispiel #4
0
    protected void gvDeceased_SelectedIndexChanged(object sender, EventArgs e)
    {
        Establishment        currentEstab = (Establishment)Session["establishment"];
        List <DeceasedDonor> allDonors    = DeceasedDonorDB.getAllDeceasedDonors();

        foreach (DeceasedDonor d in allDonors)
        {
            if (d.Establishment.ID == currentEstab.ID && (d.Status == "allotted" || d.Status == "not allotted"))
            {
                ourDonors.Add(d);
            }
        }
        DeceasedDonor         currentDonor = ourDonors[gvDeceased.PageSize * gvDeceased.PageIndex + gvDeceased.SelectedIndex];
        DeceasedOrganMatching currentMatch = new DeceasedOrganMatching();
        bool matchFound = false;
        List <DeceasedOrganMatching> allMatches = DeceasedOrganMatchingDB.getAllMatches();

        foreach (DeceasedOrganMatching d in allMatches)
        {
            if ((d.DeceasedDonor.ID == currentDonor.ID) && d.Status == "current match")
            {
                matchFound   = true;
                currentMatch = d;
            }
        }
        if (matchFound == false)
        {
            lblOutput.Text   = "Sorry no match found!";
            pnlMatch.Visible = false;
        }
        else
        {
            try
            {
                pnlMatch.Visible      = true;
                lblEstab.Text         = currentMatch.Recipient.Establishment.Name;
                Session["est"]        = currentMatch.Recipient.Establishment.ID;
                lblBloodType.Text     = currentMatch.Recipient.Bloodgroup;
                lblAge.Text           = Convert.ToString(currentMatch.Recipient.DOB);
                lblHeightWeight.Text  = currentMatch.Recipient.Height + " / " + currentMatch.Recipient.Weight;
                lblWaiting.Text       = Convert.ToString((DateTime.Today - currentMatch.Recipient.Addedon).TotalDays);
                lblComments.Text      = currentMatch.Recipient.Comments;
                lblUrgency.Text       = Convert.ToString(currentMatch.Recipient.Urgency);
                lblMatchScore.Text    = Convert.ToString(currentMatch.MatchScore);
                tbxMatchComments.Text = currentMatch.Comments;
                lblDistance.Text      = Convert.ToString(currentMatch.Distance);
            }
            catch
            { lblOutput.Text = "Please Check The Entered Values"; }
        }
    }
    public static int updateMatch(DeceasedOrganMatching m)
    {
        int num = -1;

        try
        {
            SqlCommand command = new SqlCommand("update organMatchingDeceased set status=@status, comments=@comments where deceasedOrganMatch=@id");
            command.Parameters.AddWithValue("@status", m.Status);
            command.Parameters.AddWithValue("@comments", m.Comments);
            command.Parameters.AddWithValue("@id", m.ID);
            command.Connection = connection;
            connection.Open();
            if (command.ExecuteNonQuery() > 0)
            {
                num = 1;
            }
        }
        finally
        {
            connection.Close();
        }
        return(num);
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //check the medical condition of donor
        DeceasedDonor ao = new DeceasedDonor();

        ao.Bloodgroup    = ddlBloodType.SelectedValue;
        ao.DOB           = Convert.ToDateTime(tbxDate.Text);
        ao.Establishment = (Establishment)Session["establishment"];
        ao.Donorheight   = Convert.ToInt32(tbxHeight.Text);
        ao.Donorweight   = Convert.ToInt32(tbxWeight.Text);
        ao.Deathdate     = Convert.ToDateTime(tbxDeath.Text);
        ao.Organtype     = rbtnlstOrganType.SelectedValue;
        ao.Comments      = tbxComments.Text;
        ao.Refnumber     = tbxReference.Text;
        ao.Status        = "not allotted";
        //if the user is obese he/she cannot donate
        if ((ao.Donorweight * 10000) / (ao.Donorheight * ao.Donorheight) > 30)
        {
            lblOutput.Text = "This donor is incapable of donations";
            return;
        }
        else
        {
            DeceasedDonorDB.insertDeceasedDonor(ao);

            Establishment currentEstab = (Establishment)Session["establishment"];
            string        address      = currentEstab.Address;
            DeceasedDonor tDonor;
            //donor id from database
            List <DeceasedDonor> allDeadDonors = DeceasedDonorDB.getAllDeceasedDonors();
            String x      = allDeadDonors[0].ID;
            int    tempId = Convert.ToInt32(x.Substring(5, x.Length - 5));
            foreach (DeceasedDonor dd in allDeadDonors)
            {
                if (tempId < Convert.ToInt32(dd.ID.Substring(5, dd.ID.Length - 5)) && dd.Establishment.ID == currentEstab.ID)
                {
                    tempId = Convert.ToInt32(dd.ID.Substring(5, dd.ID.Length - 5));
                }
            }
            tDonor = DeceasedDonorDB.getDonorByID("dcdnr" + Convert.ToString(tempId));
            //end of getting last one

            List <OrganRecipient> allReceivers = OrganRecipientDB.getAllRecipients();
            //List<OrganRecipient> matchedBloodReceivers = new List<OrganRecipient>();
            bool f = false;
            //check the donor blood type and receiver blood type for organ donation
            foreach (OrganRecipient r in allReceivers)
            {
                int    y   = 0;
                String bt1 = ao.Bloodgroup;
                String bt2 = r.Bloodgroup;
                if ((bt1 == "A+" || bt1 == "A-") && (bt2 == "A+" || bt2 == "A-" || bt2 == "AB+" || bt2 == "AB-"))
                {
                    y = 1;
                }
                else if ((bt1 == "B+" || bt1 == "B-") && (bt2 == "B+" || bt2 == "B-" || bt2 == "AB+" || bt2 == "AB-"))
                {
                    y = 1;
                }
                else if ((bt1 == "AB+" || bt1 == "AB-") && (bt2 == "AB+" || bt2 == "AB-"))
                {
                    y = 1;
                }
                else if ((bt1 == "O+" || bt1 == "O-") && (bt2 == "A+" || bt2 == "A-" || bt2 == "AB+" || bt2 == "AB-" || bt2 == "B+" || bt2 == "B-" || bt2 == "O+" || bt2 == "O-"))
                {
                    y = 1;
                }
                if (y == 1 && ao.Organtype == r.Organrequired && r.Status == "waiting")
                {
                    string matchAddress = r.Establishment.Address;
                    float  d            = getDistance(address, matchAddress);
                    int    score        = 0;
                    int    d1           = Convert.ToInt32(d);

                    d = d / 3600;
                    if ((r.Organrequired == "Kidney" && d < 32) || (r.Organrequired == "Liver" && d < 8))
                    {
                        int wTimeScore = 0, distanceScore = 0;
                        if (d < 5)
                        {
                            distanceScore = 5;
                        }
                        else if (d < 15)
                        {
                            distanceScore = 4;
                        }
                        else if (d < 25)
                        {
                            distanceScore = 3;
                        }
                        else if (d < 35)
                        {
                            distanceScore = 2;
                        }
                        else if (d < 45)
                        {
                            distanceScore = 1;
                        }
                        else
                        {
                            distanceScore = 0;
                        }

                        double days = (DateTime.Today - r.Addedon).TotalDays;

                        if (days < 180)
                        {
                            wTimeScore = 1;
                        }
                        else if (days < 365)
                        {
                            wTimeScore = 2;
                        }
                        else if (days < 1095)
                        {
                            wTimeScore = 3;
                        }
                        else if (days < 1825)
                        {
                            wTimeScore = 4;
                        }
                        else
                        {
                            wTimeScore = 5;
                        }
                        score = r.Urgency * 3 + distanceScore + wTimeScore;

                        DeceasedOrganMatching match = new DeceasedOrganMatching();
                        ////donor id from database
                        //List<DeceasedDonor> allDeadDonors = DeceasedDonorDB.getAllDeceasedDonors();
                        //String x = allDeadDonors[0].ID;
                        //int tempId = Convert.ToInt32(x.Substring(5, x.Length - 5));
                        //foreach(DeceasedDonor dd in allDeadDonors)
                        //{
                        //    if (tempId < Convert.ToInt32(dd.ID.Substring(5, dd.ID.Length - 5)) && dd.Establishment == currentEstab)
                        //    {
                        //        tempId = Convert.ToInt32(dd.ID.Substring(5, dd.ID.Length - 5));
                        //    }
                        //}
                        //tDonor = DeceasedDonorDB.getDonorByID("dcdnr" + Convert.ToString(tempId));
                        ////end of getting last one

                        match.DeceasedDonor = tDonor;
                        match.Recipient     = r;
                        match.MatchScore    = score;
                        match.Comments      = "NIL";
                        match.Status        = "pending";
                        match.Distance      = d1;
                        DeceasedOrganMatchingDB.insertMatch(match);
                        f = true;
                    }
                }
            }
            if (f == true)
            {
                List <DeceasedOrganMatching> deadMatches   = DeceasedOrganMatchingDB.getAllMatches();
                List <DeceasedOrganMatching> deadMatchCurr = new List <DeceasedOrganMatching>();
                foreach (DeceasedOrganMatching DOM1 in deadMatches)
                {
                    if (DOM1.DeceasedDonor.ID == tDonor.ID)
                    {
                        deadMatchCurr.Add(DOM1);
                    }
                }
                DeceasedOrganMatching tempDOM = deadMatchCurr[0];
                foreach (DeceasedOrganMatching DOM in deadMatchCurr)
                {
                    if (DOM.MatchScore > tempDOM.MatchScore)
                    {
                        tempDOM = DOM;
                    }
                }
                tempDOM.Status = "current match";
                DeceasedOrganMatchingDB.updateMatch(tempDOM);
                OrganRecipient ort = OrganRecipientDB.getRecipientByID(tempDOM.Recipient.ID);
                ort.Status = "allotted";
                OrganRecipientDB.updateOrganRecipient(ort);
                tempDOM.DeceasedDonor.Status = "allotted";
                DeceasedDonorDB.updateDeceasedDonor(tempDOM.DeceasedDonor);
            }
            else
            {
                tDonor.Status = "cancelled";
                DeceasedDonorDB.updateDeceasedDonor(tDonor);
            }
            lblOutput.Text             = "Donor successfully added!";
            tbxComments.Text           = "";
            tbxDate.Text               = "";
            tbxDeath.Text              = "";
            tbxHeight.Text             = "";
            tbxReference.Text          = "";
            tbxWeight.Text             = "";
            ddlBloodType.SelectedIndex = 0;
            string MyAccountUrl = "DeceasedDonors.aspx";
            Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", MyAccountUrl)));
        }
    }
Beispiel #7
0
    protected void gvRecipients_SelectedIndexChanged(object sender, EventArgs e)
    {
        List <OrganRecipient> ourRecipients = new List <OrganRecipient>();
        List <OrganRecipient> allRecipients = OrganRecipientDB.getAllRecipients();
        Establishment         currentEstab  = (Establishment)Session["establishment"];

        foreach (OrganRecipient r in allRecipients)
        {
            if (r.Establishment.ID == currentEstab.ID && (r.Status == "waiting" || r.Status == "allotted"))
            {
                ourRecipients.Add(r);
            }
        }
        OrganRecipient        currentRecipient = ourRecipients[gvRecipients.PageSize * gvRecipients.PageIndex + gvRecipients.SelectedIndex];
        DeceasedOrganMatching deadOrgan        = new DeceasedOrganMatching();
        LiveOrganMatching     liveOrgan        = new LiveOrganMatching();
        int matchFound = 0;
        List <DeceasedOrganMatching> allDeadMatches = DeceasedOrganMatchingDB.getAllMatches();
        List <LiveOrganMatching>     allLiveMatches = LiveOrganMatchingDB.getAllMatches();

        foreach (DeceasedOrganMatching d in allDeadMatches)
        {
            if (d.Recipient.ID == currentRecipient.ID && d.Status == "current match")
            {
                matchFound = 1;
                deadOrgan  = d;
            }
        }
        foreach (LiveOrganMatching l in allLiveMatches)
        {
            if (l.Recipient.ID == currentRecipient.ID && l.Status == "current match")
            {
                matchFound = 2;
                liveOrgan  = l;
            }
        }
        if (matchFound == 0)
        {
            lblOutput.Text   = "Sorry no matches yet!";
            pnlMatch.Visible = false;
        }
        else if (matchFound == 1)
        {
            lblOutput.Text = "";
            try
            {
                pnlMatch.Visible = true;

                lblMedical.Text       = deadOrgan.DeceasedDonor.Establishment.Name;
                Session["rwEst"]      = deadOrgan.DeceasedDonor.Establishment.ID;
                Session["ldID"]       = null;
                Session["echat"]      = null;
                lblContact.Text       = deadOrgan.DeceasedDonor.Establishment.Phone + " / " + deadOrgan.DeceasedDonor.Establishment.Email;
                lblBloodType.Text     = deadOrgan.DeceasedDonor.Bloodgroup;
                lblHeightWeight.Text  = deadOrgan.DeceasedDonor.Donorheight + " / " + deadOrgan.DeceasedDonor.Donorweight;
                lblComments.Text      = deadOrgan.DeceasedDonor.Comments;
                lblMatchScore.Text    = Convert.ToString(deadOrgan.MatchScore);
                tbxMatchComments.Text = deadOrgan.Comments;
                lblDistance.Text      = Convert.ToString(deadOrgan.Distance);
            }
            catch { lblOutput.Text = "Please Check The Entered Values"; }
        }
        else if (matchFound == 2)
        {
            lblOutput.Text = "";
            try
            {
                pnlMatch.Visible = true;

                lblMedical.Text       = liveOrgan.LiveDonor.doctorName;
                Session["rwEst"]      = null;
                Session["ldID"]       = liveOrgan.LiveDonor.Userid.userId;
                Session["echat"]      = null;
                lblContact.Text       = liveOrgan.LiveDonor.DoctorNumber + " / " + liveOrgan.LiveDonor.DoctorEmail;
                lblBloodType.Text     = liveOrgan.LiveDonor.Userid.BloodType;
                lblHeightWeight.Text  = liveOrgan.LiveDonor.userid.Height + " / " + liveOrgan.LiveDonor.Userid.Weight;
                lblComments.Text      = liveOrgan.LiveDonor.comments;
                lblMatchScore.Text    = Convert.ToString(liveOrgan.MatchScore);
                tbxMatchComments.Text = liveOrgan.Comments;
                lblDistance.Text      = Convert.ToString(liveOrgan.Distance);
            }
            catch { lblOutput.Text = "Please Check The Entered Values"; }
        }
    }
Beispiel #8
0
    protected void btnDecline_Click(object sender, EventArgs e)
    {
        List <OrganRecipient> ourRecipients = new List <OrganRecipient>();
        List <OrganRecipient> allRecipients = OrganRecipientDB.getAllRecipients();
        Establishment         currentEstab  = (Establishment)Session["establishment"];

        foreach (OrganRecipient r in allRecipients)
        {
            if (r.Establishment.ID == currentEstab.ID && (r.Status == "waiting" || r.Status == "allotted"))
            {
                ourRecipients.Add(r);
            }
        }
        OrganRecipient        currentRecipient = ourRecipients[gvRecipients.PageSize * gvRecipients.PageIndex + gvRecipients.SelectedIndex];
        DeceasedOrganMatching deadOrgan        = new DeceasedOrganMatching();
        LiveOrganMatching     liveOrgan        = new LiveOrganMatching();
        int matchFound = 0;
        List <DeceasedOrganMatching> allDeadMatches     = DeceasedOrganMatchingDB.getAllMatches();
        List <LiveOrganMatching>     allLiveMatches     = LiveOrganMatchingDB.getAllMatches();
        List <DeceasedOrganMatching> allDeadMatchesCurr = new List <DeceasedOrganMatching>();
        List <LiveOrganMatching>     allLiveMatchesCurr = new List <LiveOrganMatching>();
        bool checkMatchD = false;
        bool checkMatchL = false;

        foreach (DeceasedOrganMatching d in allDeadMatches)
        {
            if (d.Recipient.ID == currentRecipient.ID && d.Status == "current match")
            {
                matchFound = 1;
                deadOrgan  = d;
            }
            else if (d.Recipient.ID == currentRecipient.ID && d.Status == "pending" && d.DeceasedDonor.Status == "not allotted")
            {
                allDeadMatchesCurr.Add(d);
                checkMatchD = true;
            }
        }
        foreach (LiveOrganMatching l in allLiveMatches)
        {
            if (l.Recipient.ID == currentRecipient.ID && l.Status == "current match")
            {
                matchFound = 2;
                liveOrgan  = l;
            }
            else if (l.Recipient.ID == currentRecipient.ID && l.Status == "pending" && l.LiveDonor.status == "not allotted")
            {
                allLiveMatchesCurr.Add(l);
                checkMatchL = true;
            }
        }
        if (matchFound == 0)
        {
            lblOutput.Text = "Sorry no matches yet!";
        }
        else if (matchFound == 2)
        {
            // tempCurrentMatch = deadOrgan.ID;
            liveOrgan.Status = "not possible";
            LiveOrganMatchingDB.updateMatch(liveOrgan);
        }
        else if (matchFound == 1)
        {
            // tempCurrentMatch = liveOrgan.ID;
            deadOrgan.Status = "not possible";
            DeceasedOrganMatchingDB.updateMatch(deadOrgan);
        }
        LiveOrganMatching tempLDM = new LiveOrganMatching();

        if (checkMatchL == true)
        {
            tempLDM = allLiveMatchesCurr[0];
            foreach (LiveOrganMatching ldm in allLiveMatchesCurr)
            {
                if (ldm.MatchScore > tempLDM.MatchScore)
                {
                    tempLDM = ldm;
                }
            }
        }
        DeceasedOrganMatching tempDOM = new DeceasedOrganMatching();

        if (checkMatchD == true)
        {
            tempDOM = allDeadMatchesCurr[0];
            foreach (DeceasedOrganMatching dom in allDeadMatchesCurr)
            {
                if (dom.MatchScore > tempDOM.MatchScore)
                {
                    tempDOM = dom;
                }
            }
        }
        if (checkMatchD == true && checkMatchL == true)
        {
            if (tempDOM.MatchScore < tempLDM.MatchScore)
            {
                tempLDM.Status = "current match";
                LiveOrganMatchingDB.updateMatch(tempLDM);
                LiveDonor tempItem = LiveDonorDB.getLiveDonorbyID(tempLDM.LiveDonor.LdonorID);
                tempItem.status = "allotted";
                LiveDonorDB.updateLiveDonor(tempItem);
            }
            else
            {
                tempDOM.Status = "current match";
                DeceasedOrganMatchingDB.updateMatch(tempDOM);
                DeceasedDonor tempItem = DeceasedDonorDB.getDonorByID(tempDOM.DeceasedDonor.ID);
                tempItem.Status = "allotted";
                DeceasedDonorDB.updateDeceasedDonor(tempItem);
            }
        }
        else if (checkMatchD == true && checkMatchL == false)
        {
            tempDOM.Status = "current match";
            DeceasedOrganMatchingDB.updateMatch(tempDOM);
            DeceasedDonor tempItem = DeceasedDonorDB.getDonorByID(tempDOM.DeceasedDonor.ID);
            tempItem.Status = "allotted";
            DeceasedDonorDB.updateDeceasedDonor(tempItem);
        }
        else if (checkMatchL == true && checkMatchD == false)
        {
            tempLDM.Status = "current match";
            LiveOrganMatchingDB.updateMatch(tempLDM);
            LiveDonor tempItem = LiveDonorDB.getLiveDonorbyID(tempLDM.LiveDonor.LdonorID);
            tempItem.status = "allotted";
            LiveDonorDB.updateLiveDonor(tempItem);
        }
        else
        {
            currentRecipient.Status = "waiting";
            OrganRecipientDB.updateOrganRecipient(currentRecipient);
        }
        Label1.Text = "Successfully completed";
        string MyAccountUrl = "RecipientWaitingList.aspx";

        Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", MyAccountUrl)));
    }
Beispiel #9
0
    protected void btnAccept_Click(object sender, EventArgs e)
    {
        List <OrganRecipient> ourRecipients = new List <OrganRecipient>();
        List <OrganRecipient> allRecipients = OrganRecipientDB.getAllRecipients();
        Establishment         currentEstab  = (Establishment)Session["establishment"];

        foreach (OrganRecipient r in allRecipients)
        {
            if (r.Establishment.ID == currentEstab.ID && (r.Status == "waiting" || r.Status == "allotted"))
            {
                ourRecipients.Add(r);
            }
        }
        OrganRecipient        currentRecipient = ourRecipients[gvRecipients.PageSize * gvRecipients.PageIndex + gvRecipients.SelectedIndex];
        DeceasedOrganMatching deadOrgan        = new DeceasedOrganMatching();
        LiveOrganMatching     liveOrgan        = new LiveOrganMatching();
        int matchFound = 0;
        List <DeceasedOrganMatching> allDeadMatches = DeceasedOrganMatchingDB.getAllMatches();
        List <LiveOrganMatching>     allLiveMatches = LiveOrganMatchingDB.getAllMatches();

        foreach (DeceasedOrganMatching d in allDeadMatches)
        {
            if (d.Recipient.ID == currentRecipient.ID && d.Status == "current match")
            {
                matchFound = 1;
                deadOrgan  = d;
            }
        }
        foreach (LiveOrganMatching l in allLiveMatches)
        {
            if (l.Recipient.ID == currentRecipient.ID && l.Status == "current match")
            {
                matchFound = 2;
                liveOrgan  = l;
            }
        }
        pnlMatch.Visible = true;
        if (matchFound == 0)
        {
            lblOutput.Text = "Sorry no matches yet!";
        }
        else if (matchFound == 1)
        {
            currentRecipient.Status = "complete";
            OrganRecipientDB.updateOrganRecipient(currentRecipient);
            deadOrgan.DeceasedDonor.Status = "complete";
            DeceasedDonorDB.updateDeceasedDonor(deadOrgan.DeceasedDonor);
            deadOrgan.Status = "complete";
            DeceasedOrganMatchingDB.updateMatch(deadOrgan);



            foreach (DeceasedOrganMatching d2 in allDeadMatches)
            {
                if (d2.DeceasedDonor.ID == deadOrgan.DeceasedDonor.ID && d2.Status != "complete")
                {
                    d2.Status = "not possible";
                    DeceasedOrganMatchingDB.updateMatch(d2);
                }
            }

            foreach (DeceasedOrganMatching dd in allDeadMatches)
            {
                if (dd.Recipient.ID == currentRecipient.ID && dd.Status != "complete")
                {
                    dd.Status = "not possible";
                    DeceasedOrganMatchingDB.updateMatch(dd);
                }
            }

            foreach (LiveOrganMatching ll in allLiveMatches)
            {
                if (ll.Recipient.ID == currentRecipient.ID && ll.Status != "complete")
                {
                    ll.Status = "not possible";
                    LiveOrganMatchingDB.updateMatch(ll);
                }
            }
            Label1.Text = "Successfully completed";
            string MyAccountUrl = "RecipientWaitingList.aspx";
            Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", MyAccountUrl)));
        }
        else if (matchFound == 2)
        {
            currentRecipient.Status = "complete";
            OrganRecipientDB.updateOrganRecipient(currentRecipient);
            liveOrgan.LiveDonor.Status = "complete";
            LiveDonorDB.updateLiveDonor(liveOrgan.LiveDonor);
            liveOrgan.Status = "complete";
            LiveOrganMatchingDB.updateMatch(liveOrgan);



            foreach (LiveOrganMatching l2 in allLiveMatches)
            {
                if (l2.LiveDonor.LdonorID == liveOrgan.LiveDonor.LdonorID && l2.Status != "complete")
                {
                    l2.Status = "not possible";
                    LiveOrganMatchingDB.updateMatch(l2);
                }
            }

            foreach (DeceasedOrganMatching dd in allDeadMatches)
            {
                if (dd.Recipient.ID == currentRecipient.ID && dd.Status != "complete")
                {
                    dd.Status = "not possible";
                    DeceasedOrganMatchingDB.updateMatch(dd);
                }
            }
            foreach (LiveOrganMatching ll in allLiveMatches)
            {
                if (ll.Recipient.ID == currentRecipient.ID && ll.Status != "complete")
                {
                    ll.Status = "not possible";
                    LiveOrganMatchingDB.updateMatch(ll);
                }
            }
            Label1.Text = "Successfully completed";
            string MyAccountUrl = "RecipientWaitingList.aspx";
            Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", MyAccountUrl)));
        }
    }