Exemple #1
0
    private void BindGrid()
    {
        AdhocInvoiceItemList list = AdhocInvoiceItemList.GetAdhocInvoiceItemList(adInv.PayGroupId, adInv.Id);


        radGridEntry.DataSource = list;
        radGridEntry.Rebind();
    }
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
    protected void BindEntry()
    {
        Effie2017.App.Registration registration = Security.GetLoginSessionUser();
        List <Effie2017.App.Entry> entryList    = new List <Effie2017.App.Entry>();
        string guidList = "";

        Effie2017.App.EntryList entryList2 = Effie2017.App.EntryList.GetEntryList(Guid.Empty, registration.Id, "", StatusEntry.PaymentPending + "|" + StatusEntry.UploadPending + "|" + StatusEntry.UploadCompleted + "|" + StatusEntry.Completed + "|");

        foreach (Effie2017.App.Entry entry in entryList2)
        {
            //Try 3
            bool isFound = false;
            foreach (Effie2017.App.Entry entryCheck in entryList)
            {
                if (entryCheck.Invoice == entry.Invoice)
                {
                    isFound                    = true;
                    entryCheck.Amount         += entry.Amount;
                    entryCheck.Fee            += entry.Fee;
                    entryCheck.AmountReceived += entry.AmountReceived;
                    entryCheck.GrandAmount    += entry.GrandAmount;
                }
            }

            if (!isFound)
            {
                entryList.Add(entry);
            }
            //END Try 3
        }

        radGridEntry.DataSource = entryList;
        List <Effie2017.App.AdhocInvoiceItem> adhocInvoiceList = new List <Effie2017.App.AdhocInvoiceItem>();

        foreach (var entryItem in entryList)
        {
            AdhocInvoiceItemList AdhocInvoiceLists = Effie2017.App.AdhocInvoiceItemList.GetAdhocInvoiceItemList(entryItem.Id);
            foreach (var AdhocInvoiceItem in AdhocInvoiceLists)
            {
                int count = adhocInvoiceList.Where(x => x.Invoice == AdhocInvoiceItem.Invoice).ToList().Count();
                if (count == 0)
                {
                    adhocInvoiceList.Add(AdhocInvoiceItem);
                }
            }
        }

        radGridEntryAdhoc.DataSource = adhocInvoiceList.Where(x => !string.IsNullOrEmpty(x.Invoice));
    }
Exemple #4
0
    private void DisplayPriceAmounts()
    {
        AdhocInvoiceItemList adInvoiceItemList = AdhocInvoiceItemList.GetAdhocInvoiceItemList(payGroupId, Guid.Empty);

        decimal subtotal = adInvoiceItemList.Sum(m => m.Amount);
        decimal fees     = 0;

        if (rblPayment.SelectedValue == PaymentType.Cheque)
        {
            fees                = 0;
            lbTotalFees.Text    = subtotal.ToString("N");
            phAdminFees.Visible = false;
        }
        else
        {
            if (rblPayment.SelectedValue == PaymentType.PayPal)
            {
                fees = GeneralFunction.CalculateCreditFees(subtotal);
            }
            else if (rblPayment.SelectedValue == PaymentType.BankTransfer)
            {
                fees = GeneralFunction.CalculateBankTransferFees();
            }

            phAdminFees.Visible = true;
        }
        if (fees == 0)
        {
            phAdminFees.Visible = false;
        }


        decimal total = subtotal + fees;
        decimal gst   = 0;

        if (ddlCountry.SelectedValue.ToLower() == "singapore")
        {
            gst = GeneralFunction.CalculateTax(total);
        }
        decimal grandtotal = subtotal + fees + gst;

        lbSubTotal.Text  = total.ToString("N");
        lbAdminFees.Text = fees.ToString("N");
        lbGST.Text       = gst.ToString("N");
        lbTotalFees.Text = grandtotal.ToString("N");

        lbGSTRate.Text = (decimal.Parse(ConfigurationManager.AppSettings["GSTRate"]) * 100).ToString("#");
    }
Exemple #5
0
    public static Guid GetAdminidAssignedto(Guid PayGroupId, Guid Id)
    {
        Guid AdminidAssignedto = Guid.Empty;

        try
        {
            AdhocInvoiceItem adhocInvoiceItem = AdhocInvoiceItemList.GetAdhocInvoiceItemList(PayGroupId, Id).FirstOrDefault();
            Entry            entry            = Entry.GetEntry(adhocInvoiceItem.EntryId);

            Administrator administrator = AdministratorList.GetAdministratorList().Where(x => x.Id == entry.AdminidAssignedto).FirstOrDefault();
            AdminidAssignedto = administrator.Id;
        }
        catch { }

        return(AdminidAssignedto);
    }
Exemple #6
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 #7
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 #8
0
    //public static MemoryStream GenerateAdhocReceipt(Registration reg, Guid paymentGroupId)
    //{
    //    PdfReader pdfReader = null;
    //    MemoryStream memoryStreamPdfStamper = null;
    //    PdfStamper pdfStamper = null;
    //    AcroFields pdfFormFields = null;

    //    AdhocInvoiceList adhocInvList = AdhocInvoiceList.GetAdhocInvoiceList(reg.Id,paymentGroupId);
    //    if (adhocInvList.Count > 0)
    //    {
    //        AdhocInvoiceItemList adhocInvItemList = AdhocInvoiceItemList.GetAdhocInvoiceItemList(paymentGroupId, adhocInvList[0].Id);

    //        EntryList entries = EntryList.GetEntryList(paymentGroupId, reg.Id, "");



    //        pdfReader = new PdfReader(System.Configuration.ConfigurationSettings.AppSettings["PdfTemplateLocation"] + "Adhoc Invoice Template.pdf");
    //        memoryStreamPdfStamper = new MemoryStream();
    //        pdfStamper = new PdfStamper(pdfReader, memoryStreamPdfStamper);
    //        pdfFormFields = pdfStamper.AcroFields;


    //        // Form filling
    //        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //        // Basic information
    //        string customerinfo = "";
    //        customerinfo += adhocInvList[0].PayFirstname + " " + adhocInvList[0].PayLastname + "\r\n";
    //        customerinfo += adhocInvList[0].PayCompany + "\r\n";
    //        customerinfo += adhocInvList[0].PayAddress1 + "\r\n";
    //        if (adhocInvList[0].PayAddress2.Trim() != "") customerinfo += adhocInvList[0].PayAddress2 + "\r\n";
    //        customerinfo += adhocInvList[0].PayCity;
    //        if (adhocInvList[0].PayCity.Trim() != "") customerinfo += " ";
    //        customerinfo += adhocInvList[0].PayPostal + "\r\n";
    //        customerinfo += adhocInvList[0].PayCountry + "\r\n";


    //        pdfFormFields.SetField("customer", customerinfo);

    //        int rowcounter = 1;
    //        decimal total = 0;
    //        decimal fees = 0;
    //        decimal tax = 0;
    //        decimal grandtotal = 0;
    //        string invno = "";
    //        foreach (AdhocInvoiceItem adhocInvItem in adhocInvItemList)
    //        {
    //            Entry entry = Entry.GetEntry(adhocInvItem.EntryId);

    //            PopulateFeeRowAdhoc(rowcounter, pdfFormFields, entry.Serial + " - " + (adhocInvItem.InvoiceType.Equals(AdhocInvoiceType.Custom) ? adhocInvItem.InvoiceTypeOthers : GeneralFunction.GetInvoiceType(adhocInvItem.InvoiceType)) + "<br/>"+entry.Campaign, adhocInvItem.Amount);

    //            rowcounter++;

    //            string DateInvoice = "";
    //            if (adhocInvList[0].InvoiceDate != DateTime.MaxValue && adhocInvList[0].InvoiceDate != DateTime.MinValue)
    //                DateInvoice = adhocInvList[0].InvoiceDate.ToString("dd MMM yyyy");

    //            pdfFormFields.SetField("date", DateInvoice);
    //        }

    //        total = adhocInvList[0].Amount;
    //        fees = adhocInvList[0].Fee;
    //        tax = adhocInvList[0].Tax;
    //        grandtotal = adhocInvList[0].GrandAmount;

    //        invno = adhocInvList[0].Invoice;

    //        pdfFormFields.SetField("invno", invno);

    //        pdfFormFields.SetField("st1", "S$ " + (total + fees).ToString("N"));

    //        // Tax
    //        pdfFormFields.SetField("st4", "S$ " + tax.ToString("N"));

    //        //if (isPP)
    //        pdfFormFields.SetField("st2", "S$ " + fees.ToString("N"));
    //        //if (fees != 0) pdfFormFields.SetField("admin", "Admin Fees");


    //        //if (isPP)
    //        pdfFormFields.SetField("st3", "S$ " + grandtotal.ToString("N"));

    //        // dummy
    //        pdfFormFields.SetField("blank", " ");

    //        pdfStamper.FormFlattening = true;
    //        pdfStamper.Writer.CloseStream = false;
    //        pdfStamper.Close();

    //        // test
    //        memoryStreamPdfStamper.Flush();
    //        memoryStreamPdfStamper.Seek(0, SeekOrigin.Begin);

    //    }

    //    return memoryStreamPdfStamper;
    //}
    #endregion

    #region New Method
    public static MemoryStream GenerateAdhocReceipt(Registration reg, Guid paymentGroupId)
    {
        Document     document             = new Document(PageSize.A4);
        MemoryStream memoryStreamDocument = new MemoryStream();
        PdfWriter    pdfWriter            = PdfWriter.GetInstance(document, memoryStreamDocument);

        pdfWriter.CloseStream = false;

        PdfReader    pdfReader = null;
        MemoryStream memoryStreamPdfStamper = null;
        PdfStamper   pdfStamper             = null;
        AcroFields   pdfFormFields          = null;

        AdhocInvoiceList adhocInvList = AdhocInvoiceList.GetAdhocInvoiceList(reg.Id, paymentGroupId);

        if (adhocInvList.Count > 0)
        {
            document.Open();
            AdhocInvoiceItemList adhocInvItemList = AdhocInvoiceItemList.GetAdhocInvoiceItemList(paymentGroupId, adhocInvList[0].Id);

            int     itemCounter = 1;
            int     rowcounter  = 1;
            decimal total       = 0;
            decimal fees        = 0;
            decimal tax         = 0;
            decimal grandtotal  = 0;
            string  invno       = "";

            int     pageCounter = 1;
            decimal totalPage   = Math.Ceiling((decimal)adhocInvItemList.Count / 9);

            foreach (AdhocInvoiceItem adhocInvItem in adhocInvItemList)
            {
                if (rowcounter == 1)
                {
                    if (pageCounter < totalPage)
                    {
                        pdfReader = new PdfReader(System.Configuration.ConfigurationSettings.AppSettings["PdfTemplateLocation"] + "Adhoc Invoice Template 1.pdf");
                    }
                    else
                    {
                        pdfReader = new PdfReader(System.Configuration.ConfigurationSettings.AppSettings["PdfTemplateLocation"] + "Adhoc Invoice Template 2.pdf");
                    }

                    memoryStreamPdfStamper = new MemoryStream();
                    pdfStamper             = new PdfStamper(pdfReader, memoryStreamPdfStamper);
                    pdfFormFields          = pdfStamper.AcroFields;


                    // Form filling
                    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                    // Basic information
                    string customerinfo = "";
                    customerinfo += adhocInvList[0].PayFirstname + " " + adhocInvList[0].PayLastname + "\r\n";
                    customerinfo += adhocInvList[0].PayCompany + "\r\n";
                    customerinfo += adhocInvList[0].PayAddress1 + "\r\n";
                    if (adhocInvList[0].PayAddress2.Trim() != "")
                    {
                        customerinfo += adhocInvList[0].PayAddress2 + "\r\n";
                    }
                    customerinfo += adhocInvList[0].PayCity;
                    if (adhocInvList[0].PayCity.Trim() != "")
                    {
                        customerinfo += " ";
                    }
                    customerinfo += adhocInvList[0].PayPostal + "\r\n";
                    customerinfo += adhocInvList[0].PayCountry + "\r\n";


                    pdfFormFields.SetField("customer", customerinfo);
                }

                //foreach (AdhocInvoiceItem adhocInvItem in adhocInvItemList)
                //{
                Entry entry = Entry.GetEntry(adhocInvItem.EntryId);

                PopulateFeeRowAdhoc(rowcounter, pdfFormFields,
                                    entry.Serial + " - " + entry.Campaign + "<br/>" + (adhocInvItem.InvoiceType.Equals(AdhocInvoiceType.Custom) ? adhocInvItem.InvoiceTypeOthers : GeneralFunction.GetInvoiceType(adhocInvItem.InvoiceType)),
                                    adhocInvItem.Amount, itemCounter);

                rowcounter++;
                itemCounter++;

                string DateInvoice = "";
                if (adhocInvList[0].InvoiceDate != DateTime.MaxValue && adhocInvList[0].InvoiceDate != DateTime.MinValue)
                {
                    DateInvoice = adhocInvList[0].InvoiceDate.ToString("dd MMM yyyy");
                }

                pdfFormFields.SetField("date", DateInvoice);
                //}

                total      = adhocInvList[0].Amount;
                fees       = adhocInvList[0].Fee;
                tax        = adhocInvList[0].Tax;
                grandtotal = adhocInvList[0].GrandAmount;

                invno = adhocInvList[0].Invoice;

                pdfFormFields.SetField("invno", invno);

                //GeneralFunction.GetInvoiceType(adhocInv.InvoiceType);

                if (pageCounter == totalPage)
                {
                    pdfFormFields.SetField("st1", "S$ " + (total + fees).ToString("N"));

                    // Tax
                    pdfFormFields.SetField("st4", "S$ " + tax.ToString("N"));

                    //if (isPP)
                    pdfFormFields.SetField("st2", "S$ " + fees.ToString("N"));
                    //if (fees != 0) pdfFormFields.SetField("admin", "Admin Fees");


                    //if (isPP)
                    pdfFormFields.SetField("st3", "S$ " + grandtotal.ToString("N"));
                }

                // dummy
                pdfFormFields.SetField("blank", " ");

                if (rowcounter == 10 || itemCounter == adhocInvItemList.Count + 1)
                {
                    pdfStamper.FormFlattening     = true;
                    pdfStamper.Writer.CloseStream = false;
                    pdfStamper.Close();

                    PdfContentByte pdfContentByte = pdfWriter.DirectContent;
                    document.NewPage();
                    PdfImportedPage pdfImportedPage = pdfWriter.GetImportedPage(new PdfReader(memoryStreamPdfStamper.GetBuffer()), 1);
                    pdfContentByte.AddTemplate(pdfImportedPage, 0, 0);

                    rowcounter = 1;
                    pageCounter++;
                }
            }

            document.Close();
        }

        // test
        memoryStreamDocument.Flush();
        //memoryStreamDocument.Seek(0, SeekOrigin.Begin);
        memoryStreamDocument.Position = 0;

        return(memoryStreamDocument);
    }
Exemple #9
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 #10
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);
            }
        }
    }