Beispiel #1
0
        // to insert for renewal
        public int InsertIndividualContribution(IndividualContribution individualContribution)
        {
            int result = 0;

            try
            {
                List <SqlCommand> transcommand = new List <SqlCommand>();
                SqlCommand        mycmd        = new SqlCommand();
                SqlCommand        mycmd1       = new SqlCommand();

                string commandtext_Contribution = "INSERT INTO shared.TBL_CONTRIBUTION (MEMBER_ID, TOTAL_AMOUNT, CONTRIBUTION_DT, CREATED_DT, CONTRIBUTION_STATUS) VALUES ((select" +
                                                  " Member_Id from membership.TBL_Membership where Person_Id=@personId), @totalamount, @contributiondt, @createddate,@status)";
                mycmd1 = dbhelp.CreateCommand(commandtext_Contribution, CommandType.Text, "@personId", individualContribution.PersonId, "@totalamount", individualContribution.TotalAmount,
                                              "@contributiondt", individualContribution.ContributionDate, "@createddate", individualContribution.ContributionCreatedDate, "@status", individualContribution.Status);

                string commandtext_contributiontransaction = "INSERT INTO shared.TBL_CONTRIBUTION_TRANSACTION (CONTRIBUTION_ID, AMOUNT, PAYMENT_RECEIVED_DT, CREATED_DT, PAYMENT_DETAILS, PAYMENT_MODE," +
                                                             " PAYMENT_PURPOSE) VALUES ((SELECT MAX(CONTRIBUTION_ID) FROM shared.TBL_CONTRIBUTION), @amount, @paymentreceiveddate, @createddate, @paymentdets, @paymentmode, @paymentpurpose)";
                mycmd = dbhelp.CreateCommand(commandtext_contributiontransaction, CommandType.Text, "@amount", individualContribution.Amoount, "@paymentreceiveddate",
                                             individualContribution.PaymentReceivedDate, "@createddate", individualContribution.CreatedDate, "@paymentdets", individualContribution.PaymentDetails,
                                             "@paymentmode", individualContribution.PaymentMode, "@paymentpurpose", individualContribution.PaymentPurpose);

                dbhelp.ExecNonQuery("UPDATE c SET c.CONTRIBUTION_PAID = CONTRIBUTION_PAID + @amount FROM shared.TBL_CONTRIBUTION c inner join shared.TBL_CONTRIBUTION_TRANSACTION ct ON c.CONTRIBUTION_ID = ct.CONTRIBUTION_ID");

                transcommand.Add(mycmd1);
                transcommand.Add(mycmd);

                result = dbhelp.ExecTrans(transcommand);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteErrorLog(ex.ToString());
            }
            UpdatePaymentStatus(individualContribution);
            return(result);
        }
Beispiel #2
0
        // to insert for renewal
        public int InsertIndividualContributionInstallmentOrganisation(IndividualContribution individualContribution)
        {
            int result = 0;

            try
            {
                List <SqlCommand> transcommand = new List <SqlCommand>();
                SqlCommand        mycmd        = new SqlCommand();

                string commandtext_contributiontransaction = "INSERT INTO shared.TBL_CONTRIBUTION_TRANSACTION (CONTRIBUTION_ID, AMOUNT, PAYMENT_RECEIVED_DT, CREATED_DT, PAYMENT_DETAILS, PAYMENT_MODE," +
                                                             " PAYMENT_PURPOSE) VALUES (@contributionId, @amount, @paymentreceiveddate, @createddate, @paymentdets, @paymentmode, @paymentpurpose)";
                mycmd = dbhelp.CreateCommand(commandtext_contributiontransaction, CommandType.Text, "@contributionId", individualContribution.ContributionId, "@amount", individualContribution.Amoount, "@paymentreceiveddate",
                                             individualContribution.PaymentReceivedDate, "@createddate", individualContribution.CreatedDate, "@paymentdets", individualContribution.PaymentDetails,
                                             "@paymentmode", individualContribution.PaymentMode, "@paymentpurpose", individualContribution.PaymentPurpose);
                transcommand.Add(mycmd);

                result = dbhelp.ExecTrans(transcommand);
                UpdatePaymentStatusOrganisation(individualContribution);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteErrorLog(ex.ToString());
            }
            return(result);
        }
Beispiel #3
0
        public void UpdatePaymentStatus(IndividualContribution individualContribution)
        {
            List <SqlCommand> transcommand = new List <SqlCommand>();
            SqlCommand        mycmd        = new SqlCommand();

            try
            {
                string commandtext_Contribution = string.Format(@"SELECT top 1  ct.TOTAL_AMOUNT, Sum(c.AMOUNT) as Total_Paid from 
            shared.TBL_CONTRIBUTION_TRANSACTION c INNER JOIN shared.TBL_CONTRIBUTION ct
        on c.CONTRIBUTION_ID = ct.CONTRIBUTION_ID where ct.Contribution_Id={1} and ct.Member_Id = (select Member_Id from membership.TBL_Membership
          where Person_Id = {0}) group by ct.TOTAL_AMOUNT, ct.CONTRIBUTION_ID order by ct.CONTRIBUTION_ID desc", individualContribution.PersonId, individualContribution.ContributionId);
                mycmd = dbhelp.CreateCommand(commandtext_Contribution, CommandType.Text);
                transcommand.Add(mycmd);
                mycmd.Connection = dbhelp._conn;
                dbhelp._conn.Open();
                var dataReader = mycmd.ExecuteReader();
                individualContribution.Status = "Installment";
                if (dataReader != null && dataReader.HasRows)
                {
                    dataReader.Read();
                    var TotalAmount = dataReader.GetDecimal(0);
                    var paidAmount  = dataReader.GetDecimal(1);
                    if (paidAmount >= TotalAmount)
                    {
                        individualContribution.Status = "Full";
                    }
                    dataReader.Close();
                }

                string newQuery = string.Format("update shared.TBL_CONTRIBUTION set CONTRIBUTION_STATUS ='{0}', Contribution_Paid=Contribution_Paid+{1} Where Member_Id=(select Member_Id from membership.TBL_Membership " +
                                                " where Person_Id={3}) and Contribution_Id={2}", individualContribution.Status, individualContribution.Amoount, individualContribution.ContributionId, individualContribution.PersonId);
                mycmd.CommandText = newQuery;
                mycmd.ExecuteNonQuery();
                dbhelp._conn.Close();
            }
            catch (Exception ex)
            {
                ErrorLog.WriteErrorLog(ex.ToString());
            }
        }
Beispiel #4
0
        public void UpdatePaymentStatus(IndividualContribution individualContribution)
        {
            List <SqlCommand> transcommand = new List <SqlCommand>();
            SqlCommand        mycmd        = new SqlCommand();

            try {
                string commandtext_Contribution = "SELECT c.MEMBER_ID, c.TOTAL_AMOUNT, c.CONTRIBUTION_PAID from shared.TBL_CONTRIBUTION c INNER JOIN shared.TBL_CONTRIBUTION_TRANSACTION ct" +
                                                  " on c.CONTRIBUTION_ID = ct.CONTRIBUTION_ID where c.Member_Id=(Select Member_Id from membership.TBL_MEMBERSHIP VALUES ((select Member_Id from membership.TBL_Membership " +
                                                  " where Person_Id=@personId))";
                mycmd = dbhelp.CreateCommand(commandtext_Contribution, CommandType.Text, "@personId", individualContribution.PersonId);
                transcommand.Add(mycmd);
                DataTable dataTable = dbhelp.ExecDataReader(commandtext_Contribution);

                var dataReader = mycmd.ExecuteReader();
                individualContribution.Status = "Partial";
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        var TotalAmount = dataReader.GetDecimal(1);
                        var paidAmount  = dataReader.GetDecimal(2);
                        if (paidAmount >= TotalAmount)
                        {
                            individualContribution.Status = "Paid";
                        }
                    }
                    dataReader.Close();
                }
                string newQuery = string.Format("update shared.TBL_CONTRIBUTION set CONTRIBUTION_STATUS ='{0}' (Select Member_Id from membership.TBL_MEMBERSHIP VALUES ((select Member_Id from membership.TBL_Membership " +
                                                " where Person_Id=@personId))", individualContribution.Status);
                mycmd.CommandText = newQuery;
                mycmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog.WriteErrorLog(ex.ToString());
            }
        }
Beispiel #5
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);
                }
            }
        }