Пример #1
0
        /// <summary>
        /// when page  is loaded: the labels and textboxs are set approtpriatly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((int)HttpContext.Current.Session["User_lvl"] == 3 || (int)HttpContext.Current.Session["User_lvl"] == 5)
            {
                lblError.Visible = false;

                try
                {
                    donation = new ServiceReference1.DonationRequester();
                    service  = new ServiceReference1.Service1Client();
                    user     = (ServiceReference1.UserDetail)HttpContext.Current.Session["User"];
                    if (HttpContext.Current.Session["fundID"] == null)
                    {
                        donation = service.getDonation(int.Parse(Request.QueryString["donationID"].ToString()));

                        lblAmount.Text = "R " + donation.Donate.Amount;
                        lblNPO.Text    = donation.NpoName;
                    }
                    else
                    {
                        lblNPO.Text    = HttpContext.Current.Session["NPOName"].ToString();
                        lblAmount.Text = "R " + HttpContext.Current.Session["Amount"];
                    }
                    lblCardHolder.Text = user.FirstNameValue;
                    lblEmail.Text      = user.EmailValue;

                    if (Request.QueryString["paypal"].ToString().Equals("Yes"))
                    {
                        cardNumber.Visible = false;
                        cardHolder.Visible = false;
                    }
                    else
                    {
                        cardNumber.Visible = true;
                        cardHolder.Visible = true;
                        lblCardNum.Text    = "**** **** **** " + Request.QueryString["cnum"];
                    }
                }
                catch (Exception ex)
                {
                    lblError.Visible = true;
                }
            }
        }
        /// <summary>
        /// This method is called and executed when btnAddDonation is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddDonation_Click(object sender, EventArgs e)
        {
            try
            {
                if ((int)HttpContext.Current.Session["User_lvl"] == 1)
                {
                    ServiceReference1.Service1Client    service     = new ServiceReference1.Service1Client();
                    ServiceReference1.DonationRequester newDonation = new ServiceReference1.DonationRequester();
                    ServiceReference1.UserDetail        user        = (ServiceReference1.UserDetail)HttpContext.Current.Session["User"];

                    newDonation.OrgID       = service.getNPOWithManager(user.userValue.UserID);
                    newDonation.Discription = txtDescription.Text;
                    double amount = double.Parse(txtAmount.Text);
                    newDonation.Amount = amount;
                    int typeInt = ddlType.SelectedIndex + 1;
                    newDonation.Type = typeInt;
                    newDonation.Date = Convert.ToDateTime(DateTime.Today);

                    bool added = service.addDonationRequest(newDonation);

                    if (added)
                    {
                        lblError.Text = "Donation request added successfully!";
                    }
                    else
                    {
                        lblError.Text = "An error occured please try again!";
                    }
                }
                else
                {
                    lblError.Text = "You have insufficient permission to do this!";
                }
            }
            catch (Exception ex)
            {
                lblError.Text = "An error occured when adding the donation. Please check the amount textbox and try again. Use a ',' for decimals!";
            }
        }
        /// <summary>
        /// This method is called and executed when the page is loaded.
        /// All donations are retrieved and displayed on the page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            NewDons.Visible = false;
            if ((int)HttpContext.Current.Session["User_lvl"] == 3 || (int)HttpContext.Current.Session["User_lvl"] == 5)
            {
                ServiceReference1.Service1Client      service   = new ServiceReference1.Service1Client();
                ServiceReference1.UserDetail          user      = (ServiceReference1.UserDetail)HttpContext.Current.Session["User"];
                ServiceReference1.DonationRequester[] donations = service.getAllDonationRequest(user.userValue.UserID);

                DonationsTable.InnerHtml  = "";
                DonationsTable.InnerHtml += "<table style='width: 100%; border: solid #ddd; border-width: 1px 1px 1px 1px; clear: both; margin: 10px 0 30px; height: 0;'><tr style='border-bottom: solid #ddd; border-bottom-width: 1px; clear: both; margin: 10px 0 30px; height: 0;'><th style='text-align: left; margin-right: 10px;'>NPO</th><th style='text-align: left; margin-right: 10px;'>Amount</th><th style='text-align: left; margin-right: 10px;'>Description</th><th style='text-align: left; margin-right: 10px;'>Donate</th></tr>";

                DonationsTableNew.InnerHtml  = "";
                DonationsTableNew.InnerHtml += "<table style='width: 100%; border: solid #ddd; border-width: 1px 1px 1px 1px; clear: both; margin: 10px 0 30px; height: 0;'><tr style='border-bottom: solid #ddd; border-bottom-width: 1px; clear: both; margin: 10px 0 30px; height: 0;'><th style='text-align: left; margin-right: 10px;'>NPO</th><th style='text-align: left; margin-right: 10px;'>Amount</th><th style='text-align: left; margin-right: 10px;'>Description</th><th style='text-align: left; margin-right: 10px;'>Donate</th></tr>";


                int countDons = 0;

                ArrayList availableDons = new ArrayList();

                for (int a = 0; a < donations.Count(); a++)
                {
                    ServiceReference1.Organisation org = service.getOrg(donations[a].OrgID);

                    if ((bool)org.Verified)
                    {
                        if (!donations[a].Inprogress)
                        {
                            availableDons.Add(donations[a]);
                        }
                    }
                }

                ServiceReference1.DonationRequester[] avDons = (ServiceReference1.DonationRequester[])availableDons.ToArray(typeof(ServiceReference1.DonationRequester));
                numOfDonsNew = 0;
                numOfDons    = 0;

                foreach (ServiceReference1.DonationRequester d in avDons)
                {
                    if (DashboardPage.lastOnline <= d.Donate.DonationDate)
                    {
                        numOfDonsNew++;
                    }
                    else
                    {
                        numOfDons++;
                    }
                }

                ServiceReference1.DonationRequester[] avDonsNew = new ServiceReference1.DonationRequester[numOfDonsNew];
                ServiceReference1.DonationRequester[] avDonsOld = new ServiceReference1.DonationRequester[numOfDons];

                int oldCount = 0;
                int newCount = 0;

                foreach (ServiceReference1.DonationRequester d in avDons)
                {
                    if (DashboardPage.lastOnline <= d.Donate.DonationDate)
                    {
                        avDonsNew[newCount] = d;
                        newCount++;
                    }
                    else
                    {
                        avDonsOld[oldCount] = d;
                        oldCount++;
                    }
                }

                if (numOfDonsNew > 0)
                {
                    NewDons.Visible = true;

                    for (int a = (pageCountNew - 1) * 4; a < pageCountNew * 4; a++)
                    {
                        if (a >= numOfDonsNew)
                        {
                            break;
                        }

                        if (searchStrNew.Equals(""))
                        {
                            DonationsTableNew.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + avDonsNew[a].NpoName + "</th><th style='text-align: right; padding-right: 10px;'>R " + avDonsNew[a].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + avDonsNew[a].Donate.Description + "</th><th style='text-align: left;'><a href='PaymentForm.aspx?donationID=" + avDonsOld[a].Donate.RequestIDNumber + "' class='button'>Donate now</a></th></tr>";

                            countDons++;
                        }
                        else
                        {
                            int numOfDonsAdded = 0;
                            for (int b = 0; b < numOfDons; b++)
                            {
                                if (numOfDonsAdded > 3)
                                {
                                    break;
                                }
                                if (avDons[b].Discription.Contains(searchStr))
                                {
                                    DonationsTableNew.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + avDonsNew[b].NpoName + "</th><th style='text-align: right; padding-right: 10px;'>R " + avDonsNew[b].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + avDonsNew[b].Donate.Description + "</th><th style='text-align: left;'><a href='PaymentForm.aspx?donationID=" + avDonsOld[b].Donate.RequestIDNumber + "' class='button'>Donate now</a></th></tr>";

                                    numOfDonsAdded++;
                                }
                            }

                            searchStrNew      = "";
                            txtSearchNew.Text = "";
                            break;
                        }
                    }

                    DonationsTableNew.InnerHtml += "</table>";
                }

                countDons = 0;

                for (int a = (pageCount - 1) * 4; a < pageCount * 4; a++)
                {
                    if (a >= numOfDons)
                    {
                        break;
                    }

                    if (searchStr.Equals(""))
                    {
                        DonationsTable.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + avDonsOld[a].NpoName + "</th><th style='text-align: right; padding-right: 10px;'>R " + avDonsOld[a].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + avDonsOld[a].Donate.Description + "</th><th style='text-align: left;'><a href='PaymentForm.aspx?donationID=" + avDonsOld[a].Donate.RequestIDNumber + "' class='button'>Donate now</a></th></tr>";

                        countDons++;
                    }
                    else
                    {
                        int numOfDonsAdded = 0;
                        for (int b = 0; b < numOfDons; b++)
                        {
                            if (numOfDonsAdded > 3)
                            {
                                break;
                            }
                            if (avDons[b].Discription.Contains(searchStr))
                            {
                                DonationsTable.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + avDonsOld[b].NpoName + "</th><th style='text-align: right; padding-right: 10px;'>R " + avDonsOld[b].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + avDonsOld[b].Donate.Description + "</th><th style='text-align: left;'><a href='PaymentForm.aspx?donationID=" + avDonsOld[b].Donate.RequestIDNumber + "' class='button'>Donate now</a></th></tr>";

                                numOfDonsAdded++;
                            }
                        }

                        searchStr      = "";
                        txtSearch.Text = "";
                        break;
                    }
                }

                DonationsTable.InnerHtml += "</table>";
            }
        }
        /// <summary>
        /// This method is called and executed when the page is loaded.
        /// This method retrieves and displays the donations that are specific to a user.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((int)HttpContext.Current.Session["User_lvl"] == 1 || (int)HttpContext.Current.Session["User_lvl"] == 2)
            {
                ServiceReference1.Service1Client      service   = new ServiceReference1.Service1Client();
                ServiceReference1.UserDetail          user      = (ServiceReference1.UserDetail)HttpContext.Current.Session["User"];
                ServiceReference1.DonationRequester[] donations = service.getAllNDonationRequest(service.getNPOWithManager(user.userValue.UserID));

                DonationsTable.InnerHtml  = "";
                DonationsTable.InnerHtml += "<table style='width: 100%; border: solid #ddd; border-width: 1px 1px 1px 1px; clear: both; margin: 10px 0 30px; height: 0;'><tr style='border-bottom: solid #ddd; border-bottom-width: 1px; clear: both; margin: 10px 0 30px; height: 0;'><th style='text-align: left; margin-right: 10px'>Type</th><th style='text-align: left; margin-right: 10px'>Amount</th><th style='text-align: left; margin-right: 10px'>Description</th><th style='text-align: left; margin-right: 10px; width: 100px;'>Donation request date</th></tr>";

                DonationsTableOld.InnerHtml  = "";
                DonationsTableOld.InnerHtml += "<table style='width: 100%; border: solid #ddd; border-width: 1px 1px 1px 1px; clear: both; margin: 10px 0 30px; height: 0;'><tr style='border-bottom: solid #ddd; border-bottom-width: 1px; clear: both; margin: 10px 0 30px; height: 0;'><th style='text-align: left; margin-right: 10px'>Type</th><th style='text-align: left; margin-right: 10px'>Amount</th><th style='text-align: left; margin-right: 10px'>Description</th><th style='text-align: left; margin-right: 10px; width: 100px;'>Donation request date</th></tr>";

                numOfDons    = 0;
                numOfDonsOld = 0;

                foreach (ServiceReference1.DonationRequester r in donations)
                {
                    if (r.Inprogress)
                    {
                        numOfDonsOld++;
                    }
                    else
                    {
                        numOfDons++;
                    }
                }

                ServiceReference1.DonationRequester[] donationsNew = new ServiceReference1.DonationRequester[numOfDons];
                ServiceReference1.DonationRequester[] donationsOld = new ServiceReference1.DonationRequester[numOfDonsOld];
                int oldCount = 0;
                int newCount = 0;

                foreach (ServiceReference1.DonationRequester r in donations)
                {
                    if (r.Inprogress)
                    {
                        donationsOld[oldCount] = r;
                        oldCount++;
                    }
                    else
                    {
                        donationsNew[newCount] = r;
                        newCount++;
                    }
                }

                for (int a = 0; a < donations.Count(); a++)
                {
                    if (donations[a].Inprogress)
                    {
                        donationCSV += donations[a].Date.ToShortDateString() + "," + donations[a].Discription + "," + donations[a].Amount + "\n";
                    }
                }

                for (int a = (pageCount - 1) * 8; a < pageCount * 8; a++)
                {
                    if (a >= numOfDons)
                    {
                        break;
                    }

                    string type = "";

                    if (donationsNew[a].Donate.Type == 1)
                    {
                        type = "Monetary donation";
                    }
                    else if (donationsNew[a].Donate.Type == 2)
                    {
                        type = "Equipment donation";
                    }

                    if (!donationsNew[a].Inprogress)
                    {
                        if (searchStr.Equals(""))
                        {
                            DonationsTable.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + type + "</th><th style='text-align: right; padding-right: 10px;'>R " + donationsNew[a].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsNew[a].Donate.Description + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsNew[a].Donate.DonationDate.Value.ToShortDateString() + "</th></tr>";
                        }
                        else
                        {
                            int numOfDonsAdded = 0;
                            for (int b = 0; b < numOfDons; b++)
                            {
                                if (numOfDonsAdded > 7)
                                {
                                    break;
                                }
                                if (donationsNew[b].Donate.Description.Contains(searchStr))
                                {
                                    if (!donationsNew[b].Inprogress)
                                    {
                                        DonationsTable.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + type + "</th><th style='text-align: right; padding-right: 10px;'>R " + donationsNew[b].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsNew[b].Donate.Description + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsNew[b].Donate.DonationDate.Value.ToShortDateString() + "</th></tr>";
                                        numOfDonsAdded++;
                                    }
                                }
                            }

                            searchStr      = "";
                            txtSearch.Text = "";
                            break;
                        }
                    }
                }

                DonationsTable.InnerHtml += "</table>";

                for (int a = (pageCountOld - 1) * 8; a < pageCountOld * 8; a++)
                {
                    if (a >= numOfDonsOld)
                    {
                        break;
                    }

                    string type = "";

                    if (donationsOld[a].Donate.Type == 1)
                    {
                        type = "Monetary donation";
                    }
                    else if (donationsOld[a].Donate.Type == 2)
                    {
                        type = "Equipment donation";
                    }

                    if (donationsOld[a].Inprogress)
                    {
                        if (searchStrOld.Equals(""))
                        {
                            DonationsTableOld.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + type + "</th><th style='text-align: right; padding-right: 10px;'>R " + donationsOld[a].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsOld[a].Donate.Description + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsOld[a].Donate.DonationDate.Value.ToShortDateString() + "</th></tr>";
                        }
                        else
                        {
                            int numOfDonsAdded = 0;
                            for (int b = 0; b < numOfDonsOld; b++)
                            {
                                if (numOfDonsAdded > 7)
                                {
                                    break;
                                }
                                if (donationsOld[b].Donate.Description.Contains(searchStrOld))
                                {
                                    if (donationsOld[b].Inprogress)
                                    {
                                        DonationsTableOld.InnerHtml += "<tr><th style='text-align: left; margin-right: 10px;'>" + type + "</th><th style='text-align: right; padding-right: 10px;'>R " + donationsOld[b].Donate.Amount + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsOld[b].Donate.Description + "</th><th style='text-align: left; margin-right: 10px;'>" + donationsOld[b].Donate.DonationDate.Value.ToShortDateString() + "</th></tr>";
                                        numOfDonsAdded++;
                                    }
                                }
                            }

                            searchStrOld      = "";
                            txtSearchOld.Text = "";
                            break;
                        }
                    }
                }

                DonationsTableOld.InnerHtml += "</table>";
            }
        }
Пример #5
0
        /// <summary>
        /// This method is called when the page is loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((int)HttpContext.Current.Session["User_lvl"] == 3 || (int)HttpContext.Current.Session["User_lvl"] == 5)
            {
                if (!Page.IsPostBack)
                {
                    paypalPassword.Visible    = false;
                    paypalPasswordTxt.Visible = false;
                    cardNum.Visible           = true;
                    cardNumTxt.Visible        = true;
                    cardHolder.Visible        = true;
                    cardHolderTxt.Visible     = true;
                    ccvNum.Visible            = true;
                    ccvNumTxt.Visible         = true;
                    expTitle.Visible          = true;
                    expMY.Visible             = true;
                    expMYddl.Visible          = true;

                    lblError.Visible = false;
                }
                else
                {
                    lblError.Visible = false;
                    if (rbPayment.SelectedIndex == 3)
                    {
                        paypalPassword.Visible    = true;
                        paypalPasswordTxt.Visible = true;
                        cardNum.Visible           = false;
                        cardNumTxt.Visible        = false;
                        cardHolder.Visible        = false;
                        cardHolderTxt.Visible     = false;
                        ccvNum.Visible            = false;
                        ccvNumTxt.Visible         = false;
                        expTitle.Visible          = false;
                        expMY.Visible             = false;
                        expMYddl.Visible          = false;
                    }
                    else
                    {
                        paypalPassword.Visible    = false;
                        paypalPasswordTxt.Visible = false;
                        cardNum.Visible           = true;
                        cardNumTxt.Visible        = true;
                        cardHolder.Visible        = true;
                        cardHolderTxt.Visible     = true;
                        ccvNum.Visible            = true;
                        ccvNumTxt.Visible         = true;
                        expTitle.Visible          = true;
                        expMY.Visible             = true;
                        expMYddl.Visible          = true;
                    }
                }

                try
                {
                    lblError.Visible = false;
                    ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
                    donation = new ServiceReference1.DonationRequester();

                    if (HttpContext.Current.Session["fundID"] == null)
                    {
                        donation = service.getDonation(int.Parse(Request.QueryString["donationID"].ToString()));

                        lblNPO.Text    = donation.NpoName;
                        lblAmount.Text = "R " + donation.Donate.Amount;
                    }
                    else
                    {
                        lblNPO.Text    = HttpContext.Current.Session["NPOName"].ToString();
                        lblAmount.Text = "R " + HttpContext.Current.Session["Amount"];
                        fund           = true;
                    }
                }
                catch (Exception ex)
                {
                    lblError.Visible = true;
                    lblError.Text    = "An error occured!";
                }
            }
        }