Example #1
0
        protected void Submit_Renewal(object sender, EventArgs e)
        {
            if (cbpaid.Checked)
            {
                int createindcheck = 0;
                IndividualContribution individualContribution = new IndividualContribution();
                individualContribution.Amoount                 = decimal.Parse(memfee.Value);
                individualContribution.PaymentReceivedDate     = DateTime.Parse(paymentreceiveddate.Value);
                individualContribution.PaymentPurpose          = "Membership";
                individualContribution.PaymentMode             = PaymentMode.Value;
                individualContribution.ExpiryDate              = datetime.Value;
                individualContribution.DonorTier               = Donor_Tier.Value;
                individualContribution.TotalAmount             = decimal.Parse(memfee.Value);
                individualContribution.PaymentDetails          = remarks.Value;
                individualContribution.CreatedDate             = DateTime.Now;
                individualContribution.ContributionCreatedDate = DateTime.Now;
                individualContribution.ContributionDate        = DateTime.Now;
                individualContribution.PersonId                = int.Parse(Session["PersonId"].ToString());
                individualContribution.Status = "Full";
                if (cbInstallment.Checked)
                {
                    individualContribution.Amoount = decimal.Parse(txtInstallment.Value);
                    individualContribution.Status  = "Installment";
                }
                if (!string.IsNullOrEmpty(individualContribution.DonorTier) && !string.IsNullOrEmpty(individualContribution.PaymentMode))
                {
                    if (individualContribution.DonorTier == "Friend of IPS")
                    {
                        individualContribution.ExpiryDate = datetime.Value;
                    }
                    else if (individualContribution.DonorTier == "Lifetime Friend of IPS" || individualContribution.DonorTier == "Lifetime Benefactor of IPS" ||
                             individualContribution.DonorTier == "Lifetime Patron of IPS")
                    {
                        datetime.Value = individualContribution.ExpiryDate = "NA";
                    }

                    DALMembership mem = new DALMembership();
                    // individual
                    int updateindcheck = mem.EditIndividual(individualContribution.DonorTier, individualContribution.ExpiryDate, individualID.Value, DateTime.Now);

                    createindcheck = mem.InsertIndividualContribution(individualContribution);
                    //decimal amt, string paymentreceiveddate, DateTime createddate, string paymentdets, string paymentmode, string paymentpurpose, decimal totalamt, DateTime contridate
                    if (createindcheck == 0)
                    {
                        //ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displaySuccess('Successfully Renewed!');", true);
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "showControlsAfterPostBackChecked();", true);
                    }
                }
                else
                {
                    //ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "showControlsAfterPostBackCheckedFailure();", true);
                }
            }
            else
            {
                //Update Membership Table if unchecked
                var expiry_date = datetime.Value;
                var donortier   = Donor_Tier.Value;
                if (!string.IsNullOrEmpty(donortier))
                {
                    if (donortier == "Friend of IPS")
                    {
                        expiry_date = datetime.Value;
                    }
                    else if (donortier == "Lifetime Friend of IPS" || donortier == "Lifetime Benefactor of IPS" ||
                             donortier == "Lifetime Patron of IPS")
                    {
                        expiry_date    = "NA";
                        datetime.Value = expiry_date;
                    }

                    DALMembership mem = new DALMembership();

                    //individual
                    int indcheck = mem.EditIndividual(donortier, expiry_date, individualID.Value, DateTime.Now);
                    if (indcheck > 0)
                    {
                        // ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "displaySuccess('Successfully Renewed!');", true);
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "showControlsAfterPostBackUnchecked();", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                }
            }
        }
        protected void Submit_Renewal(object sender, EventArgs e)
        {
            var expiry_date = datetime.Value;
            var donortier   = Donor_Tier.Value;

            if (donortier == "Friend of IPS")
            {
                expiry_date = datetime.Value;
            }
            else if (donortier == "Lifetime Friend of IPS" || donortier == "Lifetime Benefactor of IPS" ||
                     donortier == "Lifetime Patron of IPS")
            {
                expiry_date       = "NA";
                datetime.Value    = expiry_date;
                datetime.Disabled = true;
            }

            DALMembership mem = new DALMembership();

            if (cbpaid.Checked)
            {
                int createindcheck = 0;
                IndividualContribution individualContribution = new IndividualContribution();
                individualContribution.PaymentReceivedDate     = DateTime.Parse(paymentreceiveddate.Value);
                individualContribution.PaymentPurpose          = "Membership";
                individualContribution.PaymentMode             = PaymentMode.Value;
                individualContribution.ExpiryDate              = datetime.Value;
                individualContribution.DonorTier               = Donor_Tier.Value;
                individualContribution.PaymentDetails          = remarks.Value;
                individualContribution.CreatedDate             = DateTime.Now;
                individualContribution.ContributionCreatedDate = DateTime.Now;
                individualContribution.ContributionId          = (string)(Session["ContributionID"]);
                individualContribution.ContributionDate        = DateTime.Now;
                individualContribution.PersonId = int.Parse(Session["PersonId"].ToString());
                individualContribution.Status   = "Full";

                if (hdnStatus.Value.Contains("Partial"))
                {
                    if (!string.IsNullOrEmpty(individualContribution.PaymentMode))
                    {
                        if (cbInstallment.Checked)
                        {
                            individualContribution.Amoount = decimal.Parse(txtInstallment.Value);
                            individualContribution.Status  = "Installment";
                        }

                        int insertInstallment = 0;
                        insertInstallment = mem.InsertIndividualContributionInstallment(individualContribution);
                        if (insertInstallment > 0)
                        {
                            ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "showControlsAfterPostBackChecked();", true);

                            DALMembership dao            = new DALMembership();
                            int           contributionId = Convert.ToInt32(Session["ContributionID"]);
                            float         amountPaid     = dao.GetPartialPayment(contributionId);
                            hdnInstallment.Value = amountPaid.ToString();
                            hdnStatus.Value      = "Partial";
                            memfee.Disabled      = true;
                            txtInstallment.Value = amountPaid.ToString();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "showControlsAfterPostBackCheckedInstallmentFailure();", true);
                    }
                }
                else if (memfee.Disabled.Equals(false))
                {
                    if (cbInstallment.Checked.Equals(false))
                    {
                        if (!string.IsNullOrEmpty(individualContribution.DonorTier) && !string.IsNullOrEmpty(individualContribution.PaymentMode))
                        {
                            individualContribution.Amoount     = decimal.Parse(memfee.Value);
                            individualContribution.TotalAmount = decimal.Parse(memfee.Value);

                            if (cbInstallment.Checked)
                            {
                                individualContribution.Amoount = decimal.Parse(txtInstallment.Value);
                                individualContribution.Status  = "Installment";
                            }
                            int updateindcheck = mem.EditIndividual(individualContribution.DonorTier, individualContribution.ExpiryDate, individualID.Value, DateTime.Now);
                            createindcheck = mem.InsertIndividualContribution(individualContribution);

                            if (createindcheck > 0)
                            {
                                ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "showControlsAfterPostBackCheckedNoInstallment();", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "showControlsAfterPostBackCheckedFailure();", true);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(individualContribution.DonorTier) && !string.IsNullOrEmpty(individualContribution.PaymentMode))
                        {
                            individualContribution.Amoount     = decimal.Parse(memfee.Value);
                            individualContribution.TotalAmount = decimal.Parse(memfee.Value);

                            if (cbInstallment.Checked)
                            {
                                individualContribution.Amoount = decimal.Parse(txtInstallment.Value);
                                individualContribution.Status  = "Installment";
                            }
                            int updateindcheck = mem.EditIndividual(individualContribution.DonorTier, individualContribution.ExpiryDate, individualID.Value, DateTime.Now);
                            createindcheck = mem.InsertIndividualContribution(individualContribution);
                            if (createindcheck > 0 && cbInstallment.Checked.Equals(true))
                            {
                                ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "showControlsAfterPostBackCheckedFirst();", true);
                                // ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "showControlsAfterPostBackCheckedWithInstallment();", true);
                            }
                        }
                        else
                        {
                            // hdnStatus.Value = "PartialFirst";
                            ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "showControlsAfterPostBackCheckedInstallmentFailureFirst();", true);
                            //   ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "showControlsAfterPostBackCheckedFailureWithInstallment();", true);
                        }
                    }
                }
            }
            else
            {
                //Update Membership Table if unchecked
                if (!string.IsNullOrEmpty(donortier))
                {
                    int indcheck = mem.EditIndividual(donortier, expiry_date, individualID.Value, DateTime.Now);
                    if (indcheck > 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertDisplay", "showControlsAfterPostBackUnchecked();", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                }
            }
        }