Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Effie2017.App.Registration registration = (Effie2017.App.Registration)Session["registrationForPdfView"];
        //Effie2017.App.Entry entry = (Effie2017.App.Entry)Session["entryForPdfView"];

        if (Request["regId"] == null && Request["adId"] == null)
        {
            return;
        }

        AdhocInvoice adInv        = AdhocInvoice.GetAdhocInvoice(GeneralFunction.GetValueGuid(Request["adId"].ToString(), true));
        Registration registration = Registration.GetRegistration(GeneralFunction.GetValueGuid(Request["regId"].ToString(), true));

        if (registration == null || adInv == null)
        {
            return;
        }


        MemoryStream memoryStream = null;

        // invoice
        memoryStream = RegAttachment.GenerateAdhocReceipt(registration, adInv.PayGroupId);

        Response.ContentType = "application/pdf";
        //Response.AddHeader("Content-Disposition", "attachment; filename=Invoice.pdf");
        memoryStream.WriteTo(Response.OutputStream);
        memoryStream.Close();
    }
Exemple #2
0
    private void BindGrid()
    {
        AdhocInvoiceItemList adInvoiceList = AdhocInvoiceItemList.GetAdhocInvoiceItemList(payGroupId, Guid.Empty);

        if (adInvoiceList.Count > 0)
        {
            AdhocInvoice adInv = AdhocInvoice.GetAdhocInvoice(adInvoiceList[0].AdhocInvoiceId);

            //set Payment Method
            rblPayment.SelectedValue = adInv.PaymentMethod;

            rptEntry.DataSource = adInvoiceList;
            rptEntry.DataBind();


            // Prepop the form
            Registration thisuser = Registration.GetRegistration(adInv.RegistrationId);
            if (string.IsNullOrEmpty(adInv.PayCountry))
            {
                txtCompany.Text            = thisuser.Company;
                txtFirstname.Text          = thisuser.Firstname;
                txtLastname.Text           = thisuser.Lastname;
                txtAddress1.Text           = thisuser.Address1;
                txtAddress2.Text           = thisuser.Address2;
                txtCity.Text               = thisuser.City;
                txtPostal.Text             = thisuser.Postal;
                ddlCountry.SelectedValue   = thisuser.Country;
                txtContactCountryCode.Text = GeneralFunction.GetCountryCodeFromContactNumber(thisuser.Contact);
                txtContactAreaCode.Text    = GeneralFunction.GetAreaCodeFromContactNumber(thisuser.Contact);
                txtContactNumber.Text      = GeneralFunction.GetNumberFromContactNumber(thisuser.Contact);
            }
            else
            {
                txtCompany.Text            = adInv.PayCompany;
                txtFirstname.Text          = adInv.PayFirstname;
                txtLastname.Text           = adInv.PayLastname;
                txtAddress1.Text           = adInv.PayAddress1;
                txtAddress2.Text           = adInv.PayAddress2;
                txtCity.Text               = adInv.PayCity;
                txtPostal.Text             = adInv.PayPostal;
                ddlCountry.SelectedValue   = adInv.PayCountry;
                txtContactCountryCode.Text = GeneralFunction.GetCountryCodeFromContactNumber(adInv.PayContact);
                txtContactAreaCode.Text    = GeneralFunction.GetAreaCodeFromContactNumber(adInv.PayContact);
                txtContactNumber.Text      = GeneralFunction.GetNumberFromContactNumber(adInv.PayContact);
            }

            DisplayPriceAmounts();
        }
    }
Exemple #3
0
    public void PopulateForm()
    {
        ResetForm();

        // save the entryid
        hldEntryId.Value = PayGroupId.ToString();

        AdhocInvoiceList adInvList = AdhocInvoiceList.GetAdhocInvoiceList(Guid.Empty, PayGroupId);

        adInv = AdhocInvoice.GetAdhocInvoice(adInvList[0].Id);


        lblInvoice.Text = adInv.Invoice;

        BindGrid();
        lblAmount.Text = adInv.GrandAmount.ToString("N");
        //lblAmount.Text = entry.GrandAmount.ToString("N");
        lblPrevReceived.Text          = adInv.AmountReceived.ToString("N");
        lnkAmountReceived.NavigateUrl = "../AdhocAmountReceived.aspx?pgId=" + adInv.PayGroupId.ToString();

        chkPaid.Checked = (adInv.PayStatus == StatusPaymentEntry.Paid);
        chkPaid.Enabled = !chkPaid.Checked;

        //chkAllowUpload.Checked = (entry.Status == StatusEntry.UploadPending);
        //chkAllowUpload.Enabled = !chkPaid.Checked;

        // if the amt is less than invoice amt, enable back the check boxes
        if (!IsAmountFullyPaidPrevious())
        {
            chkPaid.Enabled = true;
            //chkAllowUpload.Enabled = true;
        }


        string lastdatesent = GeneralFunction.CleanDateTimeToString(adInv.LastSendPaidEmailDate, "dd/MM/yy HH:mm tt");

        if (lastdatesent == "")
        {
            lastdatesent = "-";
        }
        lbLastSendPaidEmailDate.Text = "(Last Sent:" + lastdatesent + ")";



        // Dedfault date
        dpDateReceived.SelectedDate = DateTime.Now;
    }
Exemple #4
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ValidateForm())
        {
            AdhocInvoice adInv = SaveForm();

            if (adInv != null)
            {
                GeneralFunction.CompletePendingPaymentAdhoc(adInv.RegistrationId, adInv.PayGroupId, adInv.PaymentMethod, lbTotalFees.Text, false);

                //if (entrySelected != null)
                {
                    Administrator        admin            = Security.GetAdminLoginSession();
                    AdhocInvoiceItemList adhocInvItemList = AdhocInvoiceItemList.GetAdhocInvoiceItemList(payGroupId, adInv.Id);
                    EntryList            entries          = EntryList.GetEntryList(Guid.Empty, adInv.RegistrationId, "");
                    foreach (AdhocInvoiceItem adhocInvItem in adhocInvItemList)
                    {
                        try {
                            //FILTER For REOPEN ENTRY PROCESSING
                            Entry entry = entries.FirstOrDefault(x => x.Id == adhocInvItem.EntryId &&
                                                                 ((x.Status == StatusEntry.Completed) && (x.ProcessingStatus == StatusEntry.PendingVerification)));

                            if (adhocInvItem.InvoiceType == "ReOpen")
                            {
                                //To set to Upload Complete if Payment Method is selected
                                if (adInv.Invoice == "" && adInv.PaymentMethod != "")
                                {
                                    entry.Status           = StatusEntry.UploadCompleted;
                                    entry.ReopenedBy       = admin.Id.ToString();
                                    entry.ProcessingStatus = StatusEntry.Reopened;
                                    entry.IDAdhocInvoice   = adhocInvItem.AdhocInvoiceId.ToString();
                                }
                                else
                                {
                                    entry.ReopenedBy       = admin.Id.ToString();
                                    entry.ProcessingStatus = StatusEntry.PendingReopen;
                                    entry.IDAdhocInvoice   = adhocInvItem.AdhocInvoiceId.ToString();
                                }

                                entry.Save();
                            }
                        }
                        catch { }
                    }

                    //if (rblPayment.SelectedValue == PaymentType.PayPal)
                    //{
                    //    // get the string of serial numbers
                    //    string serials = "";
                    //    EntryList list = EntryList.GetEntryList(adInv.PayGroupId, Guid.Empty, ""); // contains the pay group id
                    //    foreach (Entry entry in list)
                    //    {
                    //        serials += entry.Serial + ",";
                    //    }
                    //    if (serials != "") serials = serials.Substring(0, serials.Length - 1);

                    //    PayPal(serials);
                    //}
                    //else
                    {
                        if (!string.IsNullOrEmpty(Request.QueryString["Page"]) && (entrySelected != null))
                        {
                            Response.Redirect("EntryProcessing.aspx?Page=Management");
                        }
                        else if (entrySelected != null)
                        {
                            Response.Redirect("EntryProcessing.aspx");
                        }
                        else
                        {
                            Response.Redirect("../Admin/AdhocInvoiceList.aspx");
                        }
                        //Response.Redirect("../Main/PendingPayment.aspx");
                    }
                }
            }
        }
    }
Exemple #5
0
    private AdhocInvoice SaveForm()
    {
        AdhocInvoiceItemList adInvoiceItemList = AdhocInvoiceItemList.GetAdhocInvoiceItemList(payGroupId, Guid.Empty);

        if (adInvoiceItemList.Count > 0)
        {
            AdhocInvoice adInv = AdhocInvoice.GetAdhocInvoice(adInvoiceItemList[0].AdhocInvoiceId);
            // cal the grand total


            adInv.PayCompany   = txtCompany.Text.Trim();
            adInv.PayAddress1  = txtAddress1.Text.Trim();
            adInv.PayAddress2  = txtAddress2.Text.Trim();
            adInv.PayCity      = txtCity.Text.Trim();
            adInv.PayPostal    = txtPostal.Text.Trim();
            adInv.PayCountry   = ddlCountry.SelectedValue;
            adInv.PayFirstname = txtFirstname.Text.Trim();
            adInv.PayLastname  = txtLastname.Text.Trim();
            adInv.PayContact   = GeneralFunction.CreateContact(txtContactCountryCode.Text.Trim(), txtContactAreaCode.Text.Trim(), txtContactNumber.Text.Trim());

            //if (rblPayment.SelectedValue != PaymentType.PayPal)
            adInv.PaymentMethod = rblPayment.SelectedValue;

            if (!string.IsNullOrEmpty(adInv.PaymentMethod))
            {
                adInv.InvoiceDateString = DateTime.Now.ToString();
            }

            adInv.Amount = 0;
            adInv.Tax    = 0;
            adInv.Fee    = 0;


            foreach (AdhocInvoiceItem adInvoiceItem in adInvoiceItemList)
            {
                adInvoiceItem.GrandAmount = adInvoiceItem.Amount;

                adInvoiceItem.Save();

                adInv.Amount += adInvoiceItem.Amount;
            }

            decimal subtotal = adInv.Amount;

            if (rblPayment.SelectedValue == PaymentType.PayPal)
            {
                adInv.Fee = GeneralFunction.CalculateCreditFees(subtotal);
            }
            if (rblPayment.SelectedValue == PaymentType.BankTransfer)
            {
                adInv.Fee = GeneralFunction.CalculateBankTransferFees();
            }
            //entry.Tax = 0;
            if (ddlCountry.SelectedValue.ToLower() == "singapore")
            {
                adInv.Tax = GeneralFunction.CalculateTax(subtotal + adInv.Fee);
            }

            adInv.GrandAmount = adInv.Amount + adInv.Fee + adInv.Tax;

            if (adInv.IsValid)
            {
                adInv.Save();
            }

            return(adInv);
        }
        return(null);
    }
Exemple #6
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ValidateForm())
        {
            AdhocInvoice adInv = SaveForm();

            // id admin mode, go back to admin page
            if (isAdminEdit)
            {
                Response.Redirect(GeneralFunction.GetRedirect("../Admin/InvoiceList.aspx"));
            }

            //To set to Upload Complete if Payment Method is selected
            //Administrator admin = Security.GetAdminLoginSession();
            AdhocInvoiceItemList adhocInvItemList = AdhocInvoiceItemList.GetAdhocInvoiceItemList(payGroupId, adInv.Id);
            EntryList            entries          = EntryList.GetEntryList(Guid.Empty, adInv.RegistrationId, "");
            foreach (AdhocInvoiceItem adhocInvItem in adhocInvItemList)
            {
                try
                {
                    //FILTER For REOPEN ENTRY PROCESSING
                    Entry entry = entries.FirstOrDefault(x => x.Id == adhocInvItem.EntryId &&
                                                         ((x.Status == StatusEntry.Completed) && (x.ProcessingStatus == StatusEntry.PendingReopen)));

                    if (adhocInvItem.InvoiceType == "ReOpen")
                    {
                        //To set to Upload Complete if Payment Method is selected
                        if (adInv.Invoice == "" && adInv.PaymentMethod != "")
                        {
                            entry.Status           = StatusEntry.UploadCompleted;
                            entry.ReopeningDate    = DateTime.Now.ToString();                //
                            entry.ProcessingStatus = StatusEntry.Reopened;                   //
                            entry.IDAdhocInvoice   = adhocInvItem.AdhocInvoiceId.ToString(); //
                        }

                        entry.Save();
                    }
                }
                catch { }
            }

            GeneralFunction.CompletePendingPaymentAdhoc(adInv.RegistrationId, adInv.PayGroupId, adInv.PaymentMethod, lbTotalFees.Text, true);

            if (rblPayment.SelectedValue == PaymentType.PayPal)
            {
                // get the string of serial numbers
                string    serials = "";
                EntryList list    = EntryList.GetEntryList(adInv.PayGroupId, Guid.Empty, ""); // contains the pay group id
                foreach (Entry entry in list)
                {
                    serials += entry.Serial + ",";
                }
                if (serials != "")
                {
                    serials = serials.Substring(0, serials.Length - 1);
                }

                PayPal(serials);
            }
            else
            {
                Response.Redirect("../Main/PendingPayment.aspx");
            }
        }
    }
Exemple #7
0
    protected void btnGenerateInvoice_Click(object sender, EventArgs e)
    {
        if (ValidateForm())
        {
            regId = Request.QueryString["regId"];

            if (regId != null && !String.IsNullOrEmpty(regId))
            {
                regGuidId = new Guid(GeneralFunction.StringDecryption(regId));
            }

            reg = Registration.GetRegistration(regGuidId);

            Guid payGroupId = Guid.NewGuid();

            decimal totalAmount = 0;

            AdhocInvoice adInvoice = AdhocInvoice.NewAdhocInvoice();
            adInvoice.PayGroupId     = payGroupId;
            adInvoice.RegistrationId = reg.Id;

            foreach (GridDataItem item in radGridEntry.Items)
            {
                DropDownList ddlInvoiceType   = (DropDownList)item.FindControl("ddlInvoiceType");
                TextBox      txtAmount        = (TextBox)item.FindControl("txtAmount");
                TextBox      txtInvoiceCustom = (TextBox)item.FindControl("txtInvoiceCustom");
                HiddenField  hdfId            = (HiddenField)item.FindControl("hdfId");

                CheckBox chkbox = (CheckBox)item.FindControl("chkbox");

                if (chkbox.Checked)
                {
                    AdhocInvoiceItem adInvoiceItem = AdhocInvoiceItem.NewAdhocInvoiceItem();

                    adInvoiceItem.Amount = Decimal.Parse(txtAmount.Text.Trim());

                    adInvoiceItem.AdhocInvoiceId    = adInvoice.Id;
                    adInvoiceItem.EntryId           = new Guid(hdfId.Value.ToString());
                    adInvoiceItem.InvoiceType       = ddlInvoiceType.SelectedValue;
                    adInvoiceItem.InvoiceTypeOthers = txtInvoiceCustom.Text.Trim();

                    adInvoiceItem.PayGroupId = payGroupId;

                    adInvoiceItem.DateCreatedString  = DateTime.Now.ToString();
                    adInvoiceItem.DateModifiedString = DateTime.Now.ToString();

                    if (adInvoiceItem.IsValid)
                    {
                        adInvoiceItem.Save();
                    }
                }
            }

            adInvoice.DateCreatedString  = DateTime.Now.ToString();
            adInvoice.DateModifiedString = DateTime.Now.ToString();

            if (adInvoice.IsValid)
            {
                adInvoice.Save();
            }

            string InvoiceUrl = "AdhocInvoiceSummary.aspx?adm=e&pgId=" + GeneralFunction.StringEncryption(payGroupId.ToString());
            if (entrySelected != null)
            {
                InvoiceUrl = "AdhocInvoiceSummary.aspx?adm=e&pgId=" + GeneralFunction.StringEncryption(payGroupId.ToString()) + "&EntryId=" + GeneralFunction.StringEncryption(entrySelected.Id.ToString());
                if (!string.IsNullOrEmpty(Request.QueryString["Page"]))
                {
                    InvoiceUrl += "&Page=Management";
                }
            }

            GeneralFunction.SetRedirect(string.Empty);
            Response.Redirect(InvoiceUrl);
        }
    }
Exemple #8
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ValidateForm())
        {
            Guid             paygroupId  = new Guid(hldEntryId.Value);
            string           InvoiceType = "";
            AdhocInvoiceList adInvList   = AdhocInvoiceList.GetAdhocInvoiceList(Guid.Empty, paygroupId);
            adInv = AdhocInvoice.GetAdhocInvoice(adInvList[0].Id);
            Registration reg     = null;
            string       invoice = "";
            try
            {
                AdhocInvoiceItem adhocInvoiceItem = AdhocInvoiceItemList.GetAdhocInvoiceItemList(adInvList[0].PayGroupId, adInvList[0].Id)[0];
                InvoiceType = adhocInvoiceItem.InvoiceType;
                reg         = Registration.GetRegistration(adInvList[0].RegistrationId);
                invoice     = adInvList[0].Invoice;
            }
            catch { }

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


            // paid?
            bool   isPaid         = false;
            Guid   paymentGroupId = adInv.PayGroupId;
            string paidstatus_org = adInv.PayStatus;

            if (chkPaid.Checked && paidstatus_org == StatusPaymentEntry.NotPaid)
            {
                adInv.PayStatus = StatusPaymentEntry.Paid;
                isPaid          = true;
                adInv.Save();

                if (!string.IsNullOrEmpty(invoice))// AD-HOC INVOICE – CONFIRMATION OF PAYMENT
                {
                    if (InvoiceType == AdhocInvoiceType.ReOpen)
                    {
                        Email.SendAdhocReOpenPaymentEmailConfirm(reg, paygroupId, invoice);
                    }
                    else if (InvoiceType == AdhocInvoiceType.ChangeReq || InvoiceType == AdhocInvoiceType.Custom || InvoiceType == AdhocInvoiceType.ExtDeadLine)
                    {
                        Email.SendAdhocOtherRequestPaymentEmailConfirm(reg, paygroupId, invoice);
                    }

                    adInv.LastSendPaidEmailDateString = DateTime.Now.ToString();
                }
            }
            if (!chkPaid.Checked && paidstatus_org == StatusPaymentEntry.Paid)
            {
                adInv.PayStatus = StatusPaymentEntry.NotPaid;
            }

            adInv.Save();



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


            Administrator admin = Security.GetAdminLoginSession();
            // history
            AdhocInvoiceAmountReceived amt = AdhocInvoiceAmountReceived.NewAdhocInvoiceAmountReceived();
            amt.Amount             = decimal.Parse(txtAmountRecieved.Text);
            amt.DateReceivedString = dpDateReceived.DateInput.SelectedDate.ToString();
            amt.PaygroupId         = adInv.PayGroupId;
            amt.Invoice            = adInv.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);
            }
        }
    }