Пример #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"]);

            }
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        public void DrawMemberQuestions()
        {
            ArrayList l = new ArrayList();
            ITC itc = new ITC();
            DataTable dt = OTCSiteMemberQuestion.GetSiteMemberQuestions(itc.SiteId);

            foreach(DataRow dr in dt.Rows){
                if(!(l.Contains(dr["QuestionText"].ToString())))
                    l.Add(dr["QuestionText"].ToString());
            }

            Response.Write("<table border=\"0\">"
                    + CR + " <tr>"
                    + CR + "  <td>How did you hear about us?</td>"
                    + CR + "  <td><input class=\"textbox\" type=\"textbox\" name=\"txtHowDidYouHear\" size=\"27\"></td>"
                    + CR + " </tr>"
                    );

            for(int i=0;i<l.Count;i++){
                DataRow[] rows = dt.Select("QuestionText = '" + l[i].ToString() + "'");
                Response.Write(" <tr>"
                        + CR + "  <td>" + l[i].ToString() + "</td>"
                        + CR + "  <td>" + this.buildList(rows,rows[0]["OTCSiteMemberQuestionId"].ToString(),"Select One") + "</td>"
                        + CR + " </tr>"
                        );
            }

            Response.Write(" <tr>"
                    + CR + "  <td>Please enter in your promotion code:<br><font size=\"1\">(only if applicable)</td>"
                    + CR + "  <td><input type=\"textbox\" class=\"textbox\" id=\"promotion\" name=\"promotion\" size=\"27\"></td>"
                    + CR + " </tr>"
                    + CR + "</table>" + CR
                    );
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        private void fillListBoxes()
        {
            ITC dz = new ITC();
            //this.ddVendors.SQL       = "spGetOTCVendorBySiteId @OTCSiteId = " + dz.SiteId;
            //this.ddVendors.TextField = "OTCVendorName";
            //this.ddVendors.IdField   = "NO_DISPLAY_OTCVendorId";
            //this.ddVendors.IntroText = "<select vendor>";
            //this.ddVendors.Fill();

            this.ddCategory.SQL       = "spGetOTCProductCategoryBySiteId @OTCSiteId = " + dz.SiteId;
            this.ddCategory.TextField = "NO_DISPLAY_ProductCategoryDescription";
            this.ddCategory.IdField   = "NO_DISPLAY_ProductCategoryId";//This procedure is also used with data grid.
            this.ddCategory.IntroText = "<select category>";
            this.ddCategory.Fill();

            //if(ddCategory.SelectedIndex > 0)
            //{
            //	this.ddSubCategory.SQL       = "spGetOTCProductSubCategoryByCategoryBySiteId @OTCSiteId = " + dz.SiteId + ",@OTCProductId = " + this.ddCategory.SelectedValue;
            //	this.ddSubCategory.TextField = "ProductSubCategoryDescription";
            //	this.ddSubCategory.IdField   = "OTCProductSubCategoryId";//This procedure is also used with data grid.
            //	this.ddSubCategory.IntroText = "<select sub category>";
            //	this.ddSubCategory.Fill();
            //}

            //this.lstColors.SQL       = "spGetOTCProductFeatureByFeatureType @OTCProductFeatureTypeId = 1";
            //this.lstColors.TextField = "FeatureLongDescription";
            //this.lstColors.IdField   = "OTCProductFeatureId";
            //this.lstColors.Fill();

            //this.lstSizes.SQL       = "spGetOTCProductFeatureByFeatureType @OTCProductFeatureTypeId = 2";
            //this.lstSizes.TextField = "FeatureLongDescription";
            //this.lstSizes.IdField   = "OTCProductFeatureId";
            //this.lstSizes.Fill();
        }
Пример #4
0
        //============================
        //
        //============================
        public void DrawProducts()
        {
            OTCGrid grid;
            ITC dz = new ITC();
            DataTable dt   = OTCProduct.GetProducts(dz.SiteId);
            DataRow[] rows = dt.Select("NO_DISPLAY_ProductName LIKE '" + this.m_sortChar.ToString() + "*'");

            if(rows.Length > 0)
                grid = new OTCGrid(OTCGrid.GetDataTableFromArray(rows));
            else
                grid = new OTCGrid(dt);

            grid.Draw();
        }
Пример #5
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //if(this.ddVendors.SelectedIndex == 0 || this.ddSubCategory.SelectedIndex == 0 || this.ddCategory.SelectedIndex == 0)
            //	return;

            ITC dz                = new ITC();
            HttpPostedFile file   = filePhoto.PostedFile;
            //HttpPostedFile thumb  = ""; //thumbNail.PostedFile;
            string savePath       = Request.PhysicalApplicationPath + "images\\product\\";
            string thumbPath	  = Request.PhysicalApplicationPath + "images\\product\\ThumbNail\\";
            OTCProduct product    = Convert.ToInt32(this.txtProductId.Value) > 0 ? new OTCProduct(Convert.ToInt32(this.txtProductId.Value)) : new OTCProduct();
            product.OTCSiteId	  = dz.SiteId;
            product.CategoryId    = Convert.ToInt32(this.ddCategory.SelectedValue);
            product.IsActive      = true; //this.chkActive.Checked;
            product.IsFeatured    = false; //this.chkFeaturedItem.Checked;
            product.ShippingDetails = ""; //this.txtShippingDetails.Value;
            product.Price         = Convert.ToDouble(this.txtPrice.Text);
            product.Discount	  = 0.0; //Convert.ToDouble(this.txtDiscount.Text);
            product.ProductDescription = this.txtDescription.Value;
            product.ProductName   = this.txtProductName.Text;
            product.ShippingPrice = 0.00;//Convert.ToDouble(this.txtShippingCosts.Text);
            product.SubCategoryId = 0;//Convert.ToInt32(this.ddSubCategory.SelectedValue);
            product.VendorId      = 89; //Convert.ToInt32(this.ddVendors.SelectedValue);
            product.SKU           = this.txtSku.Text;

            if(product.ProductId > 0)
            {
                product.Save();
                if(file.FileName.Length > 0)
                {
                    int extensionStart = file.FileName.LastIndexOf(".");
                    int extensionEnd   = file.FileName.Length - extensionStart;
                    string extension   = file.FileName.Substring(extensionStart,extensionEnd);
                    product.ImageName  = product.ProductId + extension;
                    product.Save();
                    file.SaveAs(savePath + product.ProductId + extension);
                }
            }
            else
            {
                if(!(file.FileName.Length > 0))
                {
                    product.ImageName = ".jpeg";
                    product.Add();
                }
                else
                {
                    int extensionStart = file.FileName.LastIndexOf(".");
                    int extensionEnd   = file.FileName.Length - extensionStart;
                    string extension   = file.FileName.Substring(extensionStart,extensionEnd);
                    product.ImageName = extension;
                    int productId = product.Add();
                    file.SaveAs(savePath + productId + extension);
                }
            }

            //
            //if(thumb.FileName.Length > 0)
            //{
            //	int extensionStart = thumb.FileName.LastIndexOf(".");
            //	int extensionEnd   = thumb.FileName.Length - extensionStart;
            //	string extension   = thumb.FileName.Substring(extensionStart,extensionEnd);
            //	thumb.SaveAs(thumbPath + product.ProductId + extension);
            //}

            product.DeleteProductFeatures(); //remove all features and add them again.

            //foreach(ListItem item in this.lstColors.Items){
            //	if(item.Selected)
            //		product.AddProductFeature(Convert.ToInt32(item.Value));
            //}

            //foreach(ListItem item in this.lstSizes.Items){
            //	if(item.Selected)
            //		product.AddProductFeature(Convert.ToInt32(item.Value));
            //}

            Response.Redirect("Product.aspx?PID=" + product.ProductId + "&sort=1&char=" + this.txtSortChar.Value);
        }