Beispiel #1
0
    protected void btnGo2_Click(object sender, EventArgs e)
    {
        Guid      payGroupId = new Guid(txtGroupId.Text);
        Guid      regId      = Guid.Empty;
        EntryList list       = EntryList.GetEntryList(payGroupId, Guid.Empty, ""); // contains the pay group id

        bool isChange = false;

        if (list[0].Invoice != "")
        {
            isChange = true;
        }

        string  invoice     = "";
        decimal totalamount = 0;

        foreach (Entry entry in list)
        {
            entry.Status    = StatusEntry.UploadPending;
            entry.PayStatus = StatusPaymentEntry.Paid;
            if (!isChange)
            {
                if (entry.Serial.Trim() == "")
                {
                    entry.Serial = GeneralFunction.GetNewOrderNumber(entry);
                }
                if (invoice == "")
                {
                    invoice = GeneralFunction.GetNewInvoiceNumber();
                }
            }
            else
            {
                invoice = entry.Invoice;
            }
            entry.Invoice = invoice;
            //entry.DateSubmittedString = DateTime.Now.ToString();
            //entry.Save();
            regId = entry.RegistrationId;
            //totalamount += GetEntryPrice(entry);
        }

        // update again for the amount to the 1st entry
        list[0].AmountReceived = totalamount;
        //list[0].Save();


        // Save a new amount received
        AmountReceived amt = AmountReceived.NewAmountReceived();

        amt.Amount             = totalamount;
        amt.DateReceivedString = DateTime.Now.ToString();
        amt.PaygroupId         = payGroupId;
        amt.Invoice            = invoice;
        amt.Remarks            = "Received from Paypal";
        amt.IsSetPaid          = true;
        amt.DateCreatedString  = DateTime.Now.ToString();
        //amt.Save();



        //Send Email
        Email.SendCompletedPaymentEmailPayPalChange(Registration.GetRegistration(regId), payGroupId, invoice); // payment group id

        GeneralFunction.UpdateEntryLastSendPaidEmailDate(payGroupId);
    }
Beispiel #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ValidateForm())
        {
            Guid entryId = new Guid(hldEntryId.Value);
            entry = Entry.GetEntry(entryId);

            // save the amount to the first entry or this default entry
            entry.AmountReceived += decimal.Parse(txtAmountRecieved.Text);
            entry.Save();


            // paid?
            bool      isPaid         = false;
            Guid      paymentGroupId = entry.PayGroupId;
            EntryList list           = EntryList.GetEntryList(paymentGroupId, Guid.Empty, "");
            foreach (Entry ent in list)
            {
                string paidstatus_org = ent.PayStatus;

                // Allow Upload - only if its not aleady pending complete or completed
                if (rblPayment.SelectedValue == "AllowUpload" && ent.Status != StatusEntry.UploadCompleted && ent.Status != StatusEntry.Completed)
                {
                    //if (rblPayment.SelectedValue == "AllowUpload")
                    //{
                    ent.Status = StatusEntry.UploadPending;
                    //}
                    //else
                    //{
                    //    ent.Status = StatusEntry.PaymentPending;
                    //}
                }

                // make the change only if the status has changed.
                // if not do not change it
                if (rblPayment.SelectedValue == StatusPaymentEntry.Paid /*chkPaid.Checked*/ && paidstatus_org == StatusPaymentEntry.NotPaid)
                {
                    ent.PayStatus = StatusPaymentEntry.Paid;

                    // set if its not aleady pending complete or completed
                    if (ent.Status != StatusEntry.UploadCompleted && ent.Status != StatusEntry.Completed)
                    {
                        ent.Status = StatusEntry.UploadPending;
                    }

                    isPaid = true;
                }

                //if (paidstatus_org == StatusPaymentEntry.Paid)
                //{
                //    ent.PayStatus = StatusPaymentEntry.NotPaid;
                //}


                // double check if paid then it must be allow upload
                if (ent.PayStatus == StatusPaymentEntry.Paid && ent.Status != StatusEntry.UploadCompleted && ent.Status != StatusEntry.Completed)
                {
                    ent.Status = StatusEntry.UploadPending;
                }

                ent.Save();
            }


            // send email? if sent before do not send any more
            string lastdatesent = GeneralFunction.CleanDateTimeToString(entry.LastSendPaidEmailDate, "dd/MM/yy HH:mm tt");
            //if (chkAllowUpload.Checked && lastdatesent == "")
            if (lastdatesent == "")
            {
                if (entry.PaymentMethod != PaymentType.PayPal)
                {
                    //if (IsAmountFullyPaidIncludeThisAmount())
                    if (rblPayment.SelectedValue == StatusPaymentEntry.Paid || IsAmountFullyPaidIncludeThisAmount())
                    {
                        // Full payment
                        GeneralFunction.CompleteNewEntrySubmissionOthers(paymentGroupId);
                    }
                    else if (rblPayment.SelectedValue == "AllowUpload")
                    {
                        // Partial payment
                        Email.SendCompletedPaymentEmailOthers(Registration.GetRegistration(list[0].RegistrationId), paymentGroupId, "");
                        GeneralFunction.UpdateEntryLastSendPaidEmailDate(paymentGroupId);
                    }
                }
            }


            Administrator admin = Security.GetAdminLoginSession();
            Registration  reg   = Security.GetLoginSessionUser();
            // history
            AmountReceived amt = AmountReceived.NewAmountReceived();
            amt.Amount = decimal.Parse(txtAmountRecieved.Text);
            DateTime datetime     = DateTime.Parse(dpDateReceived.DateInput.SelectedDate.ToString());
            string   Date         = datetime.ToString("MM/dd/yyyy");
            string   Time         = DateTime.Now.ToString("hh:mm tt");
            DateTime DateReceived = DateTime.Parse(Date + " " + Time);
            amt.DateReceivedString = DateReceived.ToString();
            amt.PaygroupId         = entry.PayGroupId;
            amt.Invoice            = "";
            amt.Remarks            = txtRemarks.Text;
            amt.IsSetPaid          = isPaid;
            amt.DateCreatedString  = DateTime.Now.ToString();
            if (admin != null)
            {
                amt.isAdmin       = true;
                amt.CommentatorID = admin.Id;
            }
            else
            {
                amt.isAdmin       = false;
                amt.CommentatorID = reg.Id;
            }
            amt.Save();



            if (Save_Clicked != null)
            {
                Save_Clicked(this, EventArgs.Empty);
            }
        }
    }