protected void PrintPOButton_Clicked(object sender, EventArgs e)
 {
     string ponumber = PONumberTextbox.Text;
     CartDB db = new CartDB();
     if (db.CartUpdatePayment(CurrentCart.PaymentId, CurrentCart.CartId, PaymentType.PO, "", "", "", "", "", ponumber, "[FAX]", null))
     {
         UpdateOrderPOPayment(ponumber, "[FAX]", null,"");
         MoveToThankYou();
     }
 }
    protected void CreditCardButton_Clicked(object sender, EventArgs e)
    {
        ShowCreditCardDiv();

        if (Page.IsValid)
        {
        string cc = CreditCardNumberTextbox.Text;
        string cvv = CVVTextbox.Text;
        string exp = String.Format("{0}/{1}", MonthDropdown.SelectedValue, YearDropdown.SelectedValue);
        string last_four = cc.Substring(cc.Length - 4);
        string cctype = CreditCardTypeDropdown.SelectedValue;

        CartDB db = new CartDB();
        bool success = false;

        if (CurrentCart.PaymentId > 0)
        {
            success = db.CartUpdatePayment(CurrentCart.PaymentId, CurrentCart.CartId, PaymentType.CC, cctype, last_four, Encrypt(cc), Encrypt(exp), Encrypt(cvv), "", "", null);
        }
        else
        {
            success = db.CartAddPayment(CurrentCart.CartId, PaymentType.CC, cctype, last_four, Encrypt(cc), Encrypt(exp), Encrypt(cvv), "", "", null);
        }

        if (success)
        {
            CurrentCart.MoveNextStep();
            Response.Redirect(Constants.Pages.CHECKOUT);
        }

        }
        else
        {
        error = true;
        }
    }
    protected void PurchaseOrderButton_Clicked(object sender, EventArgs e)
    {
        CartDB db = new CartDB();

        bool success = false;
        if (CurrentCart.PaymentId > 0)
        {
            success = db.CartUpdatePayment(CurrentCart.PaymentId, CurrentCart.CartId, PaymentType.PO, "", "", "", "", "", "", "", null);
        }
        else
        {
            success = db.CartAddPayment(CurrentCart.CartId, PaymentType.PO, "", "", "", "", "", "", "", null);
        }

        if (success)
        {
            CurrentCart.MoveNextStep();
            Response.Redirect(Constants.Pages.CHECKOUT);
        }
    }
    protected void UploadPOButton_Clicked(object sender, EventArgs e)
    {
        string filename = "";
        string ponumber = PONumberTextbox.Text;
        string potype = "";

        byte[] content = DoUpload(out filename);

        if(filename.Contains(".jpg"))
        {
            potype = "jpg";
        }

                if(filename.Contains(".tiff"))
        {
            potype = "tiff";
        }
                if(filename.Contains(".pdf"))
        {
            potype = "pdf";
        }
                if(filename.Contains(".doc"))
        {
            potype = "doc";
        }
               if(filename.Contains(".docx"))
        {
            potype = "docx";
        }

        if (content != null)
        {
            CartDB db = new CartDB();
            if (db.CartUpdatePayment(CurrentCart.PaymentId, CurrentCart.CartId, PaymentType.PO, "", "", "", "", "", ponumber, filename, content))
            {
                //Response.Write(String.Format("SUCCESS UPLOADING FILE {0} OF {1} BYTES LENGTH", filename, content.Length));
                UpdateOrderPOPayment(ponumber, filename, content,potype);
                MoveToThankYou();
            }
        }
    }