Exemplo n.º 1
0
        protected void btnCheckout_Click(object sender, System.EventArgs e)
        {
            if(!(doValidate()))
                return;

            int sessionOrderId = Convert.ToInt32(Session["SID"]);
            ITC itc = new ITC();
            OTCShoppingCart cart	= new OTCShoppingCart(this.m_shoppingCartId);

            string promotionKey = Request.Form["promotion"].Length > 0 ? Request.Form["promotion"] : "";
            if (promotionKey.Length > 0)
            {
                //If we have a promotion, apply here & the next instance will recognize it. We could
                //have a function that would reload the shopping cart? This is much easier for the sake of time.
                cart.ApplyPromotion(promotionKey, this.m_shoppingCartId);
            }

            //BG - Added swap product sku for international and canadian
            string shippingType = String.Empty;
            if (isInternationalAutoShip()) shippingType = "International";
            else if (isCanadianAutoShip()) shippingType = "Canadian";

            if (!String.IsNullOrEmpty(shippingType))
            {
                foreach (var item in cart.CartItems) swapProduct(shippingType, item.ProductID);
            }

            //refresh cart
            cart = new OTCShoppingCart(this.m_shoppingCartId);

            OTCSalesOrder order		= new OTCSalesOrder();
            order.ShoppingCartId    = cart.ShoppingCartID;
            order.OTCPromotionId    = cart.OTCPromotionId;
            order.Address			= this.txtAddress.Text;
            order.City				= this.txtCity.Text;
            order.Country           = this.ddCountry.SelectedItem.Text;
            order.EmailAddress		= this.txtEmailAddress.Text;
            order.FirstName			= this.txtFirstName.Text;
            order.LastName			= this.txtLastName.Text;
            order.Phone             = this.txtPhone.Text;
            order.OrderCost			= cart.CartTotal;
            order.SalesTax          = this.m_salesTax;
            order.OTCSiteId			= itc.SiteId;
            order.ShippingAddress	= this.txtShippingAddress.Text;
            order.ShippingCity		= this.txtShippingCity.Text;
            order.ShippingCost		= getShippingCost(this.ddShippingMethods.SelectedItem.Value);
            order.ShippingFirstName = this.txtShippingFirstName.Text;
            order.ShippingLastName	= this.txtShippingLastName.Text;
            //order.ShippingState		= this.txtShippingStateProvince.Text;
            order.ShippingState     = this.getShippingStateOrProvince();
            order.ShippingZip		= this.txtShippingZipPostalCode.Text; //bug fix
            //order.State				= this.ddState.SelectedIndex > 0 ? this.ddState.SelectedItem.Text : "";
            order.State             = this.getBillingStateOrProvince();
            order.ShippingPhone     = this.txtShippingPhone.Text;
            order.Zip				= this.txtZipPostalCode.Text;
            order.ShippingCountryId = Convert.ToInt32(this.ddShippingCountry.SelectedValue);
            order.ShippingCountry   = this.ddShippingCountry.SelectedItem.Text;
            order.ShippingMethod    = this.ddShippingMethods.SelectedItem.Text;
            order.ShippingEmailAddress = this.txtShippingEmailAddress.Text;
            order.Comments			= this.txtComments.Value.Length > 0 ? this.txtComments.Value : "";
            int id = order.Add();
            OTCCreditCard cc        = new OTCCreditCard();
            cc.OTCSalesOrderId      = order.OTCSalesOrderId;
            cc.OTCSiteMemberId      = order.OTCSiteMemberId;
            cc.CardNumber           = this.txtCardNumber.Text;
            cc.CardType             = this.ddCCType.SelectedValue;
            cc.ExpirationMonth      = this.ddMonth.SelectedValue;
            cc.ExpirationYear       = this.ddYear.SelectedValue;
            cc.IISSessionId         = Session.SessionID;
            cc.Add();

            if(Convert.ToBoolean(Session["WantsMemberShip"]))
            {
                OTCPromotion.AddMemberPromotion(order.OTCSiteMemberId,1);
            }

            //if(this.txtComments.Value.Length > 0)
            //{
            //	OTCContact contact = new OTCContact();
            //	contact.SiteId = 7;
            //	contact.EmailAddress = this.txtEmailAddress.Text;
            //	contact.FirstName = this.txtFirstName.Text;
            //	contact.LastName = this.txtLastName.Text;
            //	contact.Comment1 = this.txtComments.Value;
            //	contact.Add();
            //}

            try
            {
                string sql = "";
                this.m_db.Open();
                string howDidYouHear = Request.Form["txtHowDidYouHear"];

                if(howDidYouHear.Length > 0)
                {
                    sql = "spInsertOTCSiteMemberQuestionAnswerAffiliation "
                        + "@OTCSiteMemberId = " + order.OTCSiteMemberId + ","
                        + "@OTCSiteMemberQuestionId = 1,"
                        + "@OTCSiteMemberAnswerID = 1,"
                        + "@AnswerText = " + OTCDatabase.SqlFormat(howDidYouHear)
                        ;
                    this.m_db.SendSQLUpdate(sql);
                }

                foreach(string s in Request.Form.ToString().Split('&')){
                    if(s.IndexOf("mq_") > -1){
                        int questionId = Convert.ToInt32(s.Split('=')[0].Replace("mq_",""));
                        int answerId   = Convert.ToInt32(s.Split('=')[1]);
                        sql = "spInsertOTCSiteMemberQuestionAnswerAffiliation "
                            + "@OTCSiteMemberId = " + order.OTCSiteMemberId + ","
                            + "@OTCSiteMemberQuestionId = " + questionId + ","
                            + "@OTCSiteMemberAnswerID = " + answerId
                            ;
                        this.m_db.SendSQLUpdate(sql);
                    }
                }

                sql = "spUpdateCartAbandonmentOrderID @sessionId = " + OTCDatabase.SqlFormat(Session.SessionID);
                sql += ",@cartId = " + cart.ShoppingCartID;
                sql += ",@OrderId = " + order.OTCSalesOrderId;
                this.m_db.SendSQLUpdate(sql);

                this.m_db.ReleaseConnection();
            }

            catch(Exception ex) {/*do nothing*/}
            OTCEncryption crypt = new OTCEncryption(7);
            cart = new OTCShoppingCart(Session.SessionID);
            Session["shoppingCartId"]   = cart.AddNew();

            Session["SID"] = 0;

            if (Page.IsValid)
            {
                Session["SessionID"] = Session.SessionID;
                Response.Redirect("../order/creditcardpost.aspx?OID=" + id.ToString() + "&_ga=" + Request.QueryString["_ga"] + "&site=" + Request.QueryString["site"]);

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Expire the page to avoid users from clicking the back button.
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
            Response.Cache.SetNoStore();
            Response.AppendHeader("Pragma", "no-cache");

            m_currentSession = Session["SessionID"] != null ? Session["SessionID"].ToString() : "";

            if (m_currentSession == "")
                m_orderMessage = "You're order has already been processed. <br>";
            else
                m_orderMessage = "Thank you - Please wait and do not click the back button, your order is processing...";

            string siteName = Request.QueryString.ToString().IndexOf("site") > -1 ? Request.QueryString["site"] : "bm";

            if (!Page.IsPostBack)
            {
                if (m_currentSession != "")
                {
                    OTCEncryption crypt = new OTCEncryption(7);
                    int id = Convert.ToInt32(Request.QueryString["OID"]);
                    this.m_order = new OTCSalesOrder(id);
                    this.m_member = new OTCSiteMember(this.m_order.OTCSiteMemberId);
                    this.m_card = new OTCCreditCard(this.m_order.OTCSalesOrderId, Session.SessionID);

                    if (this.m_card.IISSessionId != Session.SessionID)
                    {
                        if (Request.ServerVariables["HTTP_HOST"].IndexOf("localhost") > -1)
                            Response.Redirect("/interceuticals/default.aspx");
                        else
                            Response.Redirect("http://www.interceuticals.com");
                    }

                    this.m_page = new ITCPage();
                    this.m_db.Open();
                    this.m_dt = this.m_db.GetDataset("spGetOTCSalesOrderDetails_Verisign @OTCSalesOrderId = " + id).Tables[1];

                    foreach (DataRow dr in this.m_dt.Rows)
                    {
                        this.m_product += dr["ProductName"].ToString();
                    }

                    this.m_db.ReleaseConnection();

                    //hack to finish and get deployed.
                    string sql = "SELECT * FROM OTCSalesOrderDetail WHERE OTCSalesOrderId = " + this.m_order.OTCSalesOrderId;
                    OTCDatabase db = new OTCDatabase();
                    db.Open();
                    DataTable dt = db.GetDataset(sql).Tables[0];
                    db.ReleaseConnection();

                    //this.m_siteString = "|BM|BetterMan|Male|";
                    //UTM:T|<%=Order.OTCSalesOrderId%>|<%=this.SiteName%>|<%=Order.TotalCost%>|<%=Convert.ToDouble(ProductPrice * Order.SalesTax).ToString("c").Replace("$","")%>|<%=Order.ShippingCost%>|<%=Order.City%>|<%=Order.State%>|<%=Order.Country%> UTM:I|<%=Order.OTCSalesOrderId%><%=this.SiteString%><%=ProductPrice%>|<%=ProductQty%>
                    this.m_siteName = siteName == "bm" ? "BetterManNow" : "BetterWomanNow";
                    //this.m_googleTrackingCode	= this.m_page.AnalyticsTracking;

                    foreach (DataRow dr in dt.Rows)
                    {
                        int productId = Convert.ToInt32(dr["OTCProductId"]);
                        OTCProduct p = new OTCProduct(productId);
                        if (p.CategoryId == 21)
                        {
                            this.m_siteString += "UTM:T|" + Order.OTCSalesOrderId + "|" + this.SiteName + "|" + Order.TotalCost + "|" + Convert.ToDouble(ProductPrice * Order.SalesTax).ToString("c").Replace("$", "") + "|" + Order.ShippingCost + "|" + Order.City + "|" + Order.State + "|" + Order.Country + "UTM:I|" + Order.OTCSalesOrderId + "|BM|BetterMan|Male|" + ProductPrice + "|" + ProductQty + (char)10;//"|BM|BetterMan|Male|";
                            //this.m_siteName   = "BetterManNow";
                            //this.m_googleTrackingCode = "UA-1185020-2";
                        }
                        else
                        {
                            //this.m_siteString = "|BW|BetterWoman|Female|";
                            this.m_siteString += "UTM:T|" + Order.OTCSalesOrderId + "|" + this.SiteName + "|" + Order.TotalCost + "|" + Convert.ToDouble(ProductPrice * Order.SalesTax).ToString("c").Replace("$", "") + "|" + Order.ShippingCost + "|" + Order.City + "|" + Order.State + "|" + Order.Country + "UTM:I|" + Order.OTCSalesOrderId + "|BW|BetterWoman|Female|" + ProductPrice + "|" + ProductQty + (char)10;//"|BM|BetterMan|Male|";
                            //this.m_siteName   = "BetterWomanNow";
                            //this.m_googleTrackingCode = "UA-1185020-1";
                        }
                        m_productPrice = p.Price;
                        Session["WantsMembership"] = true;

                    }

                    //Do this to avoid duplicate order post to paypal.
                    Session.Clear();
                    Session.Abandon();

                }
                else
                    Response.Redirect("PostedMessage.aspx");

            }
        }
Exemplo n.º 3
0
        //=================================
        //
        //=================================
        /*
        private EDGAMenu buildMenu()
        {
            EDGAMenu menu = new EDGAMenu();
            menu.MenuWidth = "";
            EDGAMenuItem item  = new EDGAMenuItem();
            item.Text = "Reports";
            item.HREF = "reportpicker.aspx";
            menu.AddMenuItem(item);
            item = new EDGAMenuItem();
            item.Text = "Change Dates";
            item.HREF = "default.aspx?RID=" + this.m_report.OTCReportId;
            menu.AddMenuItem(item);
            item = new EDGAMenuItem();
            item.Text = "<img src=\"/edga/images/icons/csv.gif\" border=\"0\">";
            string qstring = "report.aspx?RID=" + this.m_report.OTCReportId + "&thread=csv&STD=" + this.m_startDate.ToShortDateString() + "&EDT=" + this.m_endDate.ToShortDateString();
            if(this.m_lineOrderId > 0)
                qstring += "&LID=" + this.m_lineOrderId;
            item.HREF = qstring;
            menu.AddMenuItem(item);
            return(menu);
        }
        */
        //==================================
        //
        //==================================
        private void buildGrid(DataTable dt, DataRow[] rows)
        {
            string className = "gridRowAlt";

            Response.Write("<br><table class=\"tableWrapper\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\" border=\"0\">"
                + CR + " <tr>"
                + CR + "  <td colspan=\"" + ((dt.Columns.Count / 2) + 2) + "\" class=\"gridHeader\"><b>" + this.m_report.OTCReportName + "</b> " + this.m_startDate.ToShortDateString()+ "<i> thru </i>" + this.m_endDate.ToShortDateString() + " - " + this.m_report.OTCReportDescription + " : <b>" + rows.Length + " : Records</b></td>"
                + CR + "  <td align=\"right\" class=\"gridHeader\" nowrap colspan=\"" + ((dt.Columns.Count / 2) - 2)+ "\">[ <a href=\"default.aspx?RID=" + this.m_reportId + "\">change dates</a> ] &nbsp; [ <a href=\"reportpicker.aspx\">change report</a> ]</td>"
                + CR + " <tr>"
                );

            foreach(DataColumn dc in dt.Columns)
            {
                string qstring = "reporter.aspx?sort=" + dc.ColumnName + "&dir=" + (this.m_sortDirection == "DESC" ? "ASC" : "DESC") + "&STD=" + this.m_startDate.ToShortDateString() + "&EDT=" + this.m_endDate.ToShortDateString() + "&RID=" + this.m_reportId;
                if(this.m_lineOrderId > 0)
                    qstring += "&LID=" + this.m_lineOrderId;

                if(dc.ColumnName != "SortEm" && dc.ColumnName.IndexOf("NO_DISPLAY") == -1)
                    Response.Write("  <td class=\"gridHeader\" nowrap><b><a href=\"" + qstring + "\">" + dc.ColumnName + "</a></td>" + CR);
            }

            Response.Write(" </tr>" + CR);

            OTCEncryption crypt = new OTCEncryption(7);

            foreach(DataRow dr in rows)
            {
                className = className == "gridRow" ? "gridRowAlt" : "gridRow";
                Response.Write(" <tr class=\"" + className + "\" valign=\"top\">" + CR);
                foreach(DataColumn dc in dt.Columns)
                {
                    string columnData  = "";
                    string columnAlign = "";

                    switch(dc.DataType.Name)
                    {
                        case "DateTime" :
                            columnData  = Convert.ToDateTime(dr[dc.ColumnName]).ToShortDateString() != "1/1/1900" ? Convert.ToDateTime(dr[dc.ColumnName]).ToShortDateString() : "NEVER";
                            columnAlign = "left";
                            break;
                        case "String" :
                            columnData  = dr[dc.ColumnName].ToString();
                            columnAlign = "left";
                            break;
                        default :
                            columnData  = dr[dc.ColumnName].ToString();
                            columnAlign = "right";
                            break;
                    }

                    if(dc.ColumnName != "SortEm" && dc.ColumnName.IndexOf("NO_DISPLAY") == -1)
                    {
                        if(dc.ColumnName.IndexOf("DECRYPT") > -1)
                        {
                            //USED FOR SRS ONLY
                            if(dc.ColumnName != "DECRYPT_EXPIRES")
                                columnData = crypt.Decrypt(columnData.Replace("DECRYPT_",""));
                            else
                            {
                                string month = crypt.Decrypt(columnData.Split(' ')[0]);
                                string year  = crypt.Decrypt(columnData.Split(' ')[1]);
                                columnData = (month.Length < 2 ? "0" + month : month) + "/" + year.Substring(2,2);
                            }
                        }
                        Response.Write(" <td class=\"formFont\" align=\"" + columnAlign + "\" nowrap>" + columnData.Replace(":^~^:","<br>") + "</td>" + CR);
                    }
                }
                Response.Write(" </tr>");
            }

            Response.Write("</table>" + CR);
        }
Exemplo n.º 4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string siteName = Request.QueryString.ToString().IndexOf("site") > - 1 ? Request.QueryString["site"] : "bm";
            OTCEncryption crypt = new OTCEncryption(7);
            int id = Convert.ToInt32(Request.QueryString["OID"]);
            this.m_order  = new OTCSalesOrder(id);
            this.m_member = new OTCSiteMember(this.m_order.OTCSiteMemberId);
            this.m_card   = new OTCCreditCard(this.m_order.OTCSalesOrderId,Session.SessionID);

            if(this.m_card.IISSessionId != Session.SessionID)
                Response.Redirect("/interceuticals/index.html");

            this.m_page   = new ITCPage();
            this.m_db.Open();
            this.m_dt	  = this.m_db.GetDataset("spGetOTCSalesOrderDetails_Verisign @OTCSalesOrderId = " + id).Tables[1];

            foreach(DataRow dr in this.m_dt.Rows)
            {
                this.m_product += dr["ProductName"].ToString();
            }

            this.m_db.ReleaseConnection();

            //hack to finish and get deployed.
            string sql = "SELECT * FROM OTCSalesOrderDetail WHERE OTCSalesOrderId = " + this.m_order.OTCSalesOrderId;
            OTCDatabase db = new OTCDatabase();
            db.Open();
            DataTable dt = db.GetDataset(sql).Tables[0];
            db.ReleaseConnection();

            //this.m_siteString = "|BM|BetterMan|Male|";
            //UTM:T|<%=Order.OTCSalesOrderId%>|<%=this.SiteName%>|<%=Order.TotalCost%>|<%=Convert.ToDouble(ProductPrice * Order.SalesTax).ToString("c").Replace("$","")%>|<%=Order.ShippingCost%>|<%=Order.City%>|<%=Order.State%>|<%=Order.Country%> UTM:I|<%=Order.OTCSalesOrderId%><%=this.SiteString%><%=ProductPrice%>|<%=ProductQty%>
            this.m_siteName = siteName == "bm" ? "BetterManNow" : "BetterWomanNow";
            //this.m_googleTrackingCode	= this.m_page.AnalyticsTracking;

            foreach(DataRow dr in dt.Rows)
            {
                int productId = Convert.ToInt32(dr["OTCProductId"]);
                OTCProduct p = new OTCProduct(productId);
                if(p.CategoryId == 21){
                    this.m_siteString += "UTM:T|" + Order.OTCSalesOrderId + "|" + this.SiteName + "|" + Order.TotalCost + "|" + Convert.ToDouble(ProductPrice * Order.SalesTax).ToString("c").Replace("$","") + "|" + Order.ShippingCost + "|" + Order.City + "|" + Order.State + "|" + Order.Country + "UTM:I|" + Order.OTCSalesOrderId + "|BM|BetterMan|Male|" + ProductPrice + "|" + ProductQty  + (char)10;//"|BM|BetterMan|Male|";
                    //this.m_siteName   = "BetterManNow";
                    //this.m_googleTrackingCode = "UA-1185020-2";
                } else {
                    //this.m_siteString = "|BW|BetterWoman|Female|";
                    this.m_siteString += "UTM:T|" + Order.OTCSalesOrderId + "|" + this.SiteName + "|" + Order.TotalCost + "|" + Convert.ToDouble(ProductPrice * Order.SalesTax).ToString("c").Replace("$","") + "|" + Order.ShippingCost + "|" + Order.City + "|" + Order.State + "|" + Order.Country + "UTM:I|" + Order.OTCSalesOrderId + "|BW|BetterWoman|Female|" + ProductPrice + "|" + ProductQty + (char)10;//"|BM|BetterMan|Male|";
                    //this.m_siteName   = "BetterWomanNow";
                    //this.m_googleTrackingCode = "UA-1185020-1";
                }
                m_productPrice = p.Price;
                Session["WantsMembership"] = true;
            }
        }