Example #1
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");
     }
 }
Example #2
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);
            }
        }
Example #3
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();
        }
        /// <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);
        }
        /// <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);
        }
        /// <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);
        }
 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();
                }
            }
        }
Example #11
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);
            }
        }