Ejemplo n.º 1
0
        /// <summary>
        /// Purpose: Grabs all delivery types
        /// Accepts: Nothing
        /// Returns: List<DeliveryType>
        /// </summary>
        public List <DeliveryType> GetAllDeliveryTypes()
        {
            List <DeliveryType> deliveryTypes = new List <DeliveryType>();

            try
            {
                DeliveryTypeData data = new DeliveryTypeData();
                List <QSRDataObjects.DeliveryType> dataDeliveryTypes = data.GetAllDeliveryTypes();

                foreach (QSRDataObjects.DeliveryType dt in dataDeliveryTypes)
                {
                    DeliveryType deliveryType = new DeliveryType();
                    deliveryType.DeliveryTypeID = dt.DeliveryTypeID;
                    deliveryType.Name           = dt.Name;
                    deliveryType.Cost           = Convert.ToDouble(dt.Cost);
                    deliveryType.Description    = dt.Description;
                    deliveryType.Created        = dt.Created;
                    deliveryType.Modified       = dt.Modified;
                    deliveryTypes.Add(deliveryType);
                }
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "DeliveryType", "GetAllDeliveryTypes");
            }
            return(deliveryTypes);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            prodcd = Request.QueryString["prodcd"].ToString();
            var prod = new Product();
            prod.GetProductByCode(prodcd);
            title.Text = prod.Name.ToString();
            productCode.Text = prod.ProductCode.ToString();
            brand.Text = prod.Brand.ToString();

            //Get configurations
            Configuration config = new Configuration();
            config.GetConfigurationByCode("xCurrencyCode");

            price.Text = "$" + prod.Msrp.ToString() + " " + config.Value;

            LabelDescription.Text = prod.Description.ToString();

            //If the unlimited quantity flag is set...
            if (Convert.ToBoolean(prod.IsQuantityUnlimited) == true)
            {
                quantity.Text = "Quantity Remaining: Unlimited";
            }
            else
            {
                quantity.Text = "Quantity Remaining: " + prod.QuantityInStock.ToString();
            }

            //Attempt to display image (if it is found)
            try
            {
                itemPic.ImageUrl = "~/Images/Product_Images/" + prodcd + ".jpg";
            }
            catch (Exception)
            {
                itemPic.ImageUrl = "";
            }

            //Fill gridview with available delivery types
            ProductDeliveryType pdt = new ProductDeliveryType();
            List<ProductDeliveryType> pdtypes = pdt.GetAllProductDeliveryTypesByProdCode(prodcd);

            List<DeliveryType> deliveryTypes = new List<DeliveryType>();
            foreach (ProductDeliveryType prodDelType in pdtypes)
            {
                DeliveryType dt = new DeliveryType();
                dt.GetDeliveryTypeByID(prodDelType.DeliveryTypeID);
                deliveryTypes.Add(dt);
            }

            GridViewDeliveryTypes.DataSource = deliveryTypes;
            GridViewDeliveryTypes.DataBind();

            //Don't show "Delivery Types" title if there are no delivery types listed
            if (deliveryTypes.Count == 0)
            {
                LabelDeliveryTypesTitle.Visible = false;
            }
        }
Ejemplo n.º 3
0
 public RenderDeliveryType(DeliveryType dt)
 {
     DeliveryTypeID = dt.DeliveryTypeID;
     Name           = Convert.ToString(dt.Name);
     Cost           = Convert.ToDouble(dt.Cost);
     Description    = Convert.ToString(dt.Description);
     Created        = Convert.ToDateTime(dt.Created);
     Modified       = Convert.ToDateTime(dt.Modified);
 }
Ejemplo n.º 4
0
        //Constructor
        public CheckoutItem()
        {
            _deliveryTypes = new List<DeliveryType>();

            //Add a default selection to the delivery type dropdownlist
            DeliveryType dt = new DeliveryType();
            dt.DeliveryTypeID = 0;
            dt.Name = "Select One...";
            _deliveryTypes.Add(dt);
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Obtain Order ID from query string
                int orderid = Convert.ToInt32(Request.QueryString["orderid"]);

                //Get Order by its orderid
                Order order = new Order();
                order.GetOrderByID(orderid);

                //Populate Delivery Types dropdown list
                DeliveryType dt = new DeliveryType();
                List<DeliveryType> dtypes = dt.GetAllDeliveryTypes();
                DropDownListDeliveryType.DataSource = dtypes;
                DropDownListDeliveryType.DataTextField = "Name";
                DropDownListDeliveryType.DataValueField = "DeliveryTypeID";
                DropDownListDeliveryType.DataBind();

                //Populate Users dropdown list
                User user = new User();
                List<User> users = user.GetAllUsers();
                DropDownListUsers.DataSource = users;
                DropDownListUsers.DataTextField = "Username";
                DropDownListUsers.DataValueField = "UserID";
                DropDownListUsers.DataBind();

                //Put order details into fields
                LabelOrderID.Text = Request.QueryString["orderid"].ToString();
                DropDownListUsers.SelectedValue = Convert.ToString(order.UserID);
                TextBoxSubtotal.Text = Convert.ToString(order.Subtotal);
                TextBoxTaxes.Text = Convert.ToString(order.Taxes);
                TextBoxDeliveryCost.Text = Convert.ToString(order.DeliveryCost);
                DropDownListDeliveryType.SelectedValue = Convert.ToString(order.DeliveryTypeID);
                TextBoxGrandTotal.Text = Convert.ToString(order.GrandTotal);
            }
        }
Ejemplo n.º 6
0
        protected void ButtonGoToPayInfo_Click(object sender, EventArgs e)
        {
            //Get a reference to the original datasource for the datalist (doesn't take into account DeliveryType changes)
            DataTable dt = new DataTable();
            dt.Columns.Add("Prodcd");
            dt.Columns.Add("Name");
            dt.Columns.Add("Msrp", System.Type.GetType("System.Double"));
            dt.Columns.Add("Quantity");
            dt.Columns.Add("DeliveryTypeID");
            dt.Columns.Add("DeliveryTypeName");
            dt.Columns.Add("DeliveryCost", System.Type.GetType("System.Double"));
            dt.Columns.Add("Taxes", System.Type.GetType("System.Double"));
            dt.Columns.Add("Total", System.Type.GetType("System.Double"));
            dt.Columns.Add("FirstName");
            dt.Columns.Add("LastName");
            dt.Columns.Add("Address1");
            dt.Columns.Add("Address2");
            dt.Columns.Add("City");
            dt.Columns.Add("Country");
            dt.Columns.Add("StateProvinceID");
            dt.Columns.Add("StateProvinceName");
            dt.Columns.Add("ZipPostalCode");
            dt.Columns.Add("Email");

            //For each data list item...
            for (int i = 0; i < DataListCheckout.Items.Count; i++)
            {
                //Get reference to this data list item
                DataListItem item = DataListCheckout.Items[i];
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    //Get reference to original datarow for this datalist item
                    DataRow dr = dt.NewRow();

                    //Get reference to the product for this datalist item
                    Product prod = new Product();
                    prod.GetProductByCode(DataListCheckout.DataKeys[i].ToString());

                    dr["Prodcd"] = prod.ProductCode;
                    dr["Name"] = prod.Name;
                    dr["Msrp"] = prod.Msrp;
                    dr["Quantity"] = ((Label)(item.FindControl("LabelQuantity"))).Text;
                    dr["DeliveryTypeID"] = ((DropDownList)(item.FindControl("DropDownListDeliveryType"))).SelectedValue;

                    //Get the delivery type name and cost
                    DeliveryType dtype = new DeliveryType();
                    dtype.GetDeliveryTypeByID(Convert.ToInt32(dr["DeliveryTypeID"]));
                    dr["DeliveryTypeName"] = dtype.Name;
                    dr["DeliveryCost"] = dtype.Cost;

                    if (((CheckBox)item.FindControl("CheckBoxUseUserAddress")).Checked == true) //use account delivery info
                    {
                        //Get the current user
                        User user = new User();
                        user.GetUserByID(Convert.ToInt32(Session["UserID"]));
                        dr["FirstName"] = user.FirstName;
                        dr["LastName"] = user.LastName;
                        dr["Address1"] = user.Address1;
                        dr["Address2"] = user.Address2;
                        dr["City"] = user.City;
                        dr["StateProvinceID"] = user.StateProvinceID;
                        //dr["Country"] = user.  MUST DEAL WITH COUNTRY LATER
                        dr["ZipPostalCode"] = user.ZipCodePostal;
                        dr["Email"] = user.Email;
                    }
                    else //use customized delivery info
                    {
                        dr["FirstName"] = ((TextBox)(item.FindControl("txtFName"))).Text;
                        dr["LastName"] = ((TextBox)(item.FindControl("txtLName"))).Text;
                        dr["Address1"] = ((TextBox)(item.FindControl("txtAddress"))).Text;
                        dr["Address2"] = ((TextBox)(item.FindControl("txtAddress2"))).Text;
                        dr["City"] = ((TextBox)(item.FindControl("txtCity"))).Text;
                        //dr["Country"] = ((DropDownList)(item.FindControl("dropCountry"))).SelectedValue; MUST DEAL WITH COUNTRY LATER
                        dr["StateProvinceID"] = ((DropDownList)(item.FindControl("dropStateProv"))).SelectedValue;
                        dr["ZipPostalCode"] = ((TextBox)(item.FindControl("txtZipPostal"))).Text;
                        dr["Email"] = ((TextBox)(item.FindControl("txtEmail"))).Text;
                    }

                    //Get the state/province name and tax cost
                    StateProvince sp = new StateProvince();
                    sp.GetStateProvinceByID(Convert.ToInt32(dr["StateProvinceID"]));
                    dr["StateProvinceName"] = sp.Name;
                    dr["Taxes"] = sp.TaxRatePercentage / 100 * Convert.ToDouble(dr["Msrp"]);

                    //Calculate the total cost
                    dr["Total"] = Convert.ToDouble(dr["Msrp"]) + Convert.ToDouble(dr["DeliveryCost"]) + Convert.ToDouble(dr["Taxes"]);

                    //Add row to datatable
                    dt.Rows.Add(dr);
                }
            }

            //Add checkout list to session
            Session.Add("CheckoutDataTable",dt);

            //Go to next page
            Response.Redirect("~/PaymentInfo.aspx");
        }
Ejemplo n.º 7
0
        protected void DataListCheckout_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var item = e.Item.DataItem as DataRowView;
                if (item != null)
                {
                    //Set the checkbox value attribute
                    var chk = e.Item.FindControl("CheckBoxUseUserAddress") as CheckBox;
                    if (chk != null)
                    {
                        chk.InputAttributes.Add("value", item["Prodcd"].ToString());
                    }

                    //Set the dropdownlist datasource
                    DropDownList spDDL = e.Item.FindControl("dropStateProv") as DropDownList;
                    StateProvince sp = new StateProvince();
                    List<StateProvince> states = sp.GetAllStatesProvinces();
                    spDDL.DataSource = states;
                    spDDL.DataTextField = "Name";
                    spDDL.DataValueField = "StateProvinceID";
                    spDDL.DataBind();

                    //Get all ProductDeliveryType objects for this prodcd
                    ProductDeliveryType pdt = new ProductDeliveryType();
                    List<ProductDeliveryType> pdtypes = pdt.GetAllProductDeliveryTypesByProdCode(item["Prodcd"].ToString());

                    //For each ProductDeliveryType, add its associated DeliveryType object to the list
                    List<DeliveryType> dTypes = new List<DeliveryType>();
                    foreach (ProductDeliveryType pdtype in pdtypes)
                    {
                        DeliveryType delType = new DeliveryType();
                        delType.GetDeliveryTypeByID(pdtype.DeliveryTypeID);
                        dTypes.Add(delType);
                    }

                    //Assign list of DeliveryType to data list
                    DropDownList delTypesDDL = e.Item.FindControl("DropDownListDeliveryType") as DropDownList;
                    delTypesDDL.DataSource = dTypes;
                    delTypesDDL.DataTextField = "Name";
                    delTypesDDL.DataValueField = "DeliveryTypeID";
                    delTypesDDL.DataBind();
                }
            }
        }
Ejemplo n.º 8
0
        private void reloadGridView()
        {
            if (DropDownListDBTables.SelectedValue == "Administrators")
            {
                //Get all objects
                Administrator obj = new Administrator();
                List<Administrator> list = obj.GetAllAdministrators(false);

                //Fill a rendered object list
                List<RenderAdministrator> renderedList = new List<RenderAdministrator>();
                foreach (Administrator x in list)
                {
                    renderedList.Add(new RenderAdministrator(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Audits")
            {
                //Get all objects
                Audit obj = new Audit();
                List<Audit> list = obj.GetAllAudits();

                //Fill a rendered object list
                List<RenderAudit> renderedList = new List<RenderAudit>();
                foreach (Audit x in list)
                {
                    renderedList.Add(new RenderAudit(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "AuditTypes")
            {
                //Get all objects
                AuditType obj = new AuditType();
                List<AuditType> list = obj.GetAllAuditTypes();

                //Fill a rendered object list
                List<RenderAuditType> renderedList = new List<RenderAuditType>();
                foreach (AuditType x in list)
                {
                    renderedList.Add(new RenderAuditType(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            if (DropDownListDBTables.SelectedValue == "Categories")
            {
                //Get all objects
                Category obj = new Category();
                List<Category> list = obj.GetAllCategories(false);

                //Fill a rendered object list
                List<RenderCategory> renderedList = new List<RenderCategory>();
                foreach (Category x in list)
                {
                    renderedList.Add(new RenderCategory(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Configurations")
            {
                //Get all objects
                Configuration obj = new Configuration();
                List<Configuration> list = obj.GetAllConfigurations();

                //Fill a rendered object list
                List<RenderConfiguration> renderedList = new List<RenderConfiguration>();
                foreach (Configuration x in list)
                {
                    renderedList.Add(new RenderConfiguration(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "DeliveryType")
            {
                //Get all objects
                DeliveryType obj = new DeliveryType();
                List<DeliveryType> list = obj.GetAllDeliveryTypes();

                //Fill a rendered object list
                List<RenderDeliveryType> renderedList = new List<RenderDeliveryType>();
                foreach (DeliveryType x in list)
                {
                    renderedList.Add(new RenderDeliveryType(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "LangLabels")
            {
                //Get all objects
                LangLabel obj = new LangLabel();
                List<LangLabel> list = obj.GetAllLangLabels();

                //Fill a rendered object list
                List<RenderLangLabel> renderedList = new List<RenderLangLabel>();
                foreach (LangLabel x in list)
                {
                    renderedList.Add(new RenderLangLabel(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "OrderItems")
            {
                //Get all objects
                OrderItem obj = new OrderItem();
                List<OrderItem> list = obj.GetAllOrderItems();

                //Fill a rendered object list
                List<RenderOrderItem> renderedList = new List<RenderOrderItem>();
                foreach (OrderItem x in list)
                {
                    renderedList.Add(new RenderOrderItem(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Orders")
            {
                //Get all objects
                Order obj = new Order();
                List<Order> list = obj.GetAllOrders();

                //Fill a rendered object list
                List<RenderOrder> renderedList = new List<RenderOrder>();
                foreach (Order x in list)
                {
                    renderedList.Add(new RenderOrder(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "ProductDeliveryTypes")
            {
                //Get all objects
                ProductDeliveryType obj = new ProductDeliveryType();
                List<ProductDeliveryType> list = obj.GetAllProductDeliveryTypes();

                //Fill a rendered object list
                List<RenderProductDeliveryType> renderedList = new List<RenderProductDeliveryType>();
                foreach (ProductDeliveryType x in list)
                {
                    renderedList.Add(new RenderProductDeliveryType(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Products")
            {
                //Get all objects
                Product obj = new Product();
                List<Product> list = obj.GetAllProducts(false);

                //Fill a rendered object list
                List<RenderProduct> renderedList = new List<RenderProduct>();
                foreach(Product x in list)
                {
                    renderedList.Add(new RenderProduct(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "StatesProvinces")
            {
                //Get all objects
                StateProvince obj = new StateProvince();
                List<StateProvince> list = obj.GetAllStatesProvinces();

                //Fill a rendered object list
                List<RenderStateProvince> renderedList = new List<RenderStateProvince>();
                foreach (StateProvince x in list)
                {
                    renderedList.Add(new RenderStateProvince(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Users")
            {
                //Get all objects
                User obj = new User();
                List<User> list = obj.GetAllUsers();

                //Fill a rendered object list
                List<RenderUser> renderedList = new List<RenderUser>();
                foreach (User x in list)
                {
                    renderedList.Add(new RenderUser(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }

            //Databind the new datasource obtained above
            GridViewDBTable.DataBind();
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Check if logged in
            if (Session["UserID"] == null)
            {
                //Set a session variable to indicate return to checkout after login
                Session.Add("ReturnToCheckout", true);
                Response.Redirect("~/Login.aspx");
            }

            if (!IsPostBack)
            {
                List<Tuple<string, int>> list = new List<Tuple<string, int>>();
                if (Session["cartList"] != null)
                {
                    list = (List<Tuple<string, int>>)(Session["cartList"]);
                }
                else
                {
                    Response.Redirect("~/Index.aspx");
                }

                //Collection that will be bound to the checkout datalist
                List<CheckoutItem> coItems = new List<CheckoutItem>();

                foreach (Tuple<string, int> item in list)
                {
                    CheckoutItem coItem = new CheckoutItem();
                    coItem.Prodcd = item.Item1;
                    coItem.Quantity = item.Item2;

                    //Get product info
                    Product prod = new Product();
                    prod.GetProductByCode(item.Item1);
                    coItem.Name = prod.Name.ToString();
                    coItem.Msrp = prod.Msrp;

                    //Get all product delivery types
                    ProductDeliveryType pdt = new ProductDeliveryType();
                    List<ProductDeliveryType> pdtypes = pdt.GetAllProductDeliveryTypesByProdCode(prod.ProductCode.ToString());
                    foreach(ProductDeliveryType pdtype in pdtypes)
                    {
                        DeliveryType dt = new DeliveryType();
                        dt.GetDeliveryTypeByID(pdtype.DeliveryTypeID);
                        coItem.DeliveryTypes.Add(dt);
                    }

                    //Add checkout item to datasource list
                    coItems.Add(coItem);
                }

                //Bind to the datalist
                DataListCheckout.DataSource = coItems;
                DataListCheckout.DataBind();
            }
        }