protected void btnConfirm_Click(object sender, EventArgs e)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Order", 0, 20, SqlDbType.Int, ParameterDirection.Output));
            parms.Add(new SqlJacknife.ParmStruct("@ID_Cart", Session["ID_Cart"], 8, System.Data.SqlDbType.Int, System.Data.ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@ShippingAddress", Request.Cookies["address"].Value, 300, System.Data.SqlDbType.NVarChar, System.Data.ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@PaymentType", Session["Payment"].ToString(), 20, System.Data.SqlDbType.NVarChar, System.Data.ParameterDirection.Input));

            try
            {
                String OrderId = SqlJacknife.SendCommandGetString("PlaceOrderOutput", parms);


                sendEmail(OrderId);

                Response.Cookies.Clear();
                Response.Cookies["ID_Cart"].Expires = DateTime.Now.AddDays(-1);
                String ordered = Session["ID_Cart"].ToString();
                Session["ID_Cart"] = "";

                Response.Redirect("Ordered.aspx?ordered=" + ordered + "&messageSuccess=Your ideas are on the way!");
            }
            catch (Exception ex)
            {
                master.messageError(ex.Message);
            }
        }
        /// <summary>
        /// Notice the plural, this takes the keyword property and the inclusive to factor in as many keywords ad possible.
        /// </summary>
        /// <param name="keywordRaw"></param>
        /// <param name="inclusive"></param>
        public void DisplaySearchByKeywords(string keywordRaw, string inclusive)
        {
            String[] keywords = keywordRaw.Split(' '); //Create an array of keywords

            if (keywords.Length == 0)                  //If there are no keywords don't even bother.
            {
                lblNoResults.Visible = true;
                lblNoResults.Text    = "No results :(";
                return;
            }

            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@mustALL", inclusive, 1, SqlDbType.Char, ParameterDirection.Input)); //Must all means all must be included.

            for (int a = 0; a < Math.Min(keywords.Length, 5); a++)                                                     //Don't exceed 5 keywords
            {
                String myName = "@daWord" + (a + 1).ToString();
                parms.Add(new SqlJacknife.ParmStruct(myName, keywords[a], 50, SqlDbType.VarChar, ParameterDirection.Input));
            }

            //The rest is the same Display Search by Keyword
            DataTable dt = SqlJacknife.GetDS("Prods_by_Keywords", parms, CommandType.StoredProcedure).Tables[0];

            rptProducts.DataSource = dt;
            rptProducts.DataBind();

            if (dt.Rows.Count == 0)
            {
                lblNoResults.Visible = true;
                lblNoResults.Text    = "No results :(";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (master == null)
            {
                master = (IdeaHeaderAndSide)this.Master;
            }
            if (!IsPostBack)
            {
                string IdCat    = Request.QueryString["categoryID"];
                string keyword  = Request.QueryString["search"];
                string validate = Request.QueryString["validate"];

                if (!string.IsNullOrEmpty(validate))
                {
                    tryValidate(validate);
                }

                if (!string.IsNullOrEmpty(IdCat))
                {
                    SeeLabel.Text = "Category: " + Request.QueryString["categoryName"];
                    getProducts(IdCat);
                }
                else if (!string.IsNullOrEmpty(keyword))
                {
                    SeeLabel.Text = "Search: " + keyword;
                    DisplaySearchByKeywords(keyword, Request.QueryString["inclusion"]);
                }

                if (string.IsNullOrEmpty(keyword) && string.IsNullOrEmpty(IdCat))
                {
                    SeeLabel.Text = "Featured Ideas:";
                    SqlJacknife.stapleRepeater("Prods_Get_Featured", rptProducts, lblNoResults);
                }
            }
        }
Пример #4
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (master.getCartId() == -1)
            {
                return;
            }

            try
            {
                foreach (GridViewRow row in grdCartItems.Rows)
                {
                    List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                    parms.Add(new SqlJacknife.ParmStruct("@ID_Cart", master.getCartId(), 0, SqlDbType.Int, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@ID_Pr", (row.Cells[0].Text), 4, SqlDbType.Char, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@qty", Convert.ToInt32(((TextBox)(row.Cells[2].FindControl("Quantity"))).Text), 0, SqlDbType.Int, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@remove", ((CheckBox)(row.Cells[4].FindControl("chkRemove"))).Checked, 0, SqlDbType.Bit, ParameterDirection.Input));

                    SqlJacknife.SendCommand("spUpdateCartItems", parms);
                }
                LoadCart();
                if (grdCartItems.Rows.Count != 0)
                {
                    master.messageSuccess("Cart updated!");
                }
                else
                {
                    master.messageNormal("You don't have any item in your cart");
                }
            }
            catch (Exception ex)
            {
                master.messageLoggedError(ex.Message);
                IdeaHeaderAndSide.logMessage("IdeaShop-CartPage: Update Cart", ex.Message);
            }
        }
        protected void LoadAddress(int id)
        {
            DataTable dt = new DataTable();

            using (SqlConnection conn = new SqlConnection(cnnString))
            {
                conn.Open();
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                parms.Add(new SqlJacknife.ParmStruct("@ID_Cust", id, 0, System.Data.SqlDbType.Int, System.Data.ParameterDirection.Input));

                dt = SqlJacknife.GetDataTable("Address_By_IDCust", parms);
                if (dt.Rows.Count != 0)
                {
                    if (dt.Rows[0]["country"].ToString() == "United States" || dt.Rows[0]["country"].ToString() == "USA")
                    {
                        country.SelectedIndex = 0;
                    }
                    else if (dt.Rows[0]["country"].ToString() == "Canada")
                    {
                        country.SelectedIndex = 1;
                    }
                    else
                    {
                        country.SelectedIndex = 2;
                    }
                    zip.Text     = dt.Rows[0]["zip"].ToString();
                    sOrP.Text    = dt.Rows[0]["state"].ToString();
                    address.Text = dt.Rows[0]["street"].ToString();
                    city.Text    = dt.Rows[0]["city"].ToString();
                    changeRegex(null, null);
                }
            }
        }
Пример #6
0
 /// <summary>
 /// This finally deletes the selected category
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnConfirm_Click(object sender, EventArgs e)
 {
     try
     {
         List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
         parms.Add(new SqlJacknife.ParmStruct("@ID_Cat", ddlCategories.SelectedValue, 4, SqlDbType.Char, ParameterDirection.Input));
         SqlJacknife.SendCommand("Categ_Delete", parms, CommandType.StoredProcedure);
         Label lblMasterMessage = this.Page.Master.FindControl("lblMessage") as Label;
         lblMasterMessage.Text = "Category Deleted";
         getCategories();
         IdeaHeaderAndSide master = (IdeaHeaderAndSide)this.Master;
         master.getCategories();
         btnCancel.Visible  = false;
         btnConfirm.Visible = false;
         btnNew.Visible     = true;
         btnSave.Visible    = true;
         btnDelete.Visible  = true;
         master.messageSuccess("Category deleted");
         //Response.Redirect("default.aspx?messageSuccess=Category+Deleted!");
     }
     catch
     {
         master.messageError("Cannot delete Categories containing products");
     }
 }
        protected void loadCustomer(int id)
        {
            try
            {
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                parms.Add(new SqlJacknife.ParmStruct("@ID_Cust", id, 20, SqlDbType.Int, ParameterDirection.Input));

                DataTable dt = SqlJacknife.GetDataTable("Get_Customer", parms);

                lblId.Text      = "Id :" + dt.Rows[0]["ID_Cust"].ToString();
                fname.Text      = dt.Rows[0]["FName"].ToString();
                mname.Text      = dt.Rows[0]["MName"].ToString();
                lname.Text      = dt.Rows[0]["LName"].ToString();
                username.Text   = dt.Rows[0]["UserName"].ToString();
                birthDate.Value = dt.Rows[0]["DOB"].ToString().Split(' ')[0];
                phone.Text      = dt.Rows[0]["Phone"].ToString();
                email.Text      = dt.Rows[0]["Email"].ToString();
                address.Text    = dt.Rows[0]["Street"].ToString();
                city.Text       = dt.Rows[0]["City"].ToString();
                sOrP.Text       = dt.Rows[0]["State"].ToString();
                zip.Text        = dt.Rows[0]["ZIP"].ToString();
                country.Text    = dt.Rows[0]["Country"].ToString();
                password.Text   = dt.Rows[0]["Password"].ToString();
            }
            catch (Exception ex)
            {
                master.messageLoggedError(ex.Message);
                IdeaHeaderAndSide.logMessage("IdeaShop-Account Editor: Retrieving customer data", ex.Message);
            }
        }
Пример #8
0
        /// <summary>
        /// Saves or updates the category
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            // Check if the name is null or empty
            if (string.IsNullOrEmpty(cat_name.Text.Trim()))
            {
                IdeaHeaderAndSide leMaster = (IdeaHeaderAndSide)this.Master;
                leMaster.messageError("Please enter a title!");
            }

            Label  lblMasterMessage = this.Page.Master.FindControl("lblMessage") as Label;
            String idOutput         = "";

            if (ddlCategories.Visible == false)
            {
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                parms.Add(new SqlJacknife.ParmStruct("@ID_Cat", idOutput, 4, SqlDbType.Char, ParameterDirection.Output));
                parms.Add(new SqlJacknife.ParmStruct("@cat_name", cat_name.Text, 30, SqlDbType.VarChar, ParameterDirection.Input));
                parms.Add(new SqlJacknife.ParmStruct("@description", description.Text, 200, SqlDbType.VarChar, ParameterDirection.Input));
                SqlJacknife.SendCommand("Categ_Add", parms, CommandType.StoredProcedure);
                this.master.messageSuccess("Category Added");
            }
            else if (ddlCategories.Visible == true)
            {
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                parms.Add(new SqlJacknife.ParmStruct("@ID_Cat", ddlCategories.SelectedValue, 30, SqlDbType.Int, ParameterDirection.Input));
                parms.Add(new SqlJacknife.ParmStruct("@cat_name", cat_name.Text, 30, SqlDbType.VarChar, ParameterDirection.Input));
                parms.Add(new SqlJacknife.ParmStruct("@description", description.Text, 200, SqlDbType.VarChar, ParameterDirection.Input));
                SqlJacknife.SendCommand("Categ_Update", parms, CommandType.StoredProcedure);

                this.master.messageSuccess("Category Updated");
            }
            getCategories();
            //IdeaHeaderAndSide master = (IdeaHeaderAndSide)this.Master;
            master.getCategories();
        }
        public void LoadUpAccount(int Id)
        {
            try
            {
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                parms.Add(new SqlJacknife.ParmStruct("@ID_Cust", Id, 0, SqlDbType.Int, ParameterDirection.Input));

                DataTable dt = SqlJacknife.GetDataTable("RetrieveAccountByID", parms);
                lblID.Text            = Id.ToString();
                username.Text         = dt.Rows[0]["username"].ToString();
                password.Text         = dt.Rows[0]["password"].ToString();
                fname.Text            = dt.Rows[0]["fname"].ToString();
                lname.Text            = dt.Rows[0]["lname"].ToString();
                birthDate.Value       = dt.Rows[0]["dob"].ToString().Split(' ')[0];
                mname.Text            = dt.Rows[0]["mname"].ToString();
                phone.Text            = dt.Rows[0]["phone"].ToString();
                email.Text            = dt.Rows[0]["email"].ToString();
                country.SelectedValue = dt.Rows[0]["country"].ToString();
                city.Text             = dt.Rows[0]["city"].ToString();
                sOrP.Text             = dt.Rows[0]["state"].ToString();
                address.Text          = dt.Rows[0]["street"].ToString();
                zip.Text = dt.Rows[0]["zip"].ToString();
            }
            catch (Exception x)
            {
                master.messageLoggedError(x.Message);
                IdeaHeaderAndSide.logMessage("AccountEditorInfoLoad", x.Message);
            }
        }
Пример #10
0
        private void LoadCartOld()
        {
            if (Request.Cookies["ID_Cart"] == null)
            {
                return;
            }


            DataTable dt;
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            int cartID = 0;

            cartID = Convert.ToInt32(Request.Cookies["ID_Cart"].Value);

            parms.Add(new SqlJacknife.ParmStruct("@ID_Cart", cartID, 0, SqlDbType.Int, ParameterDirection.Input));
            dt = SqlJacknife.GetDS("spLoadCartItems", parms).Tables[0];
            if (dt.Rows.Count != 0)
            {
                grdCartItems.DataSource = dt;
                grdCartItems.DataBind();

                double subtotal = 0;
                foreach (GridViewRow row in grdCartItems.Rows)
                {
                    subtotal += Convert.ToDouble(((Label)(row.Cells[3].FindControl("lblSubTotal"))).Text.Substring(1));
                }
                lblSubtotal.Text = subtotal.ToString("c");

                double tax = subtotal * 0.15;

                double shipping = 0;

                if (subtotal <= 75 && subtotal >= 35)
                {
                    shipping = 12;
                }
                else if (subtotal < 35)
                {
                    shipping = 7;
                }

                lblSubtotal.Text = subtotal.ToString("c");
                lblTax.Text      = tax.ToString("c");
                lblShipping.Text = shipping.ToString("c");
                lblTotal.Text    = (subtotal + tax + shipping).ToString("c");
                //double subtotal = Convert.ToDouble(grdCartItems.Rows[0].Cells[4].Text.Replace("$",""));
            }
            else
            {
                grdCartItems.DataSource = dt;
                grdCartItems.DataBind();
                lblSubtotal.Text = 0.ToString("c");
                lblTax.Text      = 0.ToString("c");
                lblShipping.Text = 0.ToString("c");
                lblTotal.Text    = 0.ToString("c");
                Response.Cookies.Remove("ID_Cart");
                Response.Cookies["ID_Cart"].Expires = DateTime.Today.AddDays(-1);
            }
        }
        /// <summary>
        /// Loads a single image
        /// </summary>
        /// <param name="ID_Img"></param>
        /// <returns>A (hopefully) one-row DataTable</returns>
        public DataTable Load_Image(int ID_Img)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Img", ID_Img, 0, SqlDbType.Int, ParameterDirection.Input));

            return(SqlJacknife.GetDataTable("Load_Image", parms));
        }
Пример #12
0
        private void LoadCart()
        {
            if (String.IsNullOrEmpty(Request.QueryString["ordered"]))
            {
                return;
            }


            DataTable dt;
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            int cartID = 0;

            cartID = Convert.ToInt32(Request.QueryString["ordered"]);

            parms.Add(new SqlJacknife.ParmStruct("@ID_Cart", cartID, 0, SqlDbType.Int, ParameterDirection.Input));
            dt = SqlJacknife.GetDS("spLoadOrderedItems", parms).Tables[0];
            if (dt.Rows.Count != 0)
            {
                grdCartItems.DataSource = dt;
                grdCartItems.DataBind();

                double subtotal = 0;
                foreach (GridViewRow row in grdCartItems.Rows)
                {
                    subtotal += Convert.ToDouble(row.Cells[4].Text.Substring(1));
                }
                lblSubtotal.Text = subtotal.ToString("c");

                double tax = subtotal * 0.15;

                double shipping = 0;

                if (subtotal <= 75 && subtotal >= 35)
                {
                    shipping = 12;
                }
                else if (subtotal < 35)
                {
                    shipping = 7;
                }

                lblSubtotal.Text = subtotal.ToString("c");
                lblTax.Text      = tax.ToString("c");
                lblShipping.Text = shipping.ToString("c");
                lblTotal.Text    = (subtotal + tax + shipping).ToString("c");
                //double subtotal = Convert.ToDouble(grdCartItems.Rows[0].Cells[4].Text.Replace("$",""));

                DataTable deets = SqlJacknife.GetDataTable("Get_OrderHistory_Details", parms);
                lblAddress.Text = deets.Rows[0]["ShippingAddress"].ToString();
                lblPayment.Text = deets.Rows[0]["PaymentType"].ToString();
            }
            else
            {
                master.messageNormal("You don't have any Item on order");
            }
        }
Пример #13
0
        private DataRow getCategory(string id)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Cat", id, 4, SqlDbType.Char, ParameterDirection.Input));
            DataSet toSend = SqlJacknife.GetDS("Categ_Get_One", parms);

            return(toSend.Tables[0].Rows[0]);
        }
        /// <summary>
        /// Returns the unverified images that the current admin can verify
        /// </summary>
        /// <param name="ID_Adm"></param>
        /// <returns>A datatable images</returns>
        public DataTable Load_Unverified(int ID_Adm)
        {
            DataTable unverifiedImages          = new DataTable();
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Adm", ID_Adm, 0, SqlDbType.Int, ParameterDirection.Input));

            unverifiedImages = SqlJacknife.GetDataTable("Load_Unverified", parms);
            return(unverifiedImages);
        }
        /// <summary>
        /// Deletes an image
        /// </summary>
        /// <param name="ID_Img"></param>
        /// <returns></returns>
        public bool Delete_Image(int ID_Img)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Img", ID_Img, 0, SqlDbType.Int, ParameterDirection.Input));

            if (SqlJacknife.SendCommand("Delete_Image", parms) != 0)
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Verify a single image. Throws an exception if the verifier and uploader are the same
        /// </summary>
        /// <param name="ID_Img"></param>
        /// <param name="ID_Adm"></param>
        /// <returns>True if the save was succesful</returns>
        public bool VerifyImage(int ID_Img, int ID_Adm, string newLocus)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Adm", ID_Adm, 0, SqlDbType.Int, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@ID_Img", ID_Img, 0, SqlDbType.Int, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@newLocus", newLocus, 150, SqlDbType.NVarChar, ParameterDirection.Input));

            if (SqlJacknife.SendCommand("VerifyImage", parms) != 0)
            {
                return(true);
            }
            return(false);
        }
        protected void CreateAccount()
        {
            using (SqlConnection conn = new SqlConnection(cnnString))
            {
                conn.Open();
                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    String validCode = generateGarble(8);
                    String message   = "Hello, " + fname.Text + ",</br> Please follow the link to validate your account"
                                       + "<p><a href = 'http://*****:*****@ID_cust", null, 0, SqlDbType.Int, ParameterDirection.Output));
                    parms.Add(new SqlJacknife.ParmStruct("@fname", fname.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@mname", mname.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@lname", lname.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@username", username.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@password", password.Text, 50, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@dob", ExtractBirthday(), 0, SqlDbType.Date, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@street", address.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@city", city.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@state", sOrP.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@zip", zip.Text, 10, SqlDbType.NVarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@country", country.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@phone", phone.Text, 10, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@email", email.Text, 50, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@Validate", validCode, 8, SqlDbType.Char, ParameterDirection.Input));


                    string ID = SqlJacknife.SendCommandGetString("CreateCustomer", parms);
                    if (ID != "0")
                    {
                        master.messageSuccess("Account Created Successfully, ID: " + ID.ToString());
                        trans.Commit();
                    }

                    IdeaHeaderAndSide.sendEmail(email.Text, "ideaShopRobot@noreply", "One last step, " + fname.Text, message);
                }
                catch (Exception ex)
                {
                    master.messageLoggedError(ex.Message);
                    IdeaHeaderAndSide.logMessage("IdeaShop-Account Editor: Create Account", ex.Message);
                    trans.Rollback();
                }
            }
        }
        /// <summary>
        /// For saving a fresh image to the database
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="alttext"></param>
        /// <param name="locus"></param>
        /// <param name="ID_Adm"></param>
        /// <returns>True if the save was successful</returns>
        public bool Save_Image(string filename, string alttext, string locus, int ID_Adm)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@fileName", filename, 50, SqlDbType.NVarChar, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@altText", alttext, 50, SqlDbType.NVarChar, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@locus", locus, 150, SqlDbType.NVarChar, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@ID_Adm", ID_Adm, 0, SqlDbType.Int, ParameterDirection.Input));

            if (SqlJacknife.SendCommand("Save_Image", parms) != 0)
            {
                return(true);
            }
            return(false);
        }
        private void LoadCart()
        {
            DataTable dt;
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            int cartID = 0;

            cartID = master.getCartId();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Cart", cartID, 0, SqlDbType.Int, ParameterDirection.Input));
            dt = SqlJacknife.GetDS("spLoadCartItems", parms).Tables[0];
            if (dt.Rows.Count != 0)
            {
                grdCartItems.DataSource = dt;
                grdCartItems.DataBind();

                double subtotal = 0;
                foreach (GridViewRow row in grdCartItems.Rows)
                {
                    subtotal += Convert.ToDouble(row.Cells[4].Text.Substring(1));
                }
                lblSubtotal.Text = subtotal.ToString("c");

                double tax = subtotal * 0.15;

                double shipping = 0;

                if (subtotal <= 75 && subtotal >= 35)
                {
                    shipping = 12;
                }
                else if (subtotal < 35)
                {
                    shipping = 7;
                }
                lblAddress.Text  = Request.Cookies["address"].Value;
                lblPayment.Text  = Session["Payment"].ToString();
                lblSubtotal.Text = subtotal.ToString("c");
                lblTax.Text      = tax.ToString("c");
                lblShipping.Text = shipping.ToString("c");
                lblTotal.Text    = (subtotal + tax + shipping).ToString("c");
                //double subtotal = Convert.ToDouble(grdCartItems.Rows[0].Cells[4].Text.Replace("$",""));
            }
            else
            {
                master.messageNormal("You don't have any Item on order");
            }
        }
        public void DisplaySearchByKeyword(string keyword)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@daWord1", keyword, 50, SqlDbType.VarChar, ParameterDirection.Input));
            DataTable dt = SqlJacknife.GetDS("Prods_by_Keyword", parms, CommandType.StoredProcedure).Tables[0];

            rptProducts.DataSource = dt;
            rptProducts.DataBind();

            if (dt.Rows.Count == 0)
            {
                lblNoResults.Visible = true;
                lblNoResults.Text    = "No results :(";
            }
        }
        /// <summary>
        /// Updates an image
        /// </summary>
        /// <param name="ID_Img"></param>
        /// <param name="fileName"></param>
        /// <param name="alttext"></param>
        /// <param name="locus"></param>
        /// <param name="active"></param>
        /// <returns></returns>
        public bool Update_Image(int ID_Img, string fileName, string alttext, string locus, bool active)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Img", ID_Img, 0, SqlDbType.Int, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@fileName", fileName, 50, SqlDbType.NVarChar, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@altText", alttext, 50, SqlDbType.NVarChar, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@locus", locus, 150, SqlDbType.NVarChar, ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@active", active, 0, SqlDbType.Bit, ParameterDirection.Input));

            if (SqlJacknife.SendCommand("Update_Image", parms) != 0)
            {
                return(true);
            }
            return(false);
        }
        protected void btnContinue_Click(object sender, EventArgs e)
        {
            if (ddlPayment.SelectedIndex <= 0)
            {
                master.messageError("Please select a payment type!");
                return;
            }

            Session["Payment"] = ddlPayment.Text;
            Response.Redirect("Confirmation.aspx");
            return;

            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@ID_Cart", Session["ID_Cart"], 8, System.Data.SqlDbType.Int, System.Data.ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@ShippingAddress", Request.Cookies["address"].Value, 300, System.Data.SqlDbType.NVarChar, System.Data.ParameterDirection.Input));
            parms.Add(new SqlJacknife.ParmStruct("@PaymentType", ddlPayment.Text, 20, System.Data.SqlDbType.NVarChar, System.Data.ParameterDirection.Input));

            try
            {
                if (SqlJacknife.SendCommand("PlaceOrder", parms) == 0)
                {
                    throw new Exception("Order Failed!");
                }
                sendEmail();
            }
            catch (Exception ex)
            {
                master.messageError(ex.Message);
            }



            Response.Cookies.Clear();
            Response.Cookies["ID_Cart"].Expires = DateTime.Now.AddDays(-1);
            String ordered = Session["ID_Cart"].ToString();

            Session["ID_Cart"] = "";
            master.messageError(ddlPayment.Text);

            Response.Redirect("Ordered.aspx?ordered=" + ordered);
        }
        private void tryValidate(String validate)
        {
            try
            {
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                parms.Add(new SqlJacknife.ParmStruct("@Validate", validate, 8, SqlDbType.Char, ParameterDirection.Input));
                DataTable dt    = SqlJacknife.GetDS("ValidateCustomer", parms).Tables[0];
                String    fname = dt.Rows[0]["fname"].ToString();

                String confirmMessage = "Hello " + fname + ",</br>" +
                                        "Your account has been verified and you may now purchase ideas!</br></br>" +
                                        "- The Last Braincell Team";
                master.messageSuccess(dt.Rows[0]["UserName"].ToString() + " has been validated!");
                IdeaHeaderAndSide.sendEmail(dt.Rows[0]["Email"].ToString(), "ideaShopRobot@noreply", "You're In!", confirmMessage);
            }
            catch (Exception ex)
            {
                master.messageError(ex.Message);
            }
        }
 protected void btnArchive_Click(object sender, EventArgs e)
 {
     try
     {
         using (SqlConnection cnn = new SqlConnection(cnnString))
         {
             List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
             parms.Add(new SqlJacknife.ParmStruct("@ID_Cust", lblID.Text, 0, SqlDbType.Int, ParameterDirection.Input));
             if (SqlJacknife.SendCommand("ArchiveAccount", parms) != 0)
             {
                 master.messageSuccess("Account is Archived");
             }
         }
     }
     catch (Exception ex)
     {
         master.messageLoggedError(ex.Message);
         IdeaHeaderAndSide.logMessage("IdeaShop-Account Editor Admin: Archive Account", ex.Message);
     }
 }
        protected void UpdateAccount(int id)
        {
            using (SqlConnection conn = new SqlConnection(cnnString))
            {
                conn.Open();
                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                    parms.Add(new SqlJacknife.ParmStruct("@ID_cust", id, 0, SqlDbType.Int, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@fname", fname.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@mname", mname.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@lname", lname.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@username", username.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@password", password.Text, 50, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@dob", birthDate.Value, 0, SqlDbType.Date, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@street", address.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@city", city.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@state", sOrP.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@zip", zip.Text, 10, SqlDbType.NVarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@country", country.Text, 20, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@phone", phone.Text, 10, SqlDbType.VarChar, ParameterDirection.Input));
                    parms.Add(new SqlJacknife.ParmStruct("@email", email.Text, 50, SqlDbType.VarChar, ParameterDirection.Input));

                    if (SqlJacknife.SendCommand("UpdateAccountUser", parms) != 0)
                    {
                        master.messageSuccess("Account Updated Successfully");
                        trans.Commit();
                    }
                }
                catch (Exception ex)
                {
                    master.messageLoggedError(ex.Message);
                    IdeaHeaderAndSide.logMessage("IdeaShop-Account Editor: Update Account", ex.Message);
                    trans.Rollback();
                }
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

            parms.Add(new SqlJacknife.ParmStruct("@SearchString", txtSearch.Text, 50, SqlDbType.VarChar, ParameterDirection.Input));


            // SqlCommand cmd = new SqlCommand("Customers_by_Keywords", new SqlConnection(cnnString));
            //cmd.CommandType = CommandType.StoredProcedure;

            // SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = SqlJacknife.GetDataTable("Customers_by_Keywords", parms);

            //da.Fill(dt);


            try
            {
                if (dt.Rows.Count != 0)
                {
                    customers.DataSource     = dt;
                    customers.DataTextField  = "username";
                    customers.DataValueField = "ID_Cust";
                    customers.DataBind();
                    customers.SelectedValue = Request.QueryString["IDCust"];
                }
                else
                {
                    master.messageError("Customers not found!");
                }
            }
            catch (Exception ex)
            {
                master.messageError(ex.Message);
            }
        }
Пример #27
0
        private void LoadCart()
        {
            if (master.getCartId() == -1)//(Request.Cookies["ID_Cart"] == null)
            {
                Response.Redirect("default.aspx?messageError=Your cart is empty!");
                return;
            }

            try
            {
                DataTable dt;
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();

                int cartID = 0;
                cartID = master.getCartId();    //Convert.ToInt32(Request.Cookies["ID_Cart"].Value);

                parms.Add(new SqlJacknife.ParmStruct("@ID_Cart", cartID, 0, SqlDbType.Int, ParameterDirection.Input));
                dt = SqlJacknife.GetDS("spLoadCartItems", parms).Tables[0];


                if (dt.Rows.Count != 0)
                {
                    grdCartItems.DataSource = dt;
                    grdCartItems.DataBind();

                    double subtotal = 0;
                    foreach (GridViewRow row in grdCartItems.Rows)
                    {
                        subtotal += Convert.ToDouble(((Label)(row.Cells[3].FindControl("lblSubTotal"))).Text.Substring(1));
                    }
                    lblSubtotal.Text = subtotal.ToString("c");

                    double tax = subtotal * 0.15;

                    double shipping = 0;

                    if (subtotal <= 75 && subtotal >= 35)
                    {
                        shipping = 12;
                    }
                    else if (subtotal < 35)
                    {
                        shipping = 7;
                    }

                    lblSubtotal.Text = subtotal.ToString("c");
                    lblTax.Text      = tax.ToString("c");
                    lblShipping.Text = shipping.ToString("c");
                    lblTotal.Text    = (subtotal + tax + shipping).ToString("c");
                    //double subtotal = Convert.ToDouble(grdCartItems.Rows[0].Cells[4].Text.Replace("$",""));
                }
                else
                {
                    grdCartItems.DataSource = dt;
                    grdCartItems.DataBind();
                    lblSubtotal.Text = 0.ToString("c");
                    lblTax.Text      = 0.ToString("c");
                    lblShipping.Text = 0.ToString("c");
                    lblTotal.Text    = 0.ToString("c");
                    Response.Cookies.Remove("ID_Cart");
                    Response.Cookies["ID_Cart"].Expires = DateTime.Today.AddDays(-1);
                    Response.Redirect("default.aspx?messageError=Your cart is empty!");
                }
            }
            catch (Exception ex)
            {
                master.messageLoggedError(ex.Message);
                IdeaHeaderAndSide.logMessage("IdeaShop-CartPage: Load Cart", ex.Message);
            }
        }
Пример #28
0
        protected void LoginTry(object sender, EventArgs e)
        {
            try
            {
                List <SqlJacknife.ParmStruct> parms = new List <SqlJacknife.ParmStruct>();
                parms.Add(new SqlJacknife.ParmStruct("@UserName", txtLogin.Text, 20, SqlDbType.NVarChar, ParameterDirection.Input));
                parms.Add(new SqlJacknife.ParmStruct("@Password", txtPassword.Text, 15, SqlDbType.NVarChar, ParameterDirection.Input));
                DataTable dt = SqlJacknife.GetDS("Get_User_For_Session", parms).Tables[0];
                setSession("UserName", dt.Rows[0]["UserName"].ToString());
                setSession("ID_Cart", dt.Rows[0]["ID_Cart"].ToString());
                setSession("ID_Cust", dt.Rows[0]["ID_Cust"].ToString());
                setSession("Email", dt.Rows[0]["Email"].ToString());
                setSession("Validated", dt.Rows[0]["Validated"].ToString());
                setSession("IsAdmin", "0");
                setSession("Payment", "");

                if (dt.Rows[0]["Validated"].ToString() != "1")
                {
                    messageError("Please validate your account to make purchases!");
                }


                if (Request.Cookies["ID_Cart"] != null)
                {
                    try
                    {
                        List <SqlJacknife.ParmStruct> parms2 = new List <SqlJacknife.ParmStruct>();
                        if (string.IsNullOrEmpty(Session["ID_Cart"].ToString()))//User doesn't have a cart, give them the current one.
                        {
                            parms2.Add(new SqlJacknife.ParmStruct("@ID_Cart", Request.Cookies["ID_Cart"].Value.ToString(), 20, SqlDbType.Int, ParameterDirection.Input));
                            parms2.Add(new SqlJacknife.ParmStruct("@ID_Cust", dt.Rows[0]["ID_Cust"].ToString(), 20, SqlDbType.Int, ParameterDirection.Input));
                            SqlJacknife.SendCommand("Own_Cart", parms2);
                            setCartId(Convert.ToInt32(Request.Cookies["ID_Cart"].Value.ToString()));
                        }
                        else if (Request.Cookies["ID_Cart"] != null)
                        {
                            parms2.Add(new SqlJacknife.ParmStruct("@FeedMe", Convert.ToInt32(Session["ID_Cart"]), 20, SqlDbType.Int, ParameterDirection.Input));
                            parms2.Add(new SqlJacknife.ParmStruct("@EatMe", Convert.ToInt32(Request.Cookies["ID_Cart"].Value.ToString()), 20, SqlDbType.Int, ParameterDirection.Input));
                            SqlJacknife.SendCommand("MergeCarts", parms2);
                        }

                        Response.Cookies["ID_Cart"].Value   = null;
                        Response.Cookies["ID_Cart"].Expires = DateTime.Now.AddDays(-1);
                    }
                    catch (Exception ex)
                    {
                        messageError(ex.Message);
                    }


                    /*
                     * List<SqlJacknife.ParmStruct> parms2 = new List<SqlJacknife.ParmStruct>();
                     * parms2.Add(new SqlJacknife.ParmStruct("@ID_Cart",Request.Cookies["ID_Cart"].Value.ToString(),20,SqlDbType.Int,ParameterDirection.Input));
                     * parms2.Add(new SqlJacknife.ParmStruct("@ID_Cust", dt.Rows[0]["ID_Cust"].ToString(), 20, SqlDbType.Int, ParameterDirection.Input));
                     * SqlJacknife.SendCommand("Own_Cart",parms2);
                     */
                }

                lblUsername.Text = dt.Rows[0]["UserName"].ToString();
                txtLogin.Text    = txtPassword.Text = "";
                loggedInVisible();
                Response.Redirect("default.aspx");
            }
            catch (Exception ex)
            {
                messageError(ex.Message);
            }
        }
 /// <summary>
 /// Loads all verified images
 /// </summary>
 /// <returns></returns>
 public DataTable Load_Verified()
 {
     return(SqlJacknife.GetDataTable("Load_Verified", new List <SqlJacknife.ParmStruct>()));
 }