示例#1
0
    public void PopulateForm()
    {
        ResetForm();

        // save the entryid
        hldOrderId.Value = GalaOrderId.ToString();

        go              = GalaOrder.GetGalaOrder(GalaOrderId);
        total           = go.Amount + go.FeeShipping + go.Fee + go.Tax;
        lblInvoice.Text = go.Invoice;
        txtRemarks.Text = go.RemarksPayment;
        if (go.DatePaidString != "")
        {
            dpDateReceived.SelectedDate = go.DatePaid;
        }
        else
        {
            dpDateReceived.SelectedDate = DateTime.Now;
        }

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

        chkPaid.Checked = (go.PayStatus == StatusPaymentEntry.Paid);

        //string lastdatesent = GeneralFunction.CleanDateTimeToString(entry.LastSendPaidEmailDate, "dd/MM/yy HH:mm tt");
        //if (lastdatesent == "") lastdatesent = "-";
        //lbLastSendPaidEmailDate.Text = "(Last Sent:" + lastdatesent + ")";
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        id = Request.QueryString["Id"];
        if (id != null && id != "")
        {
            go = GalaOrder.GetGalaOrder(new Guid(id));
        }
        else
        {
            go = GalaOrder.NewGalaOrder();
        }

        if (!IsPostBack)
        {
            LoadForm();
            PopulateForm();
        }
    }
示例#3
0
    public static MemoryStream GenerateGalaReceipt(GalaOrder go)
    {
        PdfReader    pdfReader = null;
        MemoryStream memoryStreamPdfStamper = null;
        PdfStamper   pdfStamper             = null;
        AcroFields   pdfFormFields          = null;

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


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

        // Basic information
        string customerinfo = "";

        customerinfo += go.PayFirstname + " " + go.PayLastname + "\r\n";
        customerinfo += go.PayCompany + "\r\n";
        customerinfo += go.PayAddress1 + "\r\n";
        customerinfo += go.PayAddress2 + "\r\n";
        customerinfo += go.PayCity;
        if (go.PayCity.Trim() != "")
        {
            customerinfo += " ";
        }
        customerinfo += go.PayPostal + "\r\n";
        customerinfo += go.PayCountry + "\r\n";

        pdfFormFields.SetField("customer", customerinfo);

        bool    isPP       = false;
        bool    isBank     = false;
        int     rowcounter = 1;
        decimal total      = 0;
        string  invno      = "";
        //foreach (Entry entry in entries)
        //{
        string name = "Gala Order, Tables: " + go.TableCount.ToString() + " Seats: " + go.SeatCount.ToString();

        if (go.SeatCount == 0)
        {
            name = "Gala Order, Tables: " + go.TableCount.ToString();
        }
        else if (go.TableCount == 0)
        {
            name = "Gala Order, Seats: " + go.SeatCount.ToString();
        }
        PopulateFeeRow(rowcounter, pdfFormFields, name, go.Amount, 0, 1, false, "");
        rowcounter++;

        if (go.FeeShipping > 0)
        {
            PopulateFeeRow(rowcounter, pdfFormFields, "Shipping Fee", go.FeeShipping, 0, 1, false, "");
            rowcounter++;
        }

        invno = go.Invoice;

        pdfFormFields.SetField("date", go.DateCreated.ToString("dd MMM yyyy"));
        //}

        pdfFormFields.SetField("invno", invno);

        decimal fees = go.Fee;

        pdfFormFields.SetField("st2", "S$ " + fees.ToString("N"));

        total = go.Amount + go.FeeShipping + fees;
        pdfFormFields.SetField("st1", "S$ " + total.ToString("N"));


        decimal tax = go.Tax;

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

        decimal grandtotal = total;

        grandtotal += tax;
        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);
    }
示例#4
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ValidateForm())
        {
            Guid goId = new Guid(hldOrderId.Value);
            go = GalaOrder.GetGalaOrder(goId);

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

            go.DatePaidString = dpDateReceived.DateInput.SelectedDate.ToString();
            go.RemarksPayment = txtRemarks.Text;

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

            // make the change only if the status has changed.
            // if not do not change it
            if (chkPaid.Checked && paidstatus_org == StatusPaymentEntry.NotPaid)
            {
                go.PayStatus = StatusPaymentEntry.Paid;
                isPaid       = true;
            }
            if (!chkPaid.Checked && paidstatus_org == StatusPaymentEntry.Paid)
            {
                go.PayStatus = StatusPaymentEntry.NotPaid;
            }
            go.Save();
            //}


            //// send email?
            //if (chkSendPaidEmail.Checked)
            //{
            //    if (go.PaymentMethod == PaymentType.PayPal) // there shouldnt be any PP, its disabled on the list, it can never come here
            //        GeneralFunction.CompleteNewGalaOrderPayPal(go.Id);
            //    else
            //        GeneralFunction.CompleteNewGalaOrderOthers(go.Id);
            //}


            // Always send email if paid
            if (isPaid)
            {
                GeneralFunction.CompleteNewGalaOrderOthers(go.Id);
            }



            //// history
            //AmountReceived amt = AmountReceived.NewAmountReceived();
            //amt.Amount = decimal.Parse(txtAmountRecieved.Text);
            //amt.DateReceivedString = dpDateReceived.DateInput.SelectedDate.ToString();
            //amt.PaygroupId = entry.PayGroupId;
            //amt.Invoice = "";
            //amt.Remarks = txtRemarks.Text;
            //amt.IsSetPaid = isPaid;
            //amt.DateCreatedString = DateTime.Now.ToString();
            //amt.Save();



            if (Save_Clicked != null)
            {
                Save_Clicked(this, EventArgs.Empty);
            }
        }
    }
示例#5
0
    private void SaveForm()
    {
        if (go.IsNew)
        {
            go = GalaOrder.NewGalaOrder();
        }

        go.TableCount = 0;
        go.SeatCount  = 0;

        if (ddlTableCount.SelectedValue != "")
        {
            go.TableCount = int.Parse(ddlTableCount.SelectedValue);
        }
        if (ddlSingleCount.SelectedValue != "")
        {
            go.SeatCount = int.Parse(ddlSingleCount.SelectedValue);
        }
        go.Shipping = rblShipping.SelectedValue;

        go.PayFirstname = txtFirstname.Text.Trim();
        go.PayLastname  = txtLastname.Text.Trim();
        go.PayContact   = GeneralFunction.CreateContact(txtContactCountryCode.Text.Trim(), txtContactAreaCode.Text.Trim(), txtContactNumber.Text.Trim());
        go.PayEmail     = txtEmail.Text.Trim();

        go.PayCompany  = txtCompany.Text.Trim();
        go.PayAddress1 = txtAddress1.Text.Trim();
        go.PayAddress2 = txtAddress2.Text.Trim();
        go.PayCity     = txtCity.Text.Trim();
        go.PayPostal   = txtPostal.Text.Trim();
        go.PayCountry  = ddlCountry.SelectedValue;

        go.PaymentMethod = rblPayment.SelectedValue;


        // Calculation
        go.Amount = (go.TableCount * 4000) + (go.SeatCount * 450);
        go.Fee    = 0;
        if (go.Shipping == "courier")
        {
            go.FeeShipping = 15;
        }
        if (rblPayment.SelectedValue == PaymentType.BankTransfer)
        {
            go.Fee = GeneralFunction.CalculateBankTransferFees();
        }
        if (rblPayment.SelectedValue == PaymentType.PayPal)
        {
            go.Fee = GeneralFunction.CalculateCreditFees(go.Amount + go.FeeShipping);
        }

        // Gst
        go.Tax = 0;
        if (ddlCountry.SelectedValue.ToLower() == "singapore")
        {
            go.Tax = GeneralFunction.CalculateTax(go.Amount + go.Fee + go.FeeShipping);
        }


        // Misc
        go.Status            = StatusGalaOrder.Confirm; //StatusGalaOrder.Draft;
        go.PayStatus         = StatuspaymentGalaOrder.NotPaid;
        go.IsReminded        = 0;
        go.DateCreatedString = DateTime.Now.ToString();


        if (go.IsValid)
        {
            go = go.Save();
        }
        else
        {
            lbError.Text  = go.BrokenRulesCollection.ToString();
            lbError2.Text = go.BrokenRulesCollection.ToString();
        }
    }
示例#6
0
    protected void radGridEntry_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
        {
            GalaOrder go = (GalaOrder)e.Item.DataItem;

            LinkButton lnkBtn = null;
            Label      lbl    = null;
            HyperLink  lnk    = null;

            // Shippng
            lbl = (Label)e.Item.FindControl("lbShipping");
            if (go.Shipping == "collect_office")
            {
                lbl.Text = "Office";
            }
            if (go.Shipping == "collect_onsite")
            {
                lbl.Text = "Onsite";
            }
            if (go.Shipping == "courier")
            {
                lbl.Text = "Courier";
            }

            // Payment Method
            lbl      = (Label)e.Item.FindControl("lbPaymentMethod");
            lbl.Text = GeneralFunction.GetPaymentType(go.PaymentMethod);

            // Payment Status
            lbl      = (Label)e.Item.FindControl("lbPaymentStatus");
            lbl.Text = GeneralFunction.GetPaymentGalaStatus(go.PayStatus);
            if (go.PayStatus == StatuspaymentGalaOrder.Paid)
            {
                lbl.ForeColor = System.Drawing.Color.Green;
            }
            if (go.PayStatus == StatuspaymentGalaOrder.NotPaid)
            {
                lbl.ForeColor = System.Drawing.Color.Red;
            }

            // update payment
            lnkBtn = (LinkButton)e.Item.FindControl("lnkBtnUpdatePayment");
            lnkBtn.CommandArgument = go.Id.ToString();
            if (go.PaymentMethod == PaymentType.PayPal)
            {
                lnkBtn.Visible = false;                                         // dont show for PP
            }
            //// chkboxes
            //CheckBox chkbox = (CheckBox)e.Item.FindControl("chkbox");
            //Security.SecureControlByHiding(chkbox);

            counter++;
        }
        else if (e.Item.ItemType == GridItemType.Pager)
        {
            RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");

            PageSizeCombo.Items.Clear();
            PageSizeCombo.Items.Add(new RadComboBoxItem("50", "50"));
            PageSizeCombo.FindItemByText("50").Attributes.Add("ownerTableViewId", radGridEntry.MasterTableView.ClientID);
            PageSizeCombo.Items.Add(new RadComboBoxItem("100", "100"));
            PageSizeCombo.FindItemByText("100").Attributes.Add("ownerTableViewId", radGridEntry.MasterTableView.ClientID);
            PageSizeCombo.Items.Add(new RadComboBoxItem("200", "200"));
            PageSizeCombo.FindItemByText("200").Attributes.Add("ownerTableViewId", radGridEntry.MasterTableView.ClientID);
            PageSizeCombo.Items.Add(new RadComboBoxItem("All", "99999"));
            PageSizeCombo.FindItemByText("All").Attributes.Add("ownerTableViewId", radGridEntry.MasterTableView.ClientID);
            PageSizeCombo.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
        }
    }