コード例 #1
0
    public static LiveOrganMatching getMatchByID(string id)
    {
        LiveOrganMatching m = new LiveOrganMatching();

        try
        {
            SqlCommand command = new SqlCommand("Select * from organMatchingLive where liveOrganMatch = @id");
            command.Parameters.AddWithValue("@id", id);
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                m.ID         = reader["liveOrganMatch"].ToString();
                m.LiveDonor  = LiveDonorDB.getLiveDonorbyID(reader["ldonorID"].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);
    }
コード例 #2
0
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Users            u      = UsersDB.getUserbyEmail(Session["email"].ToString());
        List <LiveDonor> ldlist = LiveDonorDB.getLiveDonorbyuserID(u.userId);

        foreach (LiveDonor l in ldlist)
        {
            if (l.status == "not allotted")
            {
                id = l.ldonorID;
                break;
            }
        }
        if (id != null)
        {
            LiveDonor nowld = LiveDonorDB.getLiveDonorbyID(id);

            nowld.status = "cancelled";
            int num = LiveDonorDB.updateLiveDonor(nowld);
            if (num != 1)
            {
                lblDOutput.Text = "Sorry cancel Failed!";
            }
            else
            {
                lblDOutput.Text = "Your organ donation is now cancelled!";
                string DonateOrganUrl = "DonateOrgan.aspx";
                Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", DonateOrganUrl)));
            }
        }
        else
        {
            lblDOutput.Text = "Sorry cancel Failed!";
        }
    }
コード例 #3
0
    public static List <LiveOrganMatching> getAllMatches()
    {
        List <LiveOrganMatching> matches = new List <LiveOrganMatching>();

        try
        {
            SqlCommand command = new SqlCommand("Select * from organMatchingLive");
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                LiveOrganMatching m = new LiveOrganMatching();
                m.ID         = reader["liveOrganMatch"].ToString();
                m.LiveDonor  = LiveDonorDB.getLiveDonorbyID(reader["ldonorID"].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);
    }
コード例 #4
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)));
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["email"] == null)
            {
                Server.Transfer("CommonLogin.aspx");
            }
            else
            {
                Users            u      = UsersDB.getUserbyEmail(Session["email"].ToString());
                List <LiveDonor> ldlist = LiveDonorDB.getLiveDonorbyuserID(u.userId);
                if (ldlist.Count == 0)
                {
                    Label1.Text = "Sorry! You doesn't have any current organ donation!";
                    PanelFinishRegister.Visible = false;
                }
                else
                {
                    foreach (LiveDonor l in ldlist)
                    {
                        if (l.status == "not allotted" || l.status == "allotted")
                        {
                            tempid = l.ldonorID;
                            PanelFinishRegister.Visible = true;
                            break;
                        }
                        else
                        {
                            tempid = "0";
                        }
                    }
                    if (tempid == "0")
                    {
                        Label1.Text = "Sorry! You doesn't have any current organ donation!";
                        PanelFinishRegister.Visible = false;
                    }
                    else
                    {
                        LiveDonor ld = LiveDonorDB.getLiveDonorbyID(tempid);

                        PanelFinishRegister.Visible = true;
                        lblComment.Text             = ld.comments;
                        lblDAddress.Text            = ld.doctorAddress;
                        lblDEmail.Text = ld.doctorEmail;
                        lblDoctor.Text = ld.doctorName;
                        lblDPhone.Text = Convert.ToString(ld.doctorNumber);
                        lblOrgan.Text  = ld.organType;
                        lblstatus.Text = ld.status;
                    }
                }

                List <LiveOrganMatching> lom     = LiveOrganMatchingDB.getAllMatches();
                List <LiveOrganMatching> lomshow = new List <LiveOrganMatching>();
                if (lom.Count == 0)
                {
                    lblmatchingF.Text = "Sorry! We haven't found any matching for you right now.";
                    gvMatch.Visible   = false;
                }
                else
                {
                    foreach (LiveOrganMatching l in lom)
                    {
                        if (l.LiveDonor.userid.UserId == u.UserId && l.Status == "current match")
                        {
                            l.Distance = l.Distance / 60;
                            lomshow.Add(l);
                        }
                    }

                    if (lomshow.Count == 0)
                    {
                        lblmatchingF.Text     = "Sorry! We haven't found any matching for you right now.";
                        panelmatching.Visible = false;
                    }
                    else
                    {
                        panelmatching.Visible = true;
                        gvMatch.DataSource    = lomshow;
                        gvMatch.DataBind();
                    }
                }
            }
        }
    }