Пример #1
0
        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            //Create a User object and attempt login
            User user = new User();
            user.Login(TextBoxUsername.Text, TextBoxPassword.Text);

            //If login was successful...
            if (user.UserID > 0)
            {
                Session.Add("UserID", user.UserID);

                if (Session["ReturnToCheckout"] != null)
                {
                    Response.Redirect("Checkout.aspx");
                }
                else
                {
                    Response.Redirect("Index.aspx");
                }
            }
            else //if not successful...
            {
                LabelOutput.ForeColor = System.Drawing.Color.Red;
                LabelOutput.Text = "Login Failed.<br />Please verify username and password.";
            }
        }
Пример #2
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (txtUName.Text != "" && txtPass.Text != "" && txtPass2.Text != "" && txtFName.Text != ""
                && txtLName.Text != "" && txtSal.Text != "" && txtAddress.Text != "" && txtCity.Text != ""
                && txtZip.Text != "" && txtEmail.Text != "")
            {
                try
                {
                    usrID = Convert.ToInt32(Session["UserID"]);
                    User usr = new User();
                    usr.GetUserByID(usrID);

                    //take all values from text boxes and send them to User.cs
                    usr.Username = txtUName.Text;
                    if (txtPass.Text != txtPass2.Text)
                    {
                        LabelOutput.ForeColor = System.Drawing.Color.Red;
                        LabelOutput.Text = "Passwords do not match!";
                    }
                    else
                    {
                        usr.Password = txtPass.Text;
                        usr.Salutation = txtSal.Text;
                        usr.FirstName = txtFName.Text;
                        usr.LastName = txtLName.Text;
                        usr.Address1 = txtAddress.Text;
                        usr.Address2 = txtAddress2.Text;
                        usr.City = txtCity.Text;
                        usr.StateProvinceID = Convert.ToInt32(dropStateProv.SelectedValue);
                        usr.ZipCodePostal = txtZip.Text;
                        usr.Email = txtEmail.Text;
                        usr.IsReceiveNewsletters = ckBox.Checked;

                        // call addusr method to add usr and display success/fail text to usr
                        if (usr.UpdateUser())
                        {
                            LabelOutput.ForeColor = System.Drawing.Color.Green;
                            LabelOutput.Text = "Thank you " + txtUName.Text + "! You have successfully changed your information.";
                        }
                        else
                        {
                            LabelOutput.ForeColor = System.Drawing.Color.Red;
                            LabelOutput.Text = "Update Failed.<br />Please verify entered values.";
                            throw new Exception();
                        }
                    }
                }
                catch (Exception ex)
                {
                    String strEx = ex.Message;
                    LabelOutput.ForeColor = System.Drawing.Color.Red;
                    LabelOutput.Text = "Problem Updating, try again";
                }
            }// end if
            else
            {
                LabelOutput.ForeColor = System.Drawing.Color.Red;
                LabelOutput.Text = "Problem Updating, some required fields have not been filled.";
            }
        }
Пример #3
0
 protected void UpdatePanel1_Load(object sender, EventArgs e)
 {
     //Populate Users grid
     User user = new User();
     DataTable dataTable = user.ToDataTable(user.GetAllUsers());
     GridViewUsers.DataSource = dataTable;
     GridViewUsers.DataBind();
 }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Obtain User ID from query string
                int userid = Convert.ToInt32(Request.QueryString["userid"]);

                //Get User by its code
                User user = new User();
                user.GetUserByID(userid);

                //Populate States/Provinces dropdown list
                StateProvince sp = new StateProvince();
                List<StateProvince> states = sp.GetAllStatesProvinces();
                DropDownListStateProvince.DataSource = states;
                DropDownListStateProvince.DataTextField = "Name";
                DropDownListStateProvince.DataValueField = "StateProvinceID";
                DropDownListStateProvince.DataBind();

                //Put user details into fields
                LabelUserID.Text = Request.QueryString["userid"].ToString();
                TextBoxUsername.Text = Convert.ToString(user.Username);
                TextBoxPassword.Text = Convert.ToString(user.Password);
                TextBoxSalutation.Text = Convert.ToString(user.Salutation);
                TextBoxFirstName.Text = Convert.ToString(user.FirstName);
                TextBoxLastName.Text = Convert.ToString(user.LastName);
                TextBoxAddress1.Text = Convert.ToString(user.Address1);
                TextBoxAddress2.Text = Convert.ToString(user.Address2);
                TextBoxCity.Text = Convert.ToString(user.City);
                DropDownListStateProvince.SelectedValue = Convert.ToString(user.StateProvinceID);
                TextBoxZipPostalCode.Text = Convert.ToString(user.ZipCodePostal);
                TextBoxEmail.Text = Convert.ToString(user.Email);
                CheckBoxIsReceiveNewsletters.Checked = Convert.ToBoolean(user.IsReceiveNewsletters);
                LabelCreated.Text = Convert.ToDateTime(user.Created).ToShortDateString();
                if (Convert.ToDateTime(user.Modified) > DateTime.MinValue)
                {
                    LabelModified.Text = Convert.ToDateTime(user.Modified).ToShortDateString();
                }
                else
                {
                    LabelModified.Text = "N/A";
                }
            }
        }
Пример #5
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                //Create a User object
                User user = new User();

                //Get existing user by its id
                user.GetUserByID(Convert.ToInt32(LabelUserID.Text));

                //Update all fields
                user.Username = TextBoxUsername.Text;
                user.Password = TextBoxPassword.Text;
                user.Salutation = TextBoxSalutation.Text;
                user.FirstName = TextBoxFirstName.Text;
                user.LastName = TextBoxLastName.Text;
                user.Address1 = TextBoxAddress1.Text;
                user.Address2 = TextBoxAddress2.Text;
                user.City = TextBoxCity.Text;
                user.StateProvinceID = Convert.ToInt32(DropDownListStateProvince.SelectedValue);
                user.ZipCodePostal = TextBoxZipPostalCode.Text;
                user.Email = TextBoxEmail.Text;
                user.IsReceiveNewsletters = CheckBoxIsReceiveNewsletters.Checked;
                user.Modified = DateTime.Now;

                //Update the product
                if (user.UpdateUser())
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "", "window.top.window.$.fancybox.close();", true);
                    //Response.Redirect("~/Admin/Users.aspx");
                }
                else
                {
                    LabelOutput.ForeColor = System.Drawing.Color.Red;
                    LabelOutput.Text = "Error: Update Failed";
                }

            }
            catch (Exception ex)
            {
                LabelOutput.ForeColor = System.Drawing.Color.Red;
                LabelOutput.Text = "Error: " + ex.Message;
            }
        }
Пример #6
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);
            }
        }
Пример #7
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");
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null)
            {
                //Not logged in
                LabelWelcome.Text = "Welcome, Guest";
                LinkButtonLoginLogout.Text = "Login";
            }
            else
            {
                if (!Page.IsPostBack)
                {
                    //Get the first name of the current user
                    User user = new User();
                    user.GetUserByID(Convert.ToInt32(Session["UserID"]));
                    LabelWelcome.Text = "Welcome, " + user.FirstName;

                    //Change login button to logout
                    LinkButtonLoginLogout.Text = "Logout";

                }
            }

            if (!Page.IsPostBack)
            {
                //Get all active categories
                Category cat = new Category();
                List<Category> cats = cat.GetAllCategories(true);

                foreach (var cs in cats)
                {
                    MenuItem mi = new MenuItem();
                    MenuItem m = new MenuItem();
                    foreach (MenuItem main in appleNav.Items)
                    {
                        if (main.Text == "Categories")
                        {
                            m = main;
                            break;
                        }
                    }

                    if (cs.ParentCategoryID > 0)
                    {
                        foreach (MenuItem ms in m.ChildItems)
                        {
                            if (ms.Value == cs.ParentCategoryID.ToString())
                            {
                                mi.Value = cs.ParentCategoryID.ToString();
                                mi.Text = cs.Name.ToString();
                                mi.NavigateUrl = "~/Category.aspx?id=" + cs.CategoryID;
                                ms.ChildItems.Add(mi);
                                break;
                            }
                        }
                    }
                    else
                    {
                        mi.Value = cs.CategoryID.ToString();
                        mi.Text = cs.Name.ToString();
                        mi.Selectable = false;
                        m.ChildItems.Add(mi);
                    }
                }
            }
        }
Пример #9
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();
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null)
                Response.Redirect("~/Login.aspx");
            else
            {
                if (!Page.IsPostBack)
                {
                    usrID = Convert.ToInt32(Session["UserID"]);
                    User usr = new User();
                    usr.GetUserByID(usrID);

                    // Load users data into the fields
                    txtUName.Text = usr.Username.ToString();
                    txtPass.Text = usr.Password.ToString();
                    txtSal.Text = usr.Salutation.ToString();
                    txtFName.Text = usr.FirstName.ToString();
                    txtLName.Text = usr.LastName.ToString();
                    txtAddress.Text = usr.Address1.ToString();
                    txtAddress2.Text = usr.Address2.ToString();
                    pID = usr.StateProvinceID;
                    // populate the drop downs
                    SelectCountryAndProv();
                    txtCity.Text = usr.City.ToString();
                    txtZip.Text = usr.ZipCodePostal.ToString();
                    txtEmail.Text = usr.Email.ToString();
                    if(Convert.ToBoolean(usr.IsReceiveNewsletters))
                        ckBox.Checked = true;
                }
            }
        }