HELP! Need code checked to ensure cut-off date/time is working for people ordering flowers online.

Feb 12 2010 6:30 PM
Hi,

I'm project managing a flowers website (just completed) based in Australia where customers can order flowers online and have them delivered. Tomorrow is their busiest day of the year with Valentine's Day. The flower company asked me to make sure that customers cannot place orders for delivery on Saturday from 12pm Friday (yesterday) and that customers cannot place orders for delivery on Sunday from 10am Saturday (today). But the customer service girl from the flowers company rang me this morning to say that she's already received 2 orders this morning to be delivered today. So obviously the developers didn't do what they were suppose to do, to my great annoyance.

I have posted below the code for the 'PaymentDetails.aspx.cs" page below. I'm not a developer, so when I look at the code I don't have any idea. If anybody can see where my developers have tried to implement this and failed? (I have removed sensitive information with "XXXXXXX".) If you can help, I would GREATLY appreciate it. Many thanks in advance.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using eWayPayment;
using System.Security.Cryptography;
using System.Xml;
using System.Text;
using System.IO;

using DataAccessLayer;

public partial class PaymentDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        txtCardNumber.Attributes.Add("autocomplete", "off");
        if (!IsPostBack)
        {
            LoadYear();
            if (Session["Member"] != null)
            {
                Customer objDummy = (Customer)Session["Member"];
                if (objDummy.MemberId != 0)
                {
                    Customer objCredit = CustomerTrans.GetCreditCardDetailsByMemberId(objDummy.MemberId);
                    if (objCredit.MemberId != 0)
                    {
                        txtCardNumber.Text = DecryptCreditcardNumber(objCredit.CreditCardNumber);
                        hdnCNum.Value = DecryptCreditcardNumber2(objCredit.CreditCardNumber);
                        txtHolderName.Text = objCredit.CardHolder;
                        try
                        {
                            ddlCardType.ClearSelection();
                            ddlCardType.Items.FindByText(objCredit.CreditType).Selected = true;
                        }
                        catch (Exception ex)
                        {
                        }

                        char[] ar ={ '/' };
                        string[] expdate = objCredit.ExpiryDate.Split(ar);
                        if (expdate.Length == 2)
                        {
                            try
                            {
                                ddlExpmonth.ClearSelection();
                                ddlExpmonth.Items.FindByText(expdate[0].Trim()).Selected = true;
                            }
                            catch (Exception ex)
                            {
                            }

                            try
                            {
                                ddlExpYear.ClearSelection();
                                ddlExpYear.Items.FindByText(expdate[1].Trim()).Selected = true;
                            }
                            catch (Exception ex)
                            {
                            }

                        }


                    }
                }
            }

        }
        if (Session["MyBasket"] != null)
        {
            DataTable dtBasket = (DataTable)Session["MyBasket"];
            if (dtBasket != null && dtBasket.Rows.Count > 0)
            {



                if (Session["OrderInfo"] == null)
                {

                    Response.Redirect("DeliveryDetails.aspx");
                }
                else
                {

                    ltrDelTot.Text = "$ " + dtBasket.Compute("sum(ProductSum)", "").ToString();
                    ltrDel.Text = dtBasket.Rows[0]["DeliveryRate"].ToString(); ;
                    //decimal gst = Convert.ToDecimal(Math.Round ( Convert.ToDecimal(dtBasket.Compute("sum(ProductSum)", "").ToString()) * Convert.ToDecimal(0.11),2));
                    decimal gst = Convert.ToDecimal("0.00");
                    ltrGst.Text = gst.ToString();
                    ltrOrder.Text = Convert.ToString(Convert.ToDecimal(dtBasket.Compute("sum(ProductSum)", "").ToString()) + Convert.ToDecimal("15.00")+gst);


                    if (Session["Member"] != null)
                    {
                        tblTotal.Visible = true;
                        // ltrTotal.Text = "$ " + dtBasket.Compute("sum(ProductSum)", "").ToString();
                        object[] objInfo = (object[])Session["OrderInfo"];
                        DataTable dtInfo = (DataTable)objInfo[1];
                        if (dtInfo != null)
                        {
                            ltrRecCount.Text = dtInfo.Rows.Count.ToString();
                            ltrRecTotal.Text = Convert.ToString(Convert.ToInt32(dtInfo.Rows.Count.ToString()) * Convert.ToDecimal(Convert.ToString(Convert.ToDecimal(dtBasket.Compute("sum(ProductSum)", "").ToString()) + Convert.ToDecimal("15.00")+gst)));
                            ltrTotal.Text = "$ " + Convert.ToString(Convert.ToInt32(dtInfo.Rows.Count.ToString()) * Convert.ToDecimal(Convert.ToString(Convert.ToDecimal(dtBasket.Compute("sum(ProductSum)", "").ToString()) + Convert.ToDecimal("15.00")+gst)));
                        }
                        


                    }
                    else
                    {
                        tblTotal.Visible = false;
                        ltrTotal.Text = "$ " + Convert.ToString (Convert.ToDecimal(dtBasket.Compute("sum(ProductSum)", "").ToString())+ Convert.ToDecimal("15.00")+gst);
                    }
                }




            }
            else
            {
                Response.Redirect("ViewBasket.aspx");
            }
        }
        else
            Response.Redirect("ViewBasket.aspx");
        this.Page.Title = "Payment Details - XXXXXXX";
    }

    private string DecryptCreditcardNumber(string number)
    {
        if (number != "")
        {
            RijndaelManaged RijndaelCipher = new RijndaelManaged();

            string Password = "CSC";
            string DecryptedData;

            try
            {
                byte[] EncryptedData = Convert.FromBase64String(number);
                byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString());
                //Making of the key for decryption
                PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, Salt);
                //Creates a symmetric Rijndael decryptor object.
                ICryptoTransform Decryptor = XXXXXXX(SecretKey.GetBytes(32), SecretKey.GetBytes(16));

                MemoryStream memoryStream = new MemoryStream(EncryptedData);
                //Defines the cryptographics stream for decryption.THe stream contains decrpted data
                CryptoStream cryptoStream = new CryptoStream(memoryStream, Decryptor, CryptoStreamMode.Read);

                byte[] PlainText = new byte[EncryptedData.Length];
                int DecryptedCount = cryptoStream.Read(PlainText, 0, PlainText.Length);
                memoryStream.Close();
                cryptoStream.Close();

                //Converting to string
                DecryptedData = Encoding.Unicode.GetString(PlainText, 0, DecryptedCount);

                string cardNumber = DecryptedData;
                string firstfour = cardNumber.Substring(0, 4).Trim();
                string middleEight = cardNumber.Substring(4, 8).Trim();
                string lastFour = cardNumber.Substring(12, 4);


                DecryptedData = firstfour + "XXXXXXXX" + lastFour;
                // return dcryptNumber;

            }
            catch
            {
                DecryptedData = "";
            }
            return DecryptedData;
        }
        else
            return "";
    }


    private string DecryptCreditcardNumber2(string number)
    {
        if (number != "")
        {
            XXXXXXX

            string Password = "XXXXXXX";
            string DecryptedData;

            try
            {
                byte[] EncryptedData = Convert.FromBase64String(number);
                byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString());
                //Making of the key for decryption
                PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, XXXXXXX);
                //Creates a symmetric Rijndael decryptor object.
                ICryptoTransform Decryptor = XXXXXXX, SecretKey.GetBytes(16));

                MemoryStream memoryStream = new MemoryStream(EncryptedData);
                //Defines the cryptographics stream for decryption.THe stream contains decrpted data
                CryptoStream cryptoStream = new CryptoStream(memoryStream, Decryptor, CryptoStreamMode.Read);

                byte[] PlainText = new byte[EncryptedData.Length];
                int DecryptedCount = cryptoStream.Read(PlainText, 0, PlainText.Length);
                memoryStream.Close();
                cryptoStream.Close();

                //Converting to string
                DecryptedData = Encoding.Unicode.GetString(PlainText, 0, DecryptedCount);

            

            }
            catch
            {
                DecryptedData = "";
            }
            return DecryptedData;
        }
        else
            return "";
    }




    private void LoadYear()
    {
        ddlExpYear.Items.Clear();
        int year = DateTime.Today.Year + 6;
        for (int stYear = DateTime.Today.Year; stYear <= year; stYear++)
        {
            ddlExpYear.Items.Add(new ListItem(stYear.ToString(), stYear.ToString()));
        }
        ddlExpYear.Items.Insert(0, new ListItem("Expiry Year", "0"));
    }

    protected void btnOrder_Click(object sender, EventArgs e)
    {
        lblMsg.Visible = false;
        if (Common.Comparedate(Convert.ToDateTime(DateTime.Today.Month + "/" + DateTime.Today.Year), Convert.ToDateTime(ddlExpmonth.SelectedValue + "/" + ddlExpYear.SelectedValue)))
        {

            if (Session["OrderInfo"] != null)
            {
                object[] objInfo = (object[])Session["OrderInfo"];
                OPS objOPS = (OPS)objInfo[2];
                if (PayMentProcess(objOPS.DeliveryTypeId, objInfo[0]))
                {

                    OrderProcessing();

                }
                else
                {
                    txtCardNumber.Text = "";
                    txtHolderName.Text = "";
                    ddlCardType.SelectedIndex = 0;
                    ddlExpmonth.SelectedIndex = 0;
                    ddlExpYear.SelectedIndex = 0;
                }
            }
            else
                Response.Redirect("Index.aspx");
    }
    else
    {
        lblMsg.Visible = true;
        lblMsg.Text = "*Expiry date is already past.";
    }
    }

    private bool PayMentProcess(int delTypeId,object objCust)
    {

        lblMsg.Visible = true;
        if (delTypeId == 1)
        {
            GatewayConnector XXXXXXX = new GatewayConnector();
            GatewayRequest XXXXXXX = new GatewayRequest();
            try
            {
                //XXXXXXXRequest.XXXXXXXCustomerID = "XXXXXXX";
                XXXXXXXRequest.XXXXXXXCustomerID = "XXXXXXX";
                //get values input by user on form, or set to database values
                //XXXXXXXgateway.Uri = "https://www.XXXXXXX";
                XXXXXXXgateway.Uri = "https://www.XXXXXXX";
                XXXXXXXRequest.CardNumber = txtCardNumber.Text.Trim();
                XXXXXXXRequest.CardExpiryMonth = ddlExpmonth.SelectedValue;
                XXXXXXXRequest.CardExpiryYear = ddlExpYear.SelectedValue;
                XXXXXXXRequest.CardHolderName = txtHolderName.Text.Trim();
                string val = ltrTotal.Text.Trim().Remove(0, 1).Trim();
                //string val = "10";
                decimal dcVal = Convert.ToDecimal(val)*100;
                XXXXXXXRequest.InvoiceAmount = Convert.ToInt32(dcVal); //int
                

                // Do the payment, send XML doc containing information gathered
                if (XXXXXXXgateway.ProcessRequest(XXXXXXXRequest))
                {
                    // payment succesfully sent to gateway
                    GatewayResponse XXXXXXXResponse = XXXXXXXgateway.Response;
                    if (XXXXXXXResponse != null)
                    {
                        lblMsg.Text = "";
                        lblMsg.Text += "<b>Sorry, unfortunately your transaction FAILED!</b><br/><br/>";
                        lblMsg.Text += " XXXXXXXTrxnStatus: " + XXXXXXXResponse.Status + "<br/>";
                        lblMsg.Text += " XXXXXXXAuthCode: " + XXXXXXXResponse.AuthorisationCode + "<br/>";
                        lblMsg.Text += " XXXXXXXTrxnError: " + XXXXXXXResponse.Error + "<br/>";
                        lblMsg.Text += " XXXXXXXInvoiceRef: " + XXXXXXXResponse.TransactionNumber + "<br/>";
                        lblMsg.Text += " XXXXXXXReturnAmount: " + XXXXXXXResponse.Amount + "<br/>";
                        lblMsg.Text += " XXXXXXXTrxnNumber: " + XXXXXXXResponse.InvoiceReference + "<br/>";
                        lblMsg.Text += "<p style='color:Black;'><br/><br/>If you have entered an invalid card number please try again! Or contact our friendly customer service on XXXXXXX - Monday to Friday 8:00am to 4:00pm (AEST).</p>";
                        bool status= XXXXXXXResponse.Status;
                        if (status == false)
                        {
                            if (Session["Member"] != null)
                            {
                                Customer objDummy = (Customer)Session["Member"];
                                if (objDummy.MemberId != 0)
                                {
                                    Customer objCredit = CustomerTrans.GetCreditCardDetailsByMemberId(objDummy.MemberId);
                                    XXXXXXXRequest.CardNumber = DecryptCreditcardNumber2(objCredit.CreditCardNumber);
                                    hdnCNum.Value = XXXXXXXRequest.CardNumber;

                                    if (XXXXXXXgateway.ProcessRequest(XXXXXXXRequest))
                                    {
                                        GatewayResponse XXXXXXXResponse2 = XXXXXXXgateway.Response;
                                        if (XXXXXXXResponse2 != null)
                                        {
                                            lblMsg.Text = "";
                                            lblMsg.Text += "<b>Sorry, unfortunately your transaction FAILED!</b><br/><br/>";
                                            lblMsg.Text += " XXXXXXXTrxnStatus: " + XXXXXXXResponse2.Status + "<br/>";
                                            lblMsg.Text += " XXXXXXXAuthCode: " + XXXXXXXResponse2.AuthorisationCode + "<br/>";
                                            lblMsg.Text += " XXXXXXXTrxnError: " + XXXXXXXResponse2.Error + "<br/>";
                                            lblMsg.Text += " XXXXXXXInvoiceRef: " + XXXXXXXResponse2.TransactionNumber + "<br/>";
                                            lblMsg.Text += " XXXXXXXReturnAmount: " + XXXXXXXResponse2.Amount + "<br/>";
                                            lblMsg.Text += " XXXXXXXTrxnNumber: " + XXXXXXXResponse2.InvoiceReference + "<br/>";
                                            lblMsg.Text += "<p style='color:Black;'><br/><br/>If you have entered an invalid card number please try again! Or contact our friendly customer service on XXXXXXX - Monday to Friday 8:00am to 4:00pm (AEST).</p>";
                                            status = XXXXXXXResponse2.Status;
                                        }
                                    }
                                }

                            }
                        }
                        else
                        {
                            hdnCNum.Value = txtCardNumber.Text.Trim();
                        }
                        return status;


                        //return true;
                    }
                    else
                    {
                        lblMsg.Text = "Error: An invalid response was recieved from the payment gateway.";
                        return false;
                    }
                }
                else
                {
                    lblMsg.Text = "Error: Connection to the payment gateway failed. Check gateway URL or XML sent." + Server.UrlEncode(XXXXXXXRequest.ToXml().ToString());
                    return false;
                }


            }
            catch (Exception ex)
            {
                string strErrorMessage = "<!-- " + ex.Source + "\r\n" +
                    ex.Message + "\r\n" +
                    ex.StackTrace + "\r\n-->";

                //exception occured 
                lblMsg.Text = strErrorMessage;
                return false;
            }
        }
        else
        {
            try
            {
                if (Session["schDel"] != null)
                {
                    Customer objCustomer = (Customer)objCust;
                    OPS objSCH = (OPS)Session["schDel"];

                    if (txtCardNumber.Text.Trim() != "")
                    {
                        if (txtCardNumber.Text.Trim().Contains("XXXXXXXX"))
                        {
                            if (Session["Member"] != null)
                            {
                                Customer objDummy = (Customer)Session["Member"];
                                if (objDummy.MemberId != 0)
                                {
                                    Customer objCredit = CustomerTrans.GetCreditCardDetailsByMemberId(objDummy.MemberId);
                                    hdnCNum.Value = DecryptCreditcardNumber2(objCredit.CreditCardNumber);
                                    return true;
                                }
                                else
                                    return false;
                            }
                            else
                                return false;
                        }
                        else
                        {
                            hdnCNum.Value = txtCardNumber.Text.Trim();
                            return true;
                        }
                    }
                    else
                        return false;

                }
                else
                    return false;


            }
            catch (Exception ex3)
            {
                lblMsg.Visible = true;
                lblMsg.Text = ex3.Message;
                return false;
            }

            return false;
        }
    }


    private string GetIntervalType(int type)
    {
        if (type == 2)
            return "1";
        else if (type == 3)
            return "2";
        else if (type == 4)
            return "3";
        else if (type == 5)
            return "4";
        else
            return "1";
    }

   private  int SaveRecipientAddress(int recId)
   {
       Recipient objRecipient = RecipientTrans.GetRecipientById(recId);
       if (objRecipient != null)
       {
           RecipientAddress objRecAdd = new RecipientAddress();
           objRecAdd.Company = objRecipient.Company;
           objRecAdd.Country = objRecipient.Country;
           objRecAdd.EmailAddress = objRecipient.EmailAddress;
           objRecAdd.FaxCode = objRecipient.FaxCode;
           objRecAdd.FaxNumber = objRecipient.FaxNumber;
           objRecAdd.HomePhoneCode = objRecipient.HomePhoneCode;
           objRecAdd.HomePhoneNumber = objRecipient.HomePhoneNumber;
           objRecAdd.HospialName = objRecipient.HospialName;
           objRecAdd.IsOverSeas = objRecipient.IsOverSeas;
           objRecAdd.Mobilenumber = objRecipient.Mobilenumber;
           objRecAdd.OverSeasCountry = objRecipient.OverSeasCountry;
           objRecAdd.OverSeasPostCode = objRecipient.OverSeasPostCode;
           objRecAdd.OverSeasState = objRecipient.OverSeasState;
           objRecAdd.OverSeasTown = objRecipient.OverSeasTown;
           objRecAdd.PostCode = objRecipient.PostCode;
           objRecAdd.RecAddId = 0;
           objRecAdd.RecipientAddress1 = objRecipient.RecipientAddress;
           objRecAdd.RecipientId = recId;
           objRecAdd.StateId = objRecipient.StateId;
           objRecAdd.SuburbId = objRecipient.SuburbId;
           objRecAdd.WorkCode = objRecipient.WorkCode;
           objRecAdd.WorkNumber = objRecipient.WorkNumber;
           return RecipientTrans.InsertOrUpdateRecipientAddress(objRecAdd);
       }
       else
           return 0;
   }

    private int SaveRecipientOrder(Recipient objRecipient, int recId)
    {
        RecipientAddress objRecAdd = new RecipientAddress();
        objRecAdd.Company = objRecipient.Company;
        objRecAdd.Country = objRecipient.Country;
        objRecAdd.EmailAddress = objRecipient.EmailAddress;
        objRecAdd.FaxCode = objRecipient.FaxCode;
        objRecAdd.FaxNumber = objRecipient.FaxNumber;
        objRecAdd.HomePhoneCode = objRecipient.HomePhoneCode;
        objRecAdd.HomePhoneNumber = objRecipient.HomePhoneNumber;
        objRecAdd.HospialName = objRecipient.HospialName;
        objRecAdd.IsOverSeas = objRecipient.IsOverSeas;
        objRecAdd.Mobilenumber = objRecipient.Mobilenumber;
        objRecAdd.OverSeasCountry = objRecipient.OverSeasCountry;
        objRecAdd.OverSeasPostCode = objRecipient.OverSeasPostCode;
        objRecAdd.OverSeasState = objRecipient.OverSeasState;
        objRecAdd.OverSeasTown = objRecipient.OverSeasTown;
        objRecAdd.PostCode = objRecipient.PostCode;
        objRecAdd.RecAddId = 0;
        objRecAdd.RecipientAddress1 = objRecipient.RecipientAddress;
        objRecAdd.RecipientId = recId;
        objRecAdd.StateId = objRecipient.StateId;
        objRecAdd.SuburbId = objRecipient.SuburbId;
        objRecAdd.WorkCode = objRecipient.WorkCode;
        objRecAdd.WorkNumber = objRecipient.WorkNumber;
        return RecipientTrans.InsertOrUpdateRecipientAddress(objRecAdd);
    }



    private void  OrderProcessing()
    {
        if (Session["OrderInfo"] != null)
        {
            object[] objInfo = (object[])Session["OrderInfo"];
            if (objInfo.Length == 3)
            {
                Customer objCustomer =(Customer) objInfo[0];
                Recipient objRecipient =null;
                DataTable dtRecipients = null;
                OPS objOPS = (OPS)objInfo[2];
                
                
                if (objCustomer.MemberId != 0 && Session["Member"] != null)
                {
                    dtRecipients = (DataTable)objInfo[1];
                    ArrayList objOrList = new ArrayList();
                    foreach (DataRow drRec in dtRecipients.Rows)
                    {
                        objOPS.OrderId = 0;
                        objOPS.MemberId = objCustomer.MemberId;
                        objOPS.RecipientId =Convert.ToInt32 (drRec["RecipientId"].ToString ());
                        objOPS.RecipientAddressId = SaveRecipientAddress(Convert.ToInt32(drRec["RecipientId"].ToString()));

                        objOPS.DeliveryRecurrence = 1;
                        objOPS.OrderStatusId = 1;
                        objOPS.OrderStatusDescription = "";

                        objOPS.Recurrence = 1;
                        //objOPS.IsPaid = 1;
                        /*
                        if (objOPS.PaymentType == 1 || objOPS.PaymentType == 0)
                        {*/
                            if (objOPS.DeliveryTypeId != 1)
                            {
                                if (objOPS.IsPaid != 1)
                                {
                                    objOPS.IsPaid = 0;
                                }
                            }
                            else
                            {
                                objOPS.IsPaid = 1;
                            }
                        /*}
                        else
                            objOPS.IsPaid = 1;
                            */

                      

                        int orderId = OPSTrans.InsertOrderProcess(objOPS);
                       
                        if (orderId > 0)
                        {

                           if (objOPS.DeliveryTypeId != 1)
                           {
                               if (Session["objArList"] != null)
                               {
                                   ArrayList objArList = (ArrayList)Session["objArList"];
                                   if (objArList.Count > 0)
                                   {
                                      int reBillId= CustomerTrans.InsertRebillCustomers(orderId, objArList[0].ToString(), Convert.ToDecimal(objArList[1].ToString ()));
                                   }
                                   Session["objArList"] = null;
                               }
                               

                           }
                           GetOrderDeldate(objOPS, orderId);


                            DataTable dtBasket = (DataTable)Session["MyBasket"];
                            if (dtBasket != null)
                            {
                                foreach (DataRow dr in dtBasket.Rows)
                                {
                                    objOPS.OrderId = orderId;
                                    objOPS.ProductId = Convert.ToInt32(dr["ProductId"].ToString());
                                    objOPS.Quantity = Convert.ToInt32(dr["Quantity"].ToString());
                                    objOPS.UnitPrice = Convert.ToDecimal(dr["FFPrice"].ToString().Trim().Remove(0, 1).Trim());
                                    objOPS.IsAddOnProduct = dr["ProductType"].ToString().Trim() == "P" ? 1 : 2;
                                    objOPS.PromotionId = 0;
                                    objOPS.ProductSize = dr["ProductSize"].ToString().Trim();
                                    //objOPS.ProductColor = "";
                                    objOPS.ProductColor = dr["ProductColor"].ToString().Trim();
                                    OPSTrans.InsertOrderProductDetails(objOPS);
                                    

                                }
                                objOrList.Add(orderId);
                            }
                        }
                        Session["Orderids"] = objOrList;
                    }

                    objCustomer.CardHolder = txtHolderName.Text.Trim();
                    objCustomer.CreditCardId = 0;
                    //objCustomer.CreditCardNumber =EncryptCreditCardNumber(txtCardNumber.Text.Trim());
                    objCustomer.CreditCardNumber = EncryptCreditCardNumber(hdnCNum.Value);
                    objCustomer.CreditType = ddlCardType.SelectedItem.Text;
                    objCustomer.ExpiryDate = ddlExpmonth.SelectedItem.Text + "/" + ddlExpYear.SelectedItem.Text;

                   int creditCard= CustomerTrans.InsertOrUpdateCreditCardDetails(objCustomer);
                   SendTaxInvoice(objInfo);

                    Session["MyBasket"] = null;
                    Session["OrderInfo"] = null;
                    Session["schDel"] = null;
                    
                    Response.Redirect("Message.aspx?msgId=1&scId=y");
                }
                else
                {
                    objRecipient = (Recipient)objInfo[1];
                
                
                
                int custId= CustomerTrans.InsertOrUpdateMemberDetails(objCustomer);
                if (custId > 0)
                {
                   objRecipient.MemberId = custId;
                   int recepId=RecipientTrans.SaveOrUpdateRecipientDetails(objRecipient);
                   int recAddId = SaveRecipientOrder(objRecipient, recepId);
                   if (recepId > 0)
                   {
                       objOPS.MemberId = custId;
                       objOPS.RecipientId = recepId;
                       objOPS.RecipientAddressId = recAddId;

                       objOPS .DeliveryRecurrence =1;
                       objOPS .OrderStatusId =1;
                       objOPS .OrderStatusDescription ="";

                       objOPS .Recurrence =1;
                       objOPS .IsPaid =1;

                       int orderId=OPSTrans.InsertOrderProcess(objOPS);
                       if (orderId > 0)
                       {

                           GetOrderDeldate(objOPS, orderId);


                           DataTable dtBasket = (DataTable)Session["MyBasket"];
                           if (dtBasket != null)
                           {
                               foreach (DataRow dr in dtBasket.Rows)
                               {
                                   objOPS.OrderId = orderId;
                                   objOPS.ProductId = Convert.ToInt32(dr["ProductId"].ToString ());
                                   objOPS.Quantity = Convert.ToInt32(dr["Quantity"].ToString ());
                                   objOPS.UnitPrice = Convert.ToDecimal(dr["FFPrice"].ToString().Trim().Remove(0,1).Trim ());
                                   objOPS.IsAddOnProduct = dr["ProductType"].ToString().Trim() == "P" ? 1 : 2;
                                   objOPS.ProductSize = dr["ProductSize"].ToString().Trim();
                                   objOPS.PromotionId = 0;
                                  // objOPS.ProductColor = "";
                                   objOPS.ProductColor = dr["ProductColor"].ToString().Trim();
                                   OPSTrans.InsertOrderProductDetails(objOPS);

                               }
                           }

                           objCustomer.MemberId = custId;
                           objCustomer.CardHolder = txtHolderName.Text.Trim();
                           objCustomer.CreditCardId = 0;
                           //objCustomer.CreditCardNumber = txtCardNumber.Text.Trim();
                           //objCustomer.CreditCardNumber = EncryptCreditCard(txtCardNumber.Text.Trim());
                           //objCustomer.CreditCardNumber = EncryptCreditCardNumber(txtCardNumber.Text.Trim());
                           objCustomer.CreditCardNumber = EncryptCreditCardNumber(hdnCNum.Value);
                           objCustomer.CreditType = ddlCardType.SelectedItem.Text;
                           objCustomer.ExpiryDate = ddlExpmonth.SelectedItem.Text + "/" + ddlExpYear.SelectedItem.Text;

                           int creditCard = CustomerTrans.InsertOrUpdateCreditCardDetails(objCustomer);
                           SendTaxInvoice(objInfo);

                           Session["MyBasket"] = null;
                           Session["OrderInfo"] = null;
                           Response.Redirect("Message.aspx?msgId=1&OId="+objOPS.OrderId.ToString ());
                       }
 
                   }
               }

           }



                
            }


        }
    }



    private void GetOrderDeldate(OPS objOps, int ordId)
    {
        OPS objOrDels = new OPS();
        objOrDels.OrderDeliveryId = 0;
        objOrDels.OrderId = ordId;
        int repeat = 0;

        if (objOps.DeliveryTypeId != 1)
        {
            int rec = 0;
            DateTime dtOrDate = objOps.DeliveryStartDate;
            int rngId = 0;
            if (objOps.RangeTypeId == 0)
            {
                rngId = 20;
            }
            else
            {
                rngId = objOps.EndAfter;
                if (rngId == 0)
                {
                    /* if (dtOrDate < objOps.EndBy)
                     {
                         if (objOps.DeliveryTypeId == 4)
                         {
                             rngId = monthDifference(dtOrDate, objOps.EndBy);
                         }
                         else if (objOps.DeliveryTypeId == 5)
                         {
                             rngId = objOps.EndBy.Year - dtOrDate.Year;
                         }
                     }*/
                    rngId = 1;
                }



            }

            while (rec < rngId)
            {
                if (objOps.DeliveryTypeId == 2)
                {
                    if (objOps.PatternNumber == 0)
                    {
                        /*if (rec == 0)
                        {*/
                        objOrDels.OrderDeliveryDate = dtOrDate;
                        /* }
                         else
                         {
                            // objOrDels.OrderDeliveryDate = dtOrDate.AddDays(Convert.ToDouble(objOps.IntervalType));
                         }*/
                    }
                    else
                    {
                        /*if (rec == 0)
                        {*/
                        objOrDels.OrderDeliveryDate = dtOrDate;
                        /* }
                         else
                         {
                             //objOrDels.OrderDeliveryDate = dtOrDate.AddDays(Convert.ToDouble(objOps.IntervalType));
                         }*/
                    }
                    //objOrDels.OrderDeliveryDate = dtDeldate;
                    objOrDels.OrderDeliveryRecurrence = (rec + 1);
                    OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels);
                    rec++;
                    repeat = 1;
                    dtOrDate = dtOrDate.AddDays(Convert.ToDouble(objOps.IntervalType));
                    if (objOps.EndAfter == 0)
                    {
                        if (dtOrDate < objOps.EndBy)
                        {
                            rngId++;
                        }
                        else
                        {
                            rec = rngId;
                        }
                    }
                }


                if (objOps.DeliveryTypeId == 3)
                {
                    int days = (Convert.ToInt32(objOps.IntervalType) * 7);
                    DateTime dtRunDate = dtOrDate;
                    DateTime dtBeginningOfWeek = dtRunDate.AddDays(-1 * Convert.ToInt16(dtRunDate.DayOfWeek));
                    DateTime dtEndOfWeek = dtBeginningOfWeek.AddDays(Convert.ToDouble("6"));

                    string weeks = objOps.Pattern1.Replace("Recur every " + objOps.IntervalType.ToString().Trim() + " week(s) on: ", "").Trim();
                    char[] Splitter ={ ',' };
                    string[] splitWeek = weeks.Split(Splitter);

                    if (splitWeek.Length != 0)
                    {
                        int wDay = 1;
                        while (wDay < 7)
                        {

                            DateTime dtDeldate = dtBeginningOfWeek.AddDays(Convert.ToDouble(wDay.ToString()));
                            for (int i = 0; i < splitWeek.Length; i++)
                            {


                                if (dtDeldate < dtRunDate && repeat == 0)
                                {
                                }
                                else
                                {


                                    if (splitWeek[i].Trim().ToLower() == "monday")
                                    {
                                        if (dtDeldate.DayOfWeek == DayOfWeek.Monday)
                                        {
                                            objOrDels.OrderDeliveryDate = dtDeldate;
                                            objOrDels.OrderDeliveryRecurrence = (rec + 1);
                                            OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels);
                                            rec++;
                                            dtOrDate = dtDeldate;
                                            repeat = 1;
                                        }
                                    }
                                    if (splitWeek[i].Trim().ToLower() == "tuesday")
                                    {
                                        if (dtDeldate.DayOfWeek == DayOfWeek.Tuesday)
                                        {
                                            objOrDels.OrderDeliveryDate = dtDeldate;
                                            objOrDels.OrderDeliveryRecurrence = (rec + 1);
                                            OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels);
                                            rec++;
                                            dtOrDate = dtDeldate;
                                            repeat = 1;
                                        }
                                    }
                                    if (splitWeek[i].Trim().ToLower() == "wednesday")
                                    {
                                        if (dtDeldate.DayOfWeek == DayOfWeek.Wednesday)
                                        {
                                            objOrDels.OrderDeliveryDate = dtDeldate;
                                            objOrDels.OrderDeliveryRecurrence = (rec + 1);
                                            OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels);
                                            rec++;
                                            dtOrDate = dtDeldate;
                                            repeat = 1;
                                        }
                                    }
                                    if (splitWeek[i].Trim().ToLower() == "thursday")
                                    {
                                        if (dtDeldate.DayOfWeek == DayOfWeek.Thursday)
                                        {
                                            objOrDels.OrderDeliveryDate = dtDeldate;
                                            objOrDels.OrderDeliveryRecurrence = (rec + 1);
                                            OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels);
                                            rec++;
                                            dtOrDate = dtDeldate;
                                            repeat = 1;
                                        }
                                    }
                                    if (splitWeek[i].Trim().ToLower() == "friday")
                                    {
                                        if (dtDeldate.DayOfWeek == DayOfWeek.Friday)
                                        {
                                            objOrDels.OrderDeliveryDate = dtDeldate;
                                            objOrDels.OrderDeliveryRecurrence = (rec + 1);
                                            OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels);
                                            rec++;
                                            dtOrDate = dtDeldate;
                                            repeat = 1;
                                        }
                                    }
                                }

                                if (objOps.EndAfter == 0)
                                {
                                    if (dtDeldate < objOps.EndBy)
                                    {
                                        rngId++;
                                    }
                                    else
                                    {
                                        rec = rngId;
                                    }
                                }


                                if (rec >= rngId)
                                    break;

                            }
                            wDay++;

                            if (objOps.EndAfter == 0)
                            {
                                if (dtDeldate < objOps.EndBy)
                                {
                                    rngId++;
                                }
                                else
                                {
                                    rec = rngId;
                                }
                            }


                            if (rec >= rngId)
                                break;
                        }
                        dtOrDate = dtOrDate.AddDays(Convert.ToDouble(days.ToString()));

                        if (objOps.EndAfter == 0)
                        {
                            if (dtOrDate < objOps.EndBy)
                            {
                                rngId++;
                            }
                            else
                            {
                                rec = rngId;
                            }
                        }




                    }

                }

                if (objOps.DeliveryTypeId == 4)
                {
                    if (objOps.Pattern1 != "" && objOps.Pattern2 == "")
                    {
                        string day = objOps.Pattern1.Substring(0, objOps.Pattern1.LastIndexOf("of every")).Trim();
                        DateTime delDates = Convert.ToDateTime(dtOrDate.Month.ToString() + "/" + day + "/" + dtOrDate.Year.ToString());
                        while (rec < rngId)
                        {
                            if (delDates < dtOrDate && repeat == 0)
                            {
                                //delDates = Convert.ToDateTime(delDates).AddMonths(Convert.ToInt32(objOps.IntervalType));
                                delDates = Convert.ToDateTime(delDates).AddMonths(Convert.ToInt32("1"));
                            }
                            else
                            {
                                objOrDels.OrderDeliveryDate = delDates;
                                objOrDels.OrderDeliveryRecurrence = (rec + 1);
                                OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels);
                                rec++;
                                delDates = Convert.ToDateTime(delDates).AddMonths(Convert.ToInt32(objOps.IntervalType));
                                dtOrDate = delDates;
                                repeat = 1;

                                if (objOps.EndAfter == 0)
                                {
                                    if (dtOrDate < objOps.EndBy)
                                    {
                                        rngId++;
                                    }
                                    else
                                    {
                                        rec = rngId;
                                    }
                                }

                            }
                        }

                    }
                  {
string valTest = objOps.Pattern2.Replace(" of every ", " ").Replace("month(s)", ""); char[] Splitter ={ ' ' }; string[] vals = valTest.Trim().Split(Splitter); if (vals.Length == 3) { DateTime delDates = dtOrDate; //Common.GetSpecificDate(dtOrDate.Year, dtOrDate.Month, Common.WeekIndex.Second, DayOfWeek.Monday); if (vals[1].Trim() != "Day") { delDates = Common.GetSpecificDate(dtOrDate.Year, dtOrDate.Month, Convert.ToInt32(vals[0].Trim()), vals[1].Trim().ToLower()); } else delDates = Convert.ToDateTime(dtOrDate.Month + "/" + "1" + "/" + dtOrDate.Year); while (rec < rngId) { if (delDates < dtOrDate && repeat == 0) { //delDates = delDates.AddMonths(Convert.ToInt32(vals[2].ToString ())); delDates = delDates.AddMonths(Convert.ToInt32("1")); if (vals[1].Trim() != "Day") { delDates = Common.GetSpecificDate(delDates.Year, delDates.Month, Convert.ToInt32(vals[0].Trim()), vals[1].Trim().ToLower()); } } else { objOrDels.OrderDeliveryDate = delDates; objOrDels.OrderDeliveryRecurrence = (rec + 1); OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels); rec++; delDates = Convert.ToDateTime(delDates).AddMonths(Convert.ToInt32(vals[2].ToString())); if (vals[1].Trim() != "Day") { delDates = Common.GetSpecificDate(delDates.Year, delDates.Month, Convert.ToInt32(vals[0].Trim()), vals[1].Trim().ToLower()); } dtOrDate = delDates; repeat = 1; if (objOps.EndAfter == 0) { if (dtOrDate < objOps.EndBy) { rngId++; } else { rec = rngId; } } } } } } } if (objOps.DeliveryTypeId == 5) { if (objOps.Pattern1 != "" && objOps.Pattern2 == "") { char[] Splitter ={ ' ' }; string[] vals = objOps.Pattern1.Replace("Every ", "").Trim().Split(Splitter); if (vals.Length == 2) { int month = Convert.ToInt32(vals[0].Trim()); int dayYear = Convert.ToInt32(vals[1].Trim()); DateTime delDates = Convert.ToDateTime(month.ToString() + "/" + dayYear.ToString() + "/" + dtOrDate.Year.ToString()); while (rec < rngId) { if (delDates < dtOrDate && repeat == 0) { delDates = delDates.AddYears(1); } else { objOrDels.OrderDeliveryDate = delDates; objOrDels.OrderDeliveryRecurrence = (rec + 1); OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels); rec++; delDates = Convert.ToDateTime(delDates).AddYears(1); dtOrDate = delDates; repeat = 1; } if (objOps.EndAfter == 0) { if (dtOrDate < objOps.EndBy) { rngId++; } else { rec = rngId; } } } } } else if (objOps.Pattern1 == "" && objOps.Pattern2 != "") { char[] Splitter ={ ' ' }; string[] vals = objOps.Pattern2.Replace(" of ", " ").Trim().Split(Splitter); if (vals.Length == 3) { DateTime delDates = dtOrDate; if (vals[1].Trim() != "Day") { delDates = Common.GetSpecificDate(dtOrDate.Year, dtOrDate.Month, Convert.ToInt32(vals[0].Trim()), vals[1].Trim().ToLower()); } else delDates = Convert.ToDateTime(dtOrDate.Month + "/" + "1" + "/" + dtOrDate.Year); while (rec < rngId) { if (delDates < dtOrDate && repeat == 0) { //delDates = delDates.AddMonths(Convert.ToInt32(vals[2].ToString ())); delDates = delDates.AddYears(Convert.ToInt32("1")); if (vals[1].Trim() != "Day") { delDates = Common.GetSpecificDate(delDates.Year, delDates.Month, Convert.ToInt32(vals[0].Trim()), vals[1].Trim().ToLower()); } } else { objOrDels.OrderDeliveryDate = delDates; objOrDels.OrderDeliveryRecurrence = (rec + 1); OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels); rec++; delDates = Convert.ToDateTime(delDates).AddYears(Convert.ToInt32("1")); if (vals[1].Trim() != "Day") { delDates = Common.GetSpecificDate(delDates.Year, delDates.Month, Convert.ToInt32(vals[0].Trim()), vals[1].Trim().ToLower()); } dtOrDate = delDates; repeat = 1; } if (objOps.EndAfter == 0) { if (dtOrDate < objOps.EndBy) { rngId++; } else { rec = rngId; } } } } } } } } } /* private void GetOrderDeldate(OPS objOps,int ordId) { OPS objOrDels = new OPS(); objOrDels.OrderDeliveryId = 0; objOrDels.OrderId = ordId; if (objOps.DeliveryTypeId != 1) { int rec = 0; DateTime dtOrDate = objOps.DeliveryStartDate; int rngId = 0; if (objOps.RangeTypeId == 0) { rngId = 20; } else { rngId = objOps.EndAfter; } //while (rec < objOps.EndAfter) while (rec < rngId) { if (rec == 0) { objOrDels.OrderDeliveryDate = dtOrDate; } else { if (objOps.DeliveryTypeId == 2) { if (objOps.PatternNumber == 0) { objOrDels.OrderDeliveryDate = dtOrDate.AddDays(Convert.ToDouble(objOps.IntervalType)); } else { objOrDels.OrderDeliveryDate = dtOrDate.AddDays(Convert.ToDouble(objOps.IntervalType)); } dtOrDate = dtOrDate.AddDays(Convert.ToDouble (objOps.IntervalType)); } else if (objOps.DeliveryTypeId == 3) { int days = (Convert.ToInt32 (objOps.IntervalType) * 7); objOrDels.OrderDeliveryDate = dtOrDate.AddDays(Convert.ToDouble(days)); dtOrDate = dtOrDate.AddDays(days); } else if (objOps.DeliveryTypeId == 4) { objOrDels.OrderDeliveryDate = dtOrDate.AddMonths(Convert.ToInt32(objOps.IntervalType)); dtOrDate = dtOrDate.AddMonths(Convert.ToInt32 (objOps.IntervalType)); } else if (objOps.DeliveryTypeId == 5) { objOrDels.OrderDeliveryDate = dtOrDate.AddYears(Convert.ToInt32(objOps.IntervalType)); dtOrDate = dtOrDate.AddYears(Convert.ToInt32 (objOps.IntervalType)); } } rec++; objOrDels.OrderDeliveryRecurrence = rec; OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels); } } else { objOrDels.OrderDeliveryDate = objOps.DeliveryStartDate; ; objOrDels.OrderDeliveryRecurrence = 1; OPSTrans.InsertOrUpdateOrderDeliveryDates(objOrDels); } }*/ private void SendOrderConfirmation(Customer objCustomer, Recipient objRecipient, DataTable dtRecipients, OPS objOPS, DataTable dtBasket) { string orderTotal = "$ " + dtBasket.Compute("sum(ProductSum)", "").ToString(); if (objRecipient != null && dtRecipients == null) { StringBuilder sbTax = new StringBuilder(); sbTax.Append("<p>"); sbTax.Append("<table width='600'>"); sbTax.Append("<tr>"); sbTax.Append("<td width='300'><span style ='font-size:large; font-weight:bold;'>Fresh Flowers Order Confirmation</span></td><td align='right' width='150'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='2'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='2'>&nbsp;</td></tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'>"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2' valign='top' width='300' >"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'>"); sbTax.Append("<b>Sender Details</b>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Name:</td>"); sbTax.Append("<td>" + objCustomer.Title + objCustomer.FirstName + " " + objCustomer.SurName + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Home Phone:</td>"); sbTax.Append("<td>" + objCustomer.HomeNumberWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Work Phone:</td>"); sbTax.Append("<td>" + objCustomer.WorkPhoneWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Mobile:</td>"); sbTax.Append("<td>" + objCustomer.MobileNumber + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Email:</td>"); sbTax.Append("<td>" + objCustomer.EmailAddress + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan'2'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'><b>Recipient Details</b></td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Name:</td>"); sbTax.Append("<td>" + objRecipient.FirstName + " " + objRecipient.Surname + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Company Name:</td>"); sbTax.Append("<td>" + objRecipient.Company + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Hospital Name:</td>"); sbTax.Append("<td>" + objRecipient.HospialName + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Address:</td>"); sbTax.Append("<td>" + objRecipient.RecipientAddress + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Suburb:</td>"); sbTax.Append("<td>"); Suburb objSub = SuburbTrans.GetSuburbById(objRecipient.SuburbId); if (objSub.SuburbId != 0) { sbTax.Append(objSub.SuburbName); } sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>State:</td>"); sbTax.Append("<td>"); DataTable dtState = SuburbTrans.GetStateById(objRecipient.StateId); if (dtState.Rows.Count > 0) { sbTax.Append(dtState.Rows[0]["StateAbbr"].ToString()); } sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>PostCode:</td>"); sbTax.Append("<td>" + objRecipient.PostCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Home Phone:</td>"); sbTax.Append("<td>" + objRecipient.HomePhoneWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Work Phone:</td>"); sbTax.Append("<td>" + objRecipient.WorkPhoneWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Mobile:</td>"); sbTax.Append("<td>" + objRecipient.Mobilenumber + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'><b>Order Details</b></td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Product:</td>"); sbTax.Append("<td>"); string items = ""; if (dtBasket != null) { foreach (DataRow dr in dtBasket.Rows) { if (dr["ProductType"].ToString().Trim() == "P") { Product objProduct = ProductTrans.GetProductDetailsById(Convert.ToInt32(dr["ProductId"].ToString())); if (objProduct.ProductId != 0) { string prd = ""; string prdColorCode = ""; if (dr["ProductColor"] != null) { prdColorCode = dr["ProductColor"].ToString(); prdColorCode = prdColorCode.Trim(); if (prdColorCode != "") { prdColorCode = prdColorCode.Substring(0, 1).ToUpper(); } } prd = dr["Quantity"].ToString() + " x " + objProduct.IdNumber; prd += dr["ProductSize"].ToString().Trim() == "Ex" ? "Ex" : ""; prd += prdColorCode; prd = prd.Trim(); if (prd != "") { items += prd + " + "; } } } else { items += dr["Quantity"].ToString() + " x " + dr["ProductTitle"].ToString() + " + "; } } } items = items.Trim(); if (items.EndsWith("+")) { items = items.Remove(items.LastIndexOf("+"), 1); } sbTax.Append(items); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Price(including GST):</td>"); sbTax.Append("<td>" + ltrTotal.Text.Trim() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Order No:</td>"); sbTax.Append("<td>" + objOPS.OrderId.ToString() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Delivery Instructions:</td>"); sbTax.Append("<td>" + objOPS.DeliveryInstructions.Trim() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Card Message:</td>"); sbTax.Append("<td>" + objOPS.CardMessage.Trim() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Delivery Date:</td>"); sbTax.Append("<td>" + objOPS.DeliveryStartDate.ToString("dd/MM/yyy") + "</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</p>"); Common.MailContentCreation("XXXXXXX;" + System.Configuration.ConfigurationManager.AppSettings["mailTo"].ToString() + ";", "Order Confirmation - XXXXXXX", sbTax.ToString(), "", System.Configuration.ConfigurationManager.AppSettings["mailTo"].ToString()); } else { if (Session["Orderids"] != null) { ArrayList objOrder = (ArrayList)Session["Orderids"]; if (dtRecipients.Rows.Count > 0) { int indx = 0; foreach (DataRow drRec in dtRecipients.Rows) { Recipient objRec = RecipientTrans.GetRecipientById(Convert.ToInt32(drRec["RecipientId"].ToString())); StringBuilder sbTax = new StringBuilder(); sbTax.Append("<p>"); sbTax.Append("<table width='600'>"); sbTax.Append("<tr>"); sbTax.Append("<td width='300'><span style ='font-size:large; font-weight:bold;'>Order Confirmation</span></td><td align='right' width='150'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='2'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='2'>&nbsp;</td></tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'>"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2' valign='top' width='300' >"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'>"); sbTax.Append("<b>Sender Details</b>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Name:</td>"); sbTax.Append("<td>" + objCustomer.Title + objCustomer.FirstName + " " + objCustomer.SurName + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Home Phone:</td>"); sbTax.Append("<td>" + objCustomer.HomeNumberWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Work Phone:</td>"); sbTax.Append("<td>" + objCustomer.WorkPhoneWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Mobile:</td>"); sbTax.Append("<td>" + objCustomer.MobileNumber + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Email:</td>"); sbTax.Append("<td>" + objCustomer.EmailAddress + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan'2'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'><b>Recipient Details</b></td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Name:</td>"); sbTax.Append("<td>" + objRec.FirstName + " " + objRec.Surname + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Company Name:</td>"); sbTax.Append("<td>" + objRec.Company + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Hospital Name:</td>"); sbTax.Append("<td>" + objRec.HospialName + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Address:</td>"); sbTax.Append("<td>" + objRec.RecipientAddress + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Suburb:</td>"); sbTax.Append("<td>"); Suburb objSub = SuburbTrans.GetSuburbById(objRec.SuburbId); if (objSub.SuburbId != 0) { sbTax.Append(objSub.SuburbName); } sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>State:</td>"); sbTax.Append("<td>"); DataTable dtState = SuburbTrans.GetStateById(objRec.StateId); if (dtState.Rows.Count > 0) { sbTax.Append(dtState.Rows[0]["StateAbbr"].ToString()); } sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>PostCode:</td>"); sbTax.Append("<td>" + objRec.PostCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Home Phone:</td>"); sbTax.Append("<td>" + objRec.HomePhoneWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Work Phone:</td>"); sbTax.Append("<td>" + objRec.WorkPhoneWithCode + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Mobile:</td>"); sbTax.Append("<td>" + objRec.Mobilenumber + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'><b>Order Details</b></td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Product:</td>"); sbTax.Append("<td>"); string items = ""; if (dtBasket != null) { foreach (DataRow dr in dtBasket.Rows) { if (dr["ProductType"].ToString().Trim() == "P") { Product objProduct = ProductTrans.GetProductDetailsById(Convert.ToInt32(dr["ProductId"].ToString())); if (objProduct.ProductId != 0) { string prd = ""; string prdColorCode = ""; if (dr["ProductColor"] != null) { prdColorCode = dr["ProductColor"].ToString(); prdColorCode = prdColorCode.Trim(); if (prdColorCode != "") { prdColorCode = prdColorCode.Substring(0, 1).ToUpper(); } } prd = dr["Quantity"].ToString() + " x " + objProduct.IdNumber; prd += dr["ProductSize"].ToString().Trim() == "Ex" ? "Ex" : ""; prd += prdColorCode; prd = prd.Trim(); if (prd != "") { items += prd + " + "; } } } else { items += dr["Quantity"].ToString() + " x " + dr["ProductTitle"].ToString() + " + "; } } } items = items.Trim(); if (items.EndsWith("+")) { items = items.Remove(items.LastIndexOf("+"), 1); } sbTax.Append(items); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Price(including GST):</td>"); sbTax.Append("<td>$" + ltrOrder.Text.Trim() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Order No:</td>"); sbTax.Append("<td>"); sbTax.Append(objOrder[indx].ToString()); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Delivery Instructions:</td>"); sbTax.Append("<td>" + objOPS.DeliveryInstructions.Trim() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Card Message:</td>"); sbTax.Append("<td>" + objOPS.CardMessage.Trim() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Delivery Date:</td>"); sbTax.Append("<td>" + objOPS.DeliveryStartDate.ToString("dd/MM/yyy") + "</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</p>"); indx++; Common.MailContentCreation("XXXXXXX;" + System.Configuration.ConfigurationManager.AppSettings["mailTo"].ToString() + ";", "Order Confirmation - XXXXXXX", sbTax.ToString(), "", System.Configuration.ConfigurationManager.AppSettings["mailTo"].ToString()); } } } } } private void SendTaxInvoice(object[] objInfo) { if (objInfo.Length == 3) { Customer objCustomer = (Customer)objInfo[0]; Recipient objRecipient = null; DataTable dtRecipients = null; OPS objOPS = (OPS)objInfo[2]; DataTable dtBasket = (DataTable)Session["MyBasket"]; string orderTotal = "$ " + dtBasket.Compute("sum(ProductSum)", "").ToString(); StringBuilder sbTax = new StringBuilder(); sbTax.Append("<p>"); sbTax.Append("<table width='600'>"); sbTax.Append("<tr>"); sbTax.Append("<td width='300'><span style ='font-size:large; font-weight:bold;'>Tax Invoice</span></td><td align='right' width='150'>" + DateTime.Today.ToString("dd/MM/yyy") + "</td></tr>"); sbTax.Append("<tr><td colspan='2'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='2'>&nbsp;</td></tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2'>"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='2' valign='top' width='300' >"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td>To:</td>"); // sbTax .Append ("<td>"+objCustomer.FullName+"</td>"); sbTax.Append("<td>" + objCustomer.Title + " " + objCustomer.FirstName + " " + objCustomer.SurName + "</td>"); sbTax.Append("</tr>"); if (objCustomer.IsOverSeas == 1) { sbTax.Append("<tr>"); sbTax.Append("<td></td>"); sbTax.Append("<td>" + objCustomer.OverSeasAddress + "</td>"); sbTax.Append("</tr>"); } else { sbTax.Append("<tr>"); sbTax.Append("<td></td>"); sbTax.Append("<td>" + objCustomer.Address + "</td>"); sbTax.Append("</tr>"); } if (objCustomer.IsOverSeas == 1) { sbTax.Append("<tr>"); sbTax.Append("<td></td>"); sbTax.Append("<td>" + objCustomer.OverSeasTown + ", " + objCustomer.OverSeasState + ", " + objCustomer.Country + " " + objCustomer.OverSeasPostCode + "</td>"); sbTax.Append("</tr>"); } else { Suburb objSub = SuburbTrans.GetSuburbById(objCustomer.SuburbId); string loc = ""; /*if (objSub.SuburbId != 0) { if (objSub.Loaction != "") { loc = objSub.Loaction.Trim(); } }*/ sbTax.Append("<tr>"); sbTax.Append("<td></td>"); //if (loc != "") if (objSub.StateAbbreviation != "") { //sbTax.Append("<td>" + objCustomer.Suburb + ", " + loc + ", " + objCustomer.State + "</td>"); sbTax.Append("<td>" + objCustomer.Suburb + ", " + objSub.StateAbbreviation + " " + objCustomer.PostCode + "</td>"); } else { sbTax.Append("<td>" + objCustomer.Suburb + ", " + objCustomer.State + " " + objCustomer.PostCode + "</td>"); } sbTax.Append("</tr>"); } sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("<td valign='top' width='150'>"); sbTax.Append("CustomerID No#: &nbsp;" + objCustomer.MemberId); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='3'>&nbsp;</td></tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='3'>"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td><strong>Order#:</strong></td>"); if (Session["Orderids"] != null) { string orders = ""; ArrayList objLists = (ArrayList)Session["Orderids"]; if (objLists.Count > 0) { foreach (object obj in objLists) { orders += obj.ToString() + ", "; } orders = orders.Trim(); if (orders.EndsWith(",")) { orders = orders.Remove(orders.LastIndexOf(","), 1); } sbTax.Append("<td align='right'>" + orders + "</td>"); } } else { sbTax.Append("<td align='right'>" + objOPS.OrderId + "</td>"); } sbTax.Append("<td>&nbsp;&nbsp;</td>"); sbTax.Append("<td><strong>Delivery Date:</strong></td>"); sbTax.Append("<td>" + objOPS.DeliveryStartDate.ToString("dd/MM/yyy") + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td><strong>Total Order Amount:</strong></td>"); //sbTax.Append("<td align='right'>$"+ltrTotal.Text +"</td>"); sbTax.Append("<td align='right'><div style ='float:right;'>" + orderTotal + "</div></td>"); sbTax.Append("<td>&nbsp;&nbsp;</td>"); sbTax.Append("<td colspan='2'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td><strong>Freight:</strong></td>"); sbTax.Append("<td align='right'><div style ='float:right;'>$15.00</div></td>"); sbTax.Append("<td>&nbsp;&nbsp;</td>"); sbTax.Append("<td colspan='2'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td><strong>Amount Paid:</strong></td>"); sbTax.Append("<td align='right'>" + ltrTotal.Text + "</td>"); sbTax.Append("<td>&nbsp;&nbsp;</td>"); //sbTax.Append("<td><strong>Promotion Code:</strong></td>"); sbTax.Append("<td>&nbsp;</td>"); sbTax.Append("<td>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td><strong>Sales Person:</strong></td>"); sbTax.Append("<td align='right'>Web Sale</td>"); sbTax.Append("<td>&nbsp;</td>"); sbTax.Append("<td>&nbsp;&nbsp;</td>"); sbTax.Append("<td>&nbsp;&nbsp;</td>"); sbTax.Append("<TD>&nbsp;</td>"); sbTax.Append("<td>&nbsp;</td>"); //sbTax.Append("<td><strong>Amount Owing:</strong></td>"); //sbTax.Append("<td align='right'>$0.00</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr><td colspan='3'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='3'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='3'><strong><i>Payment Details</i></strong></td></tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='3'>"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td align='left'><strong>Payment Date</strong></td>"); sbTax.Append("<td align='left'><strong>Banked Date</strong></td>"); sbTax.Append("<td align='left'><strong>Transaction Type</strong></td>"); sbTax.Append("<td align='left'><strong>Method</strong></td>"); sbTax.Append("<td align='right'><strong>Payment Amount</strong></td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td align='left'>" + DateTime.Today.ToString("dd/MM/yyy") + "</td>"); sbTax.Append("<td align='left'>" + DateTime.Today.ToString("dd/MM/yyy") + "</td>"); sbTax.Append("<td align='left'>Payment</td>"); sbTax.Append("<td align='left'>" + ddlCardType.SelectedItem.Text + "</td>"); sbTax.Append("<td align='right'>" + ltrTotal.Text + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='4' align='right'><strong>Total Payment:</strong></td>"); sbTax.Append("<td align='right'>" + ltrTotal.Text + "</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr><td colspan='3'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='3'>&nbsp;</td></tr>"); sbTax.Append("<tr><td colspan='3'><strong><i>Product Purchase Details</i></strong></td></tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='3'>"); sbTax.Append("<table width='100%'>"); sbTax.Append("<tr>"); sbTax.Append("<td align='left' width='20%'><strong>Product Code</strong></td>"); sbTax.Append("<td align='left' width='50%'><strong>Description</strong></td>"); sbTax.Append("<td align='right' width='10%'><strong>Quantity</strong></td>"); sbTax.Append("<td align='right'width='20%'><strong>Price</strong></td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='4'>&nbsp;</td>"); sbTax.Append("</tr>"); if (dtBasket != null) { foreach (DataRow dr in dtBasket.Rows) { if (dr["ProductType"].ToString().Trim() == "P") { Product objProduct = ProductTrans.GetProductDetailsById(Convert.ToInt32(dr["ProductId"].ToString())); if (objProduct.ProductId != 0) { string prdColorCode = ""; if (dr["ProductColor"] != null) { prdColorCode = dr["ProductColor"].ToString(); prdColorCode = prdColorCode.Trim(); if (prdColorCode != "") { prdColorCode = prdColorCode.Substring(0, 1).ToUpper(); } } prdColorCode = Convert.ToString(objProduct.IdNumber + prdColorCode); sbTax.Append("<tr>"); //sbTax.Append("<td align='left' width='20%' valign='top'>" + objProduct.IdNumber + "</td>"); sbTax.Append("<td align='left' width='20%' valign='top'>" + prdColorCode + "</td>"); sbTax.Append("<td align='left' width='50%' valign='top'>" + objProduct.Description + "</td>"); } } else { AddOnProduct objAddon = AddOnProductTrans.GetAddOnProductById(Convert.ToInt32(dr["ProductId"].ToString())); if (objAddon.AddOnId != 0) { sbTax.Append("<tr>"); sbTax.Append("<td align='left' width='20%' valign='top'><div style='float:left;'>" + objAddon.AddOnCode + "</div></td>"); sbTax.Append("<td align='left' width='50%' valign='top'><div style='float:left;'>" + objAddon.Description + "</div></td>"); } } sbTax.Append("<td align='right' width='10%' valign='top'>" + dr["Quantity"].ToString() + "</td>"); sbTax.Append("<td align='right' width='20%' valign='top'>$" + dr["ProductSum"].ToString() + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='4'>&nbsp;</td>"); sbTax.Append("</tr>"); } sbTax.Append("<tr>"); sbTax.Append("<td colspan='3' align='right'><strong>GST:</strong></td>"); //sbTax .Append("<td align='right'> //string tot = ltrTotal.Text.Trim(); string tot = orderTotal; if (tot.Contains("$")) { tot = tot.Remove(0, 1).Trim(); } try { tot = "$" + Convert.ToString(Math.Round(Convert.ToDecimal(tot) * Convert.ToDecimal("0.11"), 2)); } catch (Exception ex) { tot = "$0.00"; } sbTax.Append("<td align='right'>" + tot + "</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='3' align='right'><div style ='float:right;'><strong>Total Price:</strong></div></td>"); sbTax.Append("<td align='right'>" + ltrTotal.Text.Trim() + "</td>"); sbTax.Append("</tr>"); } sbTax.Append("<tr>"); sbTax.Append("<td colspan='4'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='4'>"); sbTax.Append("<table><tr>"); sbTax.Append("<td>Tel </td>"); sbTax.Append("<td>&nbsp;</td>"); sbTax.Append("<td>13 37 37 or 1800 337 374</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Fax </td>"); sbTax.Append("<td>&nbsp;</td>"); sbTax.Append("<td>(02) 9734 9593</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>Post </td>"); sbTax.Append("<td>&nbsp;</td>"); sbTax.Append("<td>XXXXXXX, Australia</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td>ABN</td>"); sbTax.Append("<td>&nbsp;</td>"); sbTax.Append("<td>XXXXXXX</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("<tr>"); sbTax.Append("<td colspan='4'>&nbsp;</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</td>"); sbTax.Append("</tr>"); sbTax.Append("</table>"); sbTax.Append("</p>"); //Common.MailContentCreation(objCustomer.EmailAddress + ";XXXXXXX;" + System.Configuration.ConfigurationManager.AppSettings["mailTo"].ToString() + ";", "Tax Invoice - LynchGroup", sbTax.ToString(), "", System.Configuration.ConfigurationManager.AppSettings["mailTo"].ToString()); Common.MailContentCreation(objCustomer.EmailAddress, "Tax Invoice - XXXXXXX", sbTax.ToString(), "", System.Configuration.ConfigurationManager.AppSettings["mailTo"].ToString()); if (objCustomer.MemberId != 0 && Session["Member"] != null) { dtRecipients = (DataTable)objInfo[1]; } else { objRecipient = (Recipient)objInfo[1]; } SendOrderConfirmation(objCustomer, objRecipient, dtRecipients, objOPS, dtBasket); } } private string EncryptCreditCard(string val) { val = val.Trim(); GnuPGWrapper gpg = new GnuPGWrapper(); //gpg.homedirectory = @"XXXXXXX"; gpg.homedirectory = @"XXXXXXX"; gpg.passphrase = "XXXXXXX"; gpg.originator = ""; // no originator needed for encryption only gpg.recipient = "XXXXXXX"; gpg.command = Commands.Encrypt; string outputText = ""; gpg.ExecuteCommand(val, out outputText); return outputText; } private string EncryptCreditCardNumber(string val) { XXXXXXX = new XXXXXXX(); string Password = "XXXXXXX"; byte[] PlainText = System.Text.Encoding.Unicode.GetBytes(val); byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString()); PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, XXXXXXX); //Creates a symmetric encryptor object. ICryptoTransform Encryptor = RijndaelCipher.CreateEncryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16)); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); //Defines a stream that links data streams to cryptographic transformations CryptoStream cryptoStream = new CryptoStream(memoryStream, Encryptor, CryptoStreamMode.Write); cryptoStream.Write(PlainText, 0, PlainText.Length); //Writes the final state and clears the buffer cryptoStream.FlushFinalBlock(); byte[] CipherBytes = memoryStream.ToArray(); memoryStream.Close(); cryptoStream.Close(); string EncryptedData = Convert.ToBase64String(CipherBytes); return EncryptedData; } }
                  else if (objOps.Pattern1 == "" && objOps.Pattern2 != "")
    

Answers (3)