protected void Page_Load(object sender, EventArgs e)
    {
        if (this.CurrentCart == null) throw new CartException("Could not load cart data");

        if (this.CurrentCart.Completed == false)
        {
            CartDB db = new CartDB();
            db.CartUpdateCompleted(CurrentCart.CartId, true);
        db.CartDeleteAllByUserID(CurrentCart.UserId);
        confirmation = true;
        orderid = Session["orderpoid"].ToString();
        }

        if (!CartUsers.IsUserLoggedIn(Session))
        {
            CreateAccountPanel.Visible = true;
        }
        if (Session["SAPER"] != null)
        {
            if (Convert.ToBoolean(Session["SAPER"]) != false)
            {
                StudentVerificationPanel.Visible = true;
            }
        }
        Session["SAPER"] = null;
    }
    protected void ContinueButton_Clicked(object sender, EventArgs e)
    {
        bool success = false;
        string check= Convert.ToString(ShippingOptionRadio.SelectedValue);
        int shipping_option;
        if (check != "")
        {
            if (Int32.TryParse(ShippingOptionRadio.SelectedValue, out shipping_option))
            {
                success = true;
            }

            if (success)
            {
                CartDB db = new CartDB();
                if (db.CartUpdateShippingOption(CurrentCart.CartId, shipping_option))
                {
                    CurrentCart.MoveNextStep();
                    Response.Redirect(Constants.Pages.CHECKOUT);
                }
            }
        }
        else {
            checkthis = true;
        }
    }
 public void NavigateFunc()
 {
     if (getName == null)
     {
         Navigation.PushAsync(new CartPage());
     }
     else
     {
         var      getUsername = Convert.ToString(Application.Current.Properties["USERNAME"]);
         CartDB   cartDB      = new CartDB();
         string[] exPrice     = getPrice.Split('.');
         int      total       = Convert.ToInt32(exPrice[1]);
         cartDB.Username = getUsername;
         cartDB.Name     = getName;
         cartDB.Price    = getPrice;
         cartDB.Qty      = getQuantity.ToString();
         cartDB.Total    = (getQuantity * total).ToString();
         cartDB.Image    = getImage;
         CartQuery cartQuery = new CartQuery();
         var       i         = cartQuery.InsertDetails(cartDB);
         if (i > 0)
         {
             Navigation.PushAsync(new CartPage());
         }
         else
         {
             DisplayAlert("Issue", "Something went wrong..", "Ok");
         }
     }
 }
 protected void DeleteButton_Clicked(object sender, EventArgs e)
 {
     CartDB db = new CartDB();
     if (db.LoginDeleteAddress(Address.LoginAddressID))
     {
         this.Controls.Clear();
         Response.Redirect("checkout.aspx");
     }
 }
 protected bool UpdateOrderPOPayment(string po_number, string po_filename, byte[] po_file_upload,string potype)
 {
     if(CurrentCart.Payment.ORD_PAYMENT_ID != 0)
     {
         CartDB db = new CartDB();
         return db.Order_Update_POPayment(CurrentCart.Payment.ORD_PAYMENT_ID, po_number, po_filename, po_file_upload, po_file_upload != null && po_file_upload.Length > 0 ? 1 : 0, potype);
     }
     return false;
 }
 protected void PrintPOButton_Clicked(object sender, EventArgs e)
 {
     string ponumber = PONumberTextbox.Text;
     CartDB db = new CartDB();
     if (db.CartUpdatePayment(CurrentCart.PaymentId, CurrentCart.CartId, PaymentType.PO, "", "", "", "", "", ponumber, "[FAX]", null))
     {
         UpdateOrderPOPayment(ponumber, "[FAX]", null,"");
         MoveToThankYou();
     }
 }
    protected void CheckoutButton_Clicked(object sender, EventArgs e)
    {
        if (Session[Constants.SessionKeys.SUMMARY_EDIT] != null && (bool)Session[Constants.SessionKeys.SUMMARY_EDIT] == true)
        {
        Session.Remove(Constants.SessionKeys.SUMMARY_EDIT);
        CartDB db = new CartDB();
        db.CartUpdateDirty(CurrentCart.CartId, true);
        CurrentCart.MoveToStep(Constants.CheckoutStep.Summary);
        Response.Redirect(Constants.Pages.CHECKOUT);
        return;
        }

        CurrentCart.MoveToStep(0);
        Response.Redirect(Constants.Pages.CHECKOUT);
    }
    protected void ItemsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (Helper.StringExists(e.CommandName))
        {
            GridViewRow row = (GridViewRow)((Control)e.CommandSource).Parent.Parent;
            DataTable dt = BuildDataSource(CurrentCart.Items);
            DataRow dr = dt.Rows[row.RowIndex];

            int cart_contents_id = (int)dr["CartItemId"];

            CartDB db = new CartDB();
            if (e.CommandName == "AddToWishlist")
            {
                //Response.Write("Adding to Wishlist: " + dr["CartItemId"].ToString());
                throw new NotImplementedException("Add To Wishlist Not Implemented");
            }
            else if (e.CommandName == "UpdateQuantity")
            {
                Control c = row.FindControl("QtyTextbox");
                if (c != null && c.GetType().Equals(typeof(TextBox)))
                {
                    TextBox t = (TextBox)c;
                    int quantity;
                    if (Int32.TryParse(t.Text, out quantity))
                    {
                        // Update Quantity
                        // If 0, Remove
                        if (quantity > 0)
                        {
                            decimal subtotal = (decimal)dr["UnitPrice"] * quantity;

                            db.CartUpdateItemQuantity(cart_contents_id, quantity, subtotal);
                        }
                        else
                        {
                            db.CartDeleteItem(cart_contents_id);
                        }
                    }
                }
            }
            else if (e.CommandName == "RemoveItem")
            {
                db.CartDeleteItem(cart_contents_id);
            }
            Response.Redirect(Constants.Pages.CART);
        }
    }
    private bool AddItemToCart(int title_id, string sku, int quantity, out AddResponse result)
    {
        result = AddResponse.Failure;

        bool success = false; //Duncan Working
        CartDB db = new CartDB();

        DataSet ds = db.CartProductGetBySKU(sku);
        if (ds == null) return false;

        bool is_bulk = false, is_student = false;

        using (DataTableReader data = ds.CreateDataReader())
        {
            while (data.Read())
            {
                is_bulk = data.GetInt32(data.GetOrdinal("IsBulk")) == 1;
                is_student = data.GetInt32(data.GetOrdinal("IsStudent")) == 1;
                break;
            }
        }

        if (is_bulk)
        {
            result |= AddResponse.Bulk;
            return false;
        }

        success = db.CartAddSKU(CurrentCart.CartId, sku, quantity);

        if (success)
        {
            result = AddResponse.Success;
        }

        if (is_student)
        {
            result |= AddResponse.Student;
        }

        return success;
    }
 public void Add_btn_Clicked(object sender, EventArgs e)
 {
     if (Application.Current.Properties.ContainsKey("USERNAME"))
     {
         var getUserName = Convert.ToString(Application.Current.Properties["USERNAME"]);
         if (getUserName.Equals("As Guest"))
         {
             int quantity1 = Convert.ToInt32(Qty.Text);
             Navigation.PushAsync(new LoginPage(selImage, Name.Text, Price.Text, quantity1));
         }
         else
         {
             var      getUsername = Convert.ToString(Application.Current.Properties["USERNAME"]);
             CartDB   cartDB      = new CartDB();
             int      quantity    = Convert.ToInt32(Qty.Text);
             string[] exPrice     = Price.Text.Split('.');
             int      total       = Convert.ToInt32(exPrice[1]);
             cartDB.Username = getUsername;
             cartDB.Name     = Name.Text;
             cartDB.Price    = Price.Text;
             cartDB.Qty      = quantity.ToString();
             cartDB.Total    = (quantity * total).ToString();
             cartDB.Image    = selImage;
             CartQuery cartQuery = new CartQuery();
             var       i         = cartQuery.InsertDetails(cartDB);
             if (i > 0)
             {
                 Navigation.PushAsync(new CartPage());
             }
             else
             {
                 DisplayAlert("Issue", "Something went wrong..", "Ok");
             }
         }
     }
 }
    protected void CreditCardButton_Clicked(object sender, EventArgs e)
    {
        ShowCreditCardDiv();

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

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

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

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

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

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

        if (success)
        {
            CurrentCart.MoveNextStep();
            Response.Redirect(Constants.Pages.CHECKOUT);
        }
    }
    protected void ContinueButton_Clicked(object sender, EventArgs e)
    {
        bool success = false;

        if(Page.IsValid){

           int login_Uid = CartUsers.GetLoginID();
           CartLocation BillLocation = null;
           BillLocation = CartLocation.GetBillingLocationByUserID(login_Uid);

        CartDB db = new CartDB();
        db.CartDeleteAllLocations(CurrentCart.CartId);

        string BillingBusinessName = BillingBusinessNameTextbox.Text;
        string BillingFullName = BillingFullnameTextbox.Text;
        string BillingAddress1 = BillingAddressLine1Textbox.Text;
        string BillingAddress2 = BillingAddressLine2Textbox.Text;
        string BillingCity = BillingCityTextbox.Text;
        string BillingStateCode = BillingStateDropdown.SelectedValue;
        string BillingPostalCode = BillingPostalCodeTextbox.Text;
        string BillingPhone = BillingPhoneTextbox.Text;
        string BillingEmail = BillingEmailTextbox.Text;
        string BillingEmailConfirmation = BillingEmailConfirmationTextbox.Text;

        string ShippingBusinessName = ShippingBusinessNameTextbox.Text;
        string ShippingFullName = ShippingFullnameTextbox.Text;
        string ShippingAddress1 = ShippingAddressLine1Textbox.Text;
        string ShippingAddress2 = ShippingAddressLine2Textbox.Text;
        string ShippingCity = ShippingCityTextbox.Text;
        string ShippingStateCode = ShippingStateDropdown.SelectedValue;
        string ShippingPostalCode = ShippingPostalCodeTextbox.Text;
        string ShippingPhone = ShippingPhoneTextbox.Text;

        int address_book_id;
        if (Helper.StringExists(ShippingAddressBookLocationID.Value) && Int32.TryParse(ShippingAddressBookLocationID.Value, out address_book_id))
        {
            LoginAddress address = LoginAddress.GetAddressFromLoginAddressID(address_book_id);
            if (address != null && address.LoginID == CartUsers.GetLoginID())
            {
                db.LoginUpdAddress(address.LoginAddressID, address.LoginID, ShippingBusinessName, ShippingFullName, ShippingAddress1, ShippingAddress2, ShippingCity, ShippingStateCode, "", ShippingPostalCode, CountryCode,ShippingPhone, 0);
            }
        }
        try
        {
            Session["UTitle"] = BillLocation.UTitle;
            Session["AreaCode"] = BillLocation.AreaCode;
            Session["PhoneExt"] = BillLocation.PhoneExt;
            Session["Fax"] = BillLocation.Fax;
        }
        catch (Exception erro)
        {
            Session["UTitle"] = "";
            Session["AreaCode"] = "";
            Session["PhoneExt"] = "";
            Session["Fax"] = "";
        }
        try
        {
            success = db.CartAddLocation(CurrentCart.CartId, CartDB.LocationType.Billing, BillingBusinessName, BillingFullName, BillingAddress1, BillingAddress2, BillingCity, BillingStateCode, BillingPostalCode, CountryCode, BillingPhone, BillingEmail, BillLocation.UTitle, BillLocation.AreaCode, BillLocation.PhoneExt, BillLocation.Fax);
            success = db.CartAddLocation(CurrentCart.CartId, CartDB.LocationType.Shipping, ShippingBusinessName, ShippingFullName, ShippingAddress1, ShippingAddress2, ShippingCity, ShippingStateCode, ShippingPostalCode, CountryCode, ShippingPhone, "", BillLocation.UTitle, BillLocation.AreaCode, BillLocation.PhoneExt, BillLocation.Fax);
        }
        catch (Exception cartErr)
        {
            success = db.CartAddLocation(CurrentCart.CartId, CartDB.LocationType.Billing, BillingBusinessName, BillingFullName, BillingAddress1, BillingAddress2, BillingCity, BillingStateCode, BillingPostalCode, CountryCode, BillingPhone, BillingEmail,"","", "", "");
            success = db.CartAddLocation(CurrentCart.CartId, CartDB.LocationType.Shipping, ShippingBusinessName, ShippingFullName, ShippingAddress1, ShippingAddress2, ShippingCity, ShippingStateCode, ShippingPostalCode, CountryCode, ShippingPhone, "", "", "", "", "");
        }

        if (success)
        {

            if (Session[Constants.SessionKeys.SUMMARY_EDIT] != null && (bool)Session[Constants.SessionKeys.SUMMARY_EDIT] == true)
            {
                Session.Remove(Constants.SessionKeys.SUMMARY_EDIT);
                db.CartUpdateDirty(CurrentCart.CartId, true);
                CurrentCart.MoveToStep(Constants.CheckoutStep.Summary);
                Response.Redirect(Constants.Pages.CHECKOUT);
                return;
            }

            CurrentCart.MoveNextStep();
            Response.Redirect(Constants.Pages.CHECKOUT);
        }
        }
    }
    protected void SaveLocationButton_Clicked(object sender, EventArgs e)
    {
        string ShippingBusinessName = ShippingBusinessNameTextbox.Text;
        string ShippingFullName = ShippingFullnameTextbox.Text;
        string ShippingAddress1 = ShippingAddressLine1Textbox.Text;
        string ShippingAddress2 = ShippingAddressLine2Textbox.Text;
        string ShippingCity = ShippingCityTextbox.Text;
        string ShippingStateCode = ShippingStateDropdown.SelectedValue;
        string ShippingPostalCode = ShippingPostalCodeTextbox.Text;
        string ShippingPhone = ShippingPhoneTextbox.Text;

        CartDB db = new CartDB();

        bool success = false;

        int address_book_id;
        if (Helper.StringExists(ShippingAddressBookLocationID.Value) && Int32.TryParse(ShippingAddressBookLocationID.Value, out address_book_id))
        {
            LoginAddress address = LoginAddress.GetAddressFromLoginAddressID(address_book_id);
            if (address != null && address.LoginID == CartUsers.GetLoginID())
            {
                if (db.LoginUpdAddress(address.LoginAddressID, address.LoginID, ShippingBusinessName, ShippingFullName, ShippingAddress1, ShippingAddress2, ShippingCity, ShippingStateCode, "", ShippingPostalCode, CountryCode, ShippingPhone, 0))
                {
                    success = true;
                }
            }
        }
        else
        {
            int login_address_id;
            if (db.LoginAddAddress(CartUsers.GetLoginID(), ShippingBusinessName, ShippingFullName, ShippingAddress1, ShippingAddress2, ShippingCity, ShippingStateCode, "", ShippingPostalCode, CountryCode,ShippingPhone, out login_address_id))
            {
                ShippingAddressBookLocationID.Value = login_address_id.ToString();
                success = true;
            }
        }

        if (success)
        {
            //MessagePanel.Controls.Add(new LiteralControl("Address Saved"));
            MessagePanel.Controls.Add(new LiteralControl("<div style='margin: 0; float: right;'><img src='images/AddressSaved.jpg' alt='Adress saved'></div>"));
            PopulateAddressBook();
            Session["RedirectFromSaveAddress"] = "yes";
            string sbn=ShippingBusinessNameTextbox.Text;
            string sfn=ShippingFullnameTextbox.Text;
            string saa=ShippingAddressLine1Textbox.Text;
            string sab=ShippingAddressLine2Textbox.Text;
            string sct=ShippingCityTextbox.Text;
            string ssd=ShippingStateDropdown.Text;
            string spc=ShippingPostalCodeTextbox.Text;
            string spt=ShippingPhoneTextbox.Text;
            Response.Redirect("checkout.aspx"+"?sbn=" + sbn +"&sfn=" + sfn +"&saa=" + saa +"&sab=" + sab +"&sct=" + sct +"&ssd=" + ssd +"&spc=" + spc +"&spt=" +spt +"");
            // For testing only
            //Response.Redirect("http://webtest.edresources.com:8080/checkout.aspx");

        }
    }
示例#15
0
    public decimal CalculateCartTaxRate(Cart CurrentCart)
    {
        CartDB db = new CartDB();
        if (CurrentCart.BillingLocation != null)
        {
            return db.CartGetTaxFromLocation(CurrentCart.SiteId, CurrentCart.BillingLocation.CountryCode,

        CurrentCart.BillingLocation.StateCode, CurrentCart.BillingLocation.PostalCode);
        }
        else
        {
            return (decimal)0;
        }
    }
示例#16
0
    public static LoginAddress GetAddressFromLoginAddressID(int login_address_id)
    {
        CartDB db = new CartDB();
        DataSet ds = db.LoginGetAddress(login_address_id);
        if (ds != null)
        {
            using (DataTableReader data = ds.CreateDataReader())
            {
                while (data.Read())
                {
                    int loginaddressid = data.GetInt32(data.GetOrdinal("LoginAddressID"));
                    int loginid = data.GetInt32(data.GetOrdinal("LoginID"));
                    string addressname = Helper.IsString(data.GetValue(data.GetOrdinal("AddressName")), "");
                    string bldgname = Helper.IsString(data.GetValue(data.GetOrdinal("BldgName")), "");
                    string address1 = Helper.IsString(data.GetValue(data.GetOrdinal("Address1")), "");
                    string address2 = Helper.IsString(data.GetValue(data.GetOrdinal("Address2")), "");
                    string city = Helper.IsString(data.GetValue(data.GetOrdinal("City")), "");
                    string statecode = Helper.IsString(data.GetValue(data.GetOrdinal("StateCode")), "");
                    string province = Helper.IsString(data.GetValue(data.GetOrdinal("Province")), "");
                    string zip = Helper.IsString(data.GetValue(data.GetOrdinal("Zip")), "");
                    string countrycode = Helper.IsString(data.GetValue(data.GetOrdinal("CountryCode")), "");
                    string phone = Helper.IsString(data.GetValue(data.GetOrdinal("Phone")), "");

                    return new LoginAddress(loginaddressid, loginid, addressname, bldgname, address1, address2, city, statecode, province, zip, countrycode,phone);
                }
            }
        }
        return null;
    }
示例#17
0
    protected void UploadPOButton_Clicked(object sender, EventArgs e)
    {
        string filename = "";
        string ponumber = PONumberTextbox.Text;
        string potype = "";

        byte[] content = DoUpload(out filename);

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

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

        if (content != null)
        {
            CartDB db = new CartDB();
            if (db.CartUpdatePayment(CurrentCart.PaymentId, CurrentCart.CartId, PaymentType.PO, "", "", "", "", "", ponumber, filename, content))
            {
                //Response.Write(String.Format("SUCCESS UPLOADING FILE {0} OF {1} BYTES LENGTH", filename, content.Length));
                UpdateOrderPOPayment(ponumber, filename, content,potype);
                MoveToThankYou();
            }
        }
    }
示例#18
0
    public static CartLocation GetBillingLocationByUserID(int user_id)
    {
        CartDB db = new CartDB();
        DataSet ds = db.LoginGetBillingAddress(user_id);

        if (ds != null)
        {
            using (DataTableReader data = ds.CreateDataReader())
            {
                if (data.Read())
                {
                    int locationid = 0;
                    int cartid = 0;
                    int locationtype = 0;
                    string businessname = Helper.IsString(data.GetValue(data.GetOrdinal("BldgName")), "");
                    string fullname = Helper.IsString(data.GetValue(data.GetOrdinal("FullName")), "");
                    string address1 = Helper.IsString(data.GetValue(data.GetOrdinal("Address1")), "");
                    string address2 = Helper.IsString(data.GetValue(data.GetOrdinal("Address2")), "");
                    string city = Helper.IsString(data.GetValue(data.GetOrdinal("City")), "");
                    string statecode = Helper.IsString(data.GetValue(data.GetOrdinal("State")), "");
                    string postalcode = Helper.IsString(data.GetValue(data.GetOrdinal("Zip")), "");
                    string countrycode = Helper.IsString(data.GetValue(data.GetOrdinal("Country")), "");
                    string phone = Helper.IsString(data.GetValue(data.GetOrdinal("Phone")), "");
                    string email = Helper.IsString(data.GetValue(data.GetOrdinal("Email")), "");
                    DateTime datecreated = DateTime.Now;
                    DateTime lastupdated = DateTime.Now;

                    string Title = Helper.IsString(data.GetValue(data.GetOrdinal("Title")), "");
                    string AreaCode = Helper.IsString(data.GetValue(data.GetOrdinal("AreaCode")), "");
                    string PhoneExt = Helper.IsString(data.GetValue(data.GetOrdinal("PhoneExt")), "");
                    string Fax = Helper.IsString(data.GetValue(data.GetOrdinal("Fax")), "");
                    return new CartLocation(locationid, cartid, locationtype, businessname, fullname, address1, address2, city, statecode, postalcode, countrycode, phone, email, datecreated, lastupdated, Title, AreaCode, PhoneExt, Fax);
                }
            }
        }

        return null;
    }
示例#19
0
    public static CartItem[] GetCartItemsByCartID(int cart_id)
    {
        List<CartItem> items = new List<CartItem>();

        CartDB db = new CartDB();
        DataSet ds = db.CartGetAllItems(cart_id);

        if (ds != null)
        {
            using (DataTableReader data = ds.CreateDataReader())
            {
                while (data.Read())
                {
                    int cartitemid = data.GetInt32(data.GetOrdinal("CartContentsId"));
                    int cartid = data.GetInt32(data.GetOrdinal("CartId"));
                    int producttitleid = data.GetInt32(data.GetOrdinal("ProductTitleId"));
                    string productsku = data.GetString(data.GetOrdinal("ProductSKU"));
                    int quantity = data.GetInt32(data.GetOrdinal("Quantity"));
                    decimal unitprice = data.GetDecimal(data.GetOrdinal("UnitPrice"));
                    decimal subtotal = data.GetDecimal(data.GetOrdinal("SubTotal"));
                    int linenumber = data.GetInt32(data.GetOrdinal("LineNumber"));
                    bool is_student = (int)data.GetValue(data.GetOrdinal("IsStudent")) == 1;
                    bool is_bulk = (int)data.GetValue(data.GetOrdinal("IsBulk")) == 1;
                    DateTime datecreated = data.GetDateTime(data.GetOrdinal("DateCreated"));
                    DateTime lastupdated = data.GetDateTime(data.GetOrdinal("LastUpdated"));

                    CartItem item = new CartItem(cartitemid, cartid, producttitleid, productsku, quantity, unitprice, subtotal, linenumber,is_bulk, is_student, datecreated, lastupdated);
                    items.Add(item);
                }
            }
        }

        return items.ToArray();
    }
示例#20
0
    public void Refresh(CartRefreshMethod type)
    {
        CartDB db = new CartDB();
        DataSet cart_data = null;

        switch(type)
        {
            case CartRefreshMethod.UniqueID:
                cart_data = db.GetCartFromGuid(this._UniqueId);
                break;
            case CartRefreshMethod.CartID:
                if (this._CartId > 0)
                {
                    cart_data = db.GetCartFromCartID(this._CartId);
                }
                break;
            case CartRefreshMethod.UserID:
                if (this._SiteId > 0 && this._UserId != null)
                {
                    cart_data = db.GetCartFromUserID(this._SiteId, this._UserId);
                }
                break;
        }

        this._populate_cart_from_dataset(cart_data);
    }
示例#21
0
 public void Clean()
 {
     if (this.IsLoaded)
     {
         CartDB db = new CartDB();
         db.CleanCart(this);
         Refresh();
     }
 }
示例#22
0
    public static Cart GetCartFromSession(HttpSessionState Session)
    {
        Cart cart = null;
        int site_id;
        bool logged_in = CartUsers.IsUserLoggedIn(Session);
        string user_id = logged_in ? CartUsers.GetUserName(Session) : "";
        if (Session[Constants.SessionKeys.SITE_ID] != null)
        {
            if (Int32.TryParse((string)Session[Constants.SessionKeys.SITE_ID], out site_id) == false)
            {
                throw new CartException("Could not find SiteID in current session");
            }
        }
        else
        {
            throw new CartException("Could not find SiteID in current session");
        }

        // This is a three step process
        // We do this because the current context of the shopping cart, should always override the saved context of the shopping cart.
        // This makes most sense in this scenario:
        /* So say you were browsing the site without logging in, and you've added a bunch of items to your cart.
           Now, you don't hit checkout or anything, but instead decide to log in to your account you remember you had.
           Should the cart you just created override any existing (saved) cart in the user account? */

        // 0. If a user is logged in, and the current session doesn't have any items in it, and a saved session exists, use it.
        if (logged_in)
        {
            cart = Cart.GetCartByUserID(site_id, Session.SessionID);
            if (cart != null && cart.IsLoaded && cart.HasItems == false)
            {
                cart = Cart.GetCartByUserID(site_id, user_id);
                if (cart != null && cart.IsLoaded)
                {
                    return cart;
                }
            }
        }

        // 1. If one exists in the current session, and it actually has items in it, use it. In this case, if the username has not been updated, update it.
        cart = Cart.GetCartByUserID(site_id, Session.SessionID);
        if (cart != null && cart.IsLoaded)
        {
            if (logged_in && cart.UserId == Session.SessionID)
            {
                CartDB db = new CartDB();
                db.CartUpdateUserId(cart.CartId, user_id);
            }
            cart.Refresh();
            return cart;
        }

        // 2. If this is not the case, try loading from the user id.
        if (logged_in)
        {
            cart = Cart.GetCartByUserID(site_id, user_id);
            if (cart != null && cart.IsLoaded)
            {
                return cart;
            }
        }

        // 3. If we still do not have one, just create a new one. If logged in, use the current username, if not, use the session id
        cart = Cart.CreateNew(site_id, logged_in ? user_id : Session.SessionID);
        if (cart != null && cart.IsLoaded)
        {
            return cart;
        }

        throw new CartException("Could not retrieve a cart from the current session");
    }
示例#23
0
    public static Cart CreateNew(int site_id, string user_id)
    {
        CartDB db = new CartDB();

        if (db.CartCreate(site_id, user_id))
        {
            return Cart.GetCartByUserID(site_id, user_id);
        }

        throw new CartException("Could not create cart");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.IsSecureConnection != false)
        {
            string redirect = Request.Url.ToString().Replace("https://", "http://");
            Response.Redirect(redirect);
            return;
        }

        try
        {
            string Torch_Order_Detail = "";
            //-- Left Menu Active
            if (Request.QueryString["am"] != null && Request.QueryString["am"] != "")
            {
                try { SiteConstants.LeftMenuActive = Convert.ToInt32(Request.QueryString["am"].ToString()); }
                catch { SiteConstants.LeftMenuActive = 4; }
            }
            else { SiteConstants.LeftMenuActive = 4; }
            //--
            SetChildPage("cart.aspx");
            this.CurrentCart = Cart.GetCartFromSession(Session);

            if (this.CurrentCart.CheckoutStep >= (int)Constants.CheckoutStep.ThankYou)
            {
                CartDB db = new CartDB();
                db.CartUpdateCompleted(this.CurrentCart.CartId, true);
                db.CartDeleteAllByUserID(this.CurrentCart.UserId);
                Response.Redirect("cart.aspx");
            }

            if (this.CurrentCart.Dirty) this.CurrentCart.Clean();

            CartDisplayPanel.Visible = this.CurrentCart.HasItems;
            CartEmptyPanel.Visible = !CartDisplayPanel.Visible;
            StudentItemMessagePanel.Visible = CartEmptyPanel.Visible == false && this.CurrentCart.HasStudentItems;

            DebugPanel.Controls.Add(new LiteralControl(Helper.VarDump(CurrentCart)));
            if (CurrentCart.ItemsWeight > 100)
            {
                overweigth = true;
            }
            DebugPanel.Visible = false;

            //ItemsGrid.RowCommand += new GridViewCommandEventHandler(ItemsGrid_RowCommand);
            //ItemsGrid.RowDataBound += new GridViewRowEventHandler(ItemsGrid_RowDataBound);

            ItemsList.ItemDataBound += new RepeaterItemEventHandler(ItemsList_ItemDataBound);
            ItemsList.ItemCommand += new RepeaterCommandEventHandler(ItemsList_ItemCommand);

            string SocialTwistScript = "<div style='width: 100px; float: right; margin-top: -20px;margin-right:12px;'>" + Global.globalSocialTwist + "</a></div>";
            string link = String.Format("http://"+Request.Url.Host.ToString()+"/cart_share.aspx?id={0}", CurrentCart.UniqueId.ToString());
            CartDisplayPanel.Controls.AddAt(0, new LiteralControl(SocialTwistScript.Replace("window.location", "'"+link+"'")));

            LoadControls();

            if (CartDisplayPanel.Visible)
            {
                this.BindData(CurrentCart.Items);
            }

            Page.RegisterStartupScript("RegisterControls", String.Format(" <script type='text/javascript'>{0}</script>", Helper.GenerateScriptToAccessControls(Page.Controls)));
            //Helper.MakeGridViewAccessible(ref ItemsGrid);
        }
        catch (CartException ex)
        {
            Response.Write("exception!" + ex.Message);
            this.DisplayMessage(ex.Message);
            CartDisplayPanel.Visible = false;
            CartEmptyPanel.Visible = false;
            StudentItemMessagePanel.Visible = false;
        }
        if (completeNames == "")
        {
            QuoteThisButton.Visible = false;
        }
        else {
            QuoteThisButton.Visible = true;
        }
    }
示例#25
0
    public static CartLocation GetCartLocationByLocationID(int location_id)
    {
        CartDB db = new CartDB();
        DataSet ds = db.GetLocationFromLocationId(location_id);

        if (ds != null)
        {
            using (DataTableReader data = ds.CreateDataReader())
            {
                if (data.Read())
                {
                    int locationid = data.GetInt32(data.GetOrdinal("LocationId"));
                    int cartid = data.GetInt32(data.GetOrdinal("CartId"));
                    int locationtype = data.GetInt32(data.GetOrdinal("LocationType"));
                    string businessname = Helper.IsString(data.GetValue(data.GetOrdinal("BusinessName")), "");
                    string fullname = Helper.IsString(data.GetValue(data.GetOrdinal("FullName")), "");
                    string address1 = Helper.IsString(data.GetValue(data.GetOrdinal("Address1")), "");
                    string address2 = Helper.IsString(data.GetValue(data.GetOrdinal("Address2")), "");
                    string city = Helper.IsString(data.GetValue(data.GetOrdinal("City")), "");
                    string statecode = Helper.IsString(data.GetValue(data.GetOrdinal("StateCode")), "");
                    string postalcode = Helper.IsString(data.GetValue(data.GetOrdinal("PostalCode")), "");
                    string countrycode = Helper.IsString(data.GetValue(data.GetOrdinal("CountryCode")), "");
                    string phone = Helper.IsString(data.GetValue(data.GetOrdinal("Phone")), "");
                    string email = Helper.IsString(data.GetValue(data.GetOrdinal("Email")), "");
                    DateTime datecreated = data.GetDateTime(data.GetOrdinal("DateCreated"));
                    DateTime lastupdated = data.GetDateTime(data.GetOrdinal("LastUpdated"));
                    string Title = "";// CompletedCart.BillingLocation.UTitle;
                    string AreaCode =""; //CompletedCart.BillingLocation.AreaCode;
                    string PhoneExt = "";//CompletedCart.BillingLocation.PhoneExt;
                    string Fax = "";//CompletedCart.BillingLocation.Fax;

                    return new CartLocation(locationid, cartid, locationtype, businessname, fullname, address1, address2, city, statecode, postalcode, countrycode, phone,
                        email, datecreated, lastupdated, Title, AreaCode, PhoneExt, Fax);
                }
            }
        }

        return null;
    }
    private DataTable BuildDataSource(CartItem[] items)
    {
        DataTable dt = CreateDataSource();
        CartDB db = new CartDB();

        foreach (CartItem item in items)
        {
            string title = "", pubname = "", puburl = "";

            DataSet ds = db.CartProductGetBySKU(item.ProductSKU);
            if (ds != null)
            {
                using (DataTableReader dtr = ds.CreateDataReader())
                {
                    while (dtr.Read())
                    {

                        title = Helper.IsString(dtr.GetValue(dtr.GetOrdinal("Title")), "");

                        pubname = Helper.IsString(dtr.GetValue(dtr.GetOrdinal("PubName")), "");

                        puburl = Helper.IsString(dtr.GetValue(dtr.GetOrdinal("PubUrl")), "");
                    }
                    dtr.Close();
                }
            }

            DataRow row = dt.NewRow();
            row["CartItemId"] = item.CartItemId;
            row["ProductTitleId"] = item.ProductTitleId;
            row["ProductSKU"] = item.ProductSKU;
            row["Title"] = "<a href=\"product.aspx?p=" + item.ProductTitleId + "&s=" + item.ProductSKU + "\">" + title + "</a>";
            completeNames += title + "|";
            row["PubName"] = pubname;
            row["PubURL"] = puburl;
            row["Quantity"] = item.Quantity;
            completeQty += item.Quantity.ToString()+"|";
            row["UnitPrice"] = item.UnitPrice;
            row["SubTotal"] = item.SubTotal;
            row["UnitPriceDollar"] = Helper.Dollar(item.UnitPrice);
            row["SubTotalDollar"] = Helper.Dollar(item.SubTotal);
            dt.Rows.Add(row);
        }

        dt.AcceptChanges();
        return dt;
    }
    protected void ContinueButton_Clicked(object sender, EventArgs e)
    {
        string cont = "";// Request["emailTo"].ToString();

        sendEmail send = new sendEmail();

        bool success = true;
        int orderIdEmail = 0;
        // Submit Order

        CartDB db = new CartDB();
        if (CurrentCart.Completed == false)
        {
            int order_id, payment_id;
            success = db.Order_Post_Cart(CurrentCart, CartUsers.GetLoginID(), SalesRepFlagCheckbox.Checked ? 1 : 0, out order_id, out payment_id,Convert.ToString(SumaryComents.Value));
            success = db.CartUpdatePaymentOrderIDs(CurrentCart.PaymentId, order_id, payment_id);
            if (Session["TorchInCart"] != null && bool.Parse(Session["TorchInCart"].ToString()) == true)
            {
                ArrayList listSkusDesc = new ArrayList();
                ArrayList listSkus = new ArrayList();
                int orderId = Convert.ToInt32(Session["orderIdForTorch"]);
                SiteProduct product = new SiteProduct();
                DataSet torchData = product.Get_TorchDescription(this.CurrentCart.CartId);
                foreach (DataTable table in torchData.Tables)
                {
                    foreach (DataRow Confdetail in table.Rows)
                    {
                        listSkus.Add(Confdetail["sku"].ToString());
                        listSkusDesc.Add(new LisTorchDescription(Confdetail["sku"].ToString(), Confdetail["description"].ToString()));
                    }
                }
                HashSet hs = new HashSet();
                hs.AddAll(listSkus);
                listSkus.Clear();
                listSkus.AddRange(hs);

                foreach(string sku in listSkus)
                {
                   string finalDescription = "";
                   foreach (LisTorchDescription sku2 in listSkusDesc)
                   {
                       if(sku.Equals(sku2.SKU))
                       {
                           finalDescription += "|" + sku2.Description + "|";

                       }
                   }
                   product.Add_Torch_Description(orderId, finalDescription, sku);
                }
                Session["TorchInCart"] = null;

                Session["orderIdForTorch"] = null;

            }

            if (CartUsers.IsUserLoggedIn(Session) && CurrentCart.BillingLocation != null)
            {
                int login_id = CartUsers.GetLoginID();
                db.LoginUpdBillingAddress(login_id, CurrentCart.BillingLocation.BusinessName, CurrentCart.BillingLocation.Address1, CurrentCart.BillingLocation.Address2, CurrentCart.BillingLocation.City, CurrentCart.BillingLocation.StateCode, CurrentCart.BillingLocation.PostalCode, CurrentCart.BillingLocation.CountryCode, CurrentCart.BillingLocation.Phone);
            }

        }
        CartDB de = new CartDB();

        cont = cont.Replace("\n\r", ""); //before making any substitution, check that there are no new lines in the code. Windows
        cont = cont.Replace("\n", ""); // Unix: note that this code will not change anyting in windows, due to the first line

        cont = cont.Replace("<img src=\"images/buttonEdit.jpg\" alt=\"Edit\" />", "");// Why will I want and edit button in the mail ?"<img src=\"http://www.edresources.com/images/buttonEdit.jpg\" alt=\"Edit\" />");
        cont = cont.Replace("type=\"checkbox\"", "type=\"hidden\"");
        cont = cont.Replace("textarea","div style='display:none;'");
        cont = cont.Replace("TEXTAREA", "div style='display:none;'");
        cont = cont.Replace("Comments", "");
        cont = cont.Replace("/ Special Instructions:", "");

         cont = System.Text.RegularExpressions.Regex.Replace(cont, "<img class=\"first-child", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont, "last-child\" alt=\"Edit\">", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont,"last-child\" alt=Edit src=\"images/buttonEdit.jpg\">","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont,"last-child\" alt=Edit src=\"images2/buttonEdit.jpg\">","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
         cont = System.Text.RegularExpressions.Regex.Replace(cont,"last-child\" alt=\"Place Order\" src=\"images/buttonPlaceOrder.jpg\">","<br>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

           cont = cont.Replace("Special Instructions:", "<b>Special Instructions:</b>");
        if (!SalesRepFlagCheckbox.Checked) {
            cont = cont.Replace("Yes, a sales rep helped me with this order", " ");
        }
        if (success)
        {
            DataSet data2 = new DataSet();
            data2 = de.Get_OrderId_By_Email(CartUsers.GetLoginID());
            foreach (DataTable table2 in data2.Tables)
            {
                foreach (DataRow row2 in table2.Rows)
                {
                    orderIdEmail = Convert.ToInt32(row2["OrderID"]);
                }
            }

            Session["orderpoid"] = orderIdEmail;

            if (CurrentCart.Payment.PaymentType == (int)PaymentType.CC)
            {
                send.toEmail(cont, CurrentCart.BillingLocation.Email, orderIdEmail);
                CurrentCart.MoveNextStep();

            }
            else
            {
                send.toEmail(cont, CurrentCart.BillingLocation.Email, orderIdEmail);
                CurrentCart.MoveToStep((int)Constants.CheckoutStep.PurchaseOrder);
            }

            Response.Redirect(Constants.Pages.CHECKOUT);
        }
    }
示例#28
0
 public void MoveToStep(int step)
 {
     CartDB db = new CartDB();
     if (step >= 0 && db.UpdateCartCheckoutStep(this._CartId, step))
     {
         this._CheckoutStep = step;
     }
 }
示例#29
0
    public static CartPayment GetCartPaymentByPaymentID(int payment_id)
    {
        CartDB db = new CartDB();
        DataSet ds = db.GetPaymentFromPaymentId(payment_id);

        if (ds != null)
        {
            using (DataTableReader data = ds.CreateDataReader())
            {
                while (data.Read())
                {
                    int cartid = data.GetInt32(data.GetOrdinal("CartId"));
                    int paymenttype = data.GetInt32(data.GetOrdinal("PaymentType"));
                    string cctype = Helper.IsString(data.GetValue(data.GetOrdinal("CCType")), "");
                    string cclastfourdigits = Helper.IsString(data.GetValue(data.GetOrdinal("CCLastFourDigits")), "");
                    string encryptedcc = Helper.IsString(data.GetValue(data.GetOrdinal("EncryptedCC")), "");
                    string encryptedccexpiration = Helper.IsString(data.GetValue(data.GetOrdinal("EncryptedCCExpiration")), "");
                    string encryptedcccvv = Helper.IsString(data.GetValue(data.GetOrdinal("EncryptedCCCVV")), "");
                    string pofilename = Helper.IsString(data.GetValue(data.GetOrdinal("POFileName")), "");
                    object obj_pofileupload = data.GetValue(data.GetOrdinal("POFileUpload"));
                    byte[] pofileupload = null;
                    if (obj_pofileupload != null && obj_pofileupload.GetType().Equals(typeof(byte[])))
                    {
                       pofileupload = (byte[])obj_pofileupload;
                    }

                    int ord_id = 0, ord_payment_id = 0;

                    object obj_ord_id = data.GetValue(data.GetOrdinal("ORD_ID"));
                    if (obj_ord_id != null && obj_ord_id.GetType().Equals(typeof(int)))
                    {
                        ord_id = (int)obj_ord_id;
                    }

                    object obj_ord_payment_id = data.GetValue(data.GetOrdinal("ORD_Payment_ID"));
                    if (obj_ord_payment_id != null && obj_ord_payment_id.GetType().Equals(typeof(int)))
                    {
                        ord_payment_id = (int)obj_ord_payment_id;
                    }

                    DateTime datecreated = data.GetDateTime(data.GetOrdinal("DateCreated"));
                    DateTime lastupdated = data.GetDateTime(data.GetOrdinal("LastUpdated"));

                    return new CartPayment(cartid, paymenttype, cctype, cclastfourdigits, encryptedcc, encryptedccexpiration, encryptedcccvv, pofilename, pofileupload, ord_id, ord_payment_id, datecreated, lastupdated);
                }
            }
        }

        return null;
    }