protected void btnPlaceOrder_Click(object sender, EventArgs e) { DataTable userDt = (DataTable)Session["UserWholeRecord"]; int customerID = Convert.ToInt32(userDt.Rows[0]["user_id"]); CustomerOrderDetails cod = new CustomerOrderDetails { CustomerID = customerID, GUID = Request.QueryString["id"].ToString(), Address = txtAddress.InnerText, PhoneNumber = txtPhoneNumber.Text, Quantity = ddlProductQuantity.SelectedValue.Equals("-1") ? 1 : ddlProductQuantity.SelectedIndex, TotalPrice = Convert.ToDouble(lblTotalPrice.Text) }; ECommerceBusiness ecb = new ECommerceBusiness { CODObj = cod }; ecb.AddNewCustomerOrderDetails(); Panel panel = OrderBody; panel.Style.Add("display", "none"); panel = pCPOD; panel.Style.Add("display", "none"); lblMessage.Text = "Your order will be placed within 24 hours!"; lblMessage.Style.Add("display", "block"); }
private bool isAlreadyExists() { bool uExists = false; bool eExists = false; User user = new User { Username = txtUsername.Text, Email = txtEmail.Text }; ECommerceBusiness ecb = new ECommerceBusiness { UserObj = user }; DataTable dt = ecb.IsUserNameExists(); if (dt.Rows.Count > 0) { uExists = dt.Rows[0]["UserNameExists"].ToString().Equals("0") ? false : true; } dt = ecb.IsEmailExists(); if (dt.Rows.Count > 0) { eExists = dt.Rows[0]["EmailExists"].ToString().Equals("0") ? false : true; } return((uExists == false && eExists == false) ? false : true); }
protected void repeaterItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("CancelOrder")) { HiddenField hf = (HiddenField)e.Item.FindControl("hiddenField"); int productID = Convert.ToInt32(hf.Value); ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt = (DataTable)Session["UserWholeRecord"]; int userID = Convert.ToInt32(dt.Rows[0]["user_id"].ToString()); Panel p = OrderBody; p.Style.Add("display", "none"); p = pCPOD; p.Style.Add("display", "none"); lblMessage.Text = "Order Cancelled!"; lblMessage.Style.Add("display", "block"); ecb.CancelOrder(productID, userID); } else if (e.CommandName.Equals("ViewProduct")) { HiddenField hf = (HiddenField)e.Item.FindControl("hfGUID"); string productGUID = hf.Value; Response.Redirect("Product.aspx?id=" + productGUID); } }
public void EmailExists(string email) { User user = new User { Email = email }; user.EmailInUse = false; ECommerceBusiness ecb = new ECommerceBusiness { UserObj = user }; DataTable dt = ecb.IsEmailExists(); if (dt.Rows.Count > 0) { user.EmailInUse = dt.Rows[0]["EmailExists"].ToString().Equals("0") ? false : true; } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(user)); }
protected void LoginButtonClickPerformed(object sender, EventArgs e) { Admin admin = new Admin { UserName = txtUsername.Text, password = txtPassword.Text }; ECommerceBusiness ecb = new ECommerceBusiness { AdminObj = admin }; DataTable dt = ecb.SelectAdmin(); if (dt.Rows.Count > 0) { Session["Fullname"] = dt.Rows[0]["FullName"].ToString(); Session["Username"] = dt.Rows[0]["username"].ToString(); Session["Password"] = dt.Rows[0]["Password"].ToString(); Session["Image"] = dt.Rows[0]["ImageUrl"].ToString(); Session["AdminSession"] = "Admin"; Response.Redirect("~/admin/ControlBusiness.aspx"); } else { lblStatus.Text = "Username or password not matched !"; } }
protected void btnAdd_Click(object sender, EventArgs e) { /* * check whether user fill all the required filed or not * server-site validation */ if (IsValid) { Company company = new Company { CompanyName = txtCompanyName.Text, CompanyDescription = taCompanyDescription.InnerText, PartnershipDate = txtDOB.Value }; ECommerceBusiness ecb = new ECommerceBusiness { CompanyObj = company }; ecb.AddNewCompany(); resetForm(); Page.ClientScript.RegisterStartupScript(this.GetType(), "Confirmation", "alert('Successfully added a new patnered company into database')", true); } }
private void SelectAllUser() { ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt = ecb.SelectAllUser(); if (dt.Rows.Count > 0) { gvUserList.DataSource = dt; gvUserList.DataBind(); } }
private void getAllCompanies() { ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt = ecb.getAllCompanies(); if (dt.Rows.Count > 0) { ListItem item = new ListItem("Select Company", "-1"); ddlProductCompany.DataSource = dt; ddlProductCompany.DataBind(); ddlProductCompany.Items.Insert(0, item); } }
private bool changeUserPassword() { string GUID = Request.QueryString["uid"]; string Salt; string Hash = HashingAndSalting.createSaltedHash(txtNewPassword.Text, out Salt); User user = new User(GUID, txtNewPassword.Text, Salt, Hash); ECommerceBusiness ecb = new ECommerceBusiness { UserObj = user }; return(ecb.IsPasswordChanged()); }
protected void btnResetPassword_Click(object sender, EventArgs e) { User user = new User { Email = txtEmail.Text }; ECommerceBusiness ecb = new ECommerceBusiness { UserObj = user }; DataTable dt = ecb.ResetPassword(); if (dt.Rows.Count > 0) { string returnCode = dt.Rows[0]["ReturnCode"].ToString(); if (returnCode.Equals("1")) { string username = dt.Rows[0]["Username"].ToString(); string toEmail = dt.Rows[0]["Email"].ToString(); string uniqueID = dt.Rows[0]["UniqueID"].ToString(); try { SendPasswordResetMail(toEmail, username, uniqueID); lblStatus.Text = "An email with instructions to reset your password is sent to your email address"; lblStatus.ForeColor = System.Drawing.Color.Green; txtEmail.Text = string.Empty; } catch (Exception ex) { lblStatus.Text = "An unknown error occured!"; lblStatus.ForeColor = System.Drawing.Color.Red; } } else { lblStatus.Text = "Email not found!"; lblStatus.ForeColor = System.Drawing.Color.Red; } } else { lblStatus.Text = "Email not found!"; lblStatus.ForeColor = System.Drawing.Color.Red; } }
protected void btnDeleteProduct_Click(object sender, EventArgs e) { if (Session["productID"] == null) { lblDeleteProductStatus.Text = "Please select a product's row in order to delete the user!"; lblDeleteProductStatus.ForeColor = System.Drawing.Color.Red; } else { ECommerceBusiness ecb = new ECommerceBusiness(); ecb.DeleteProduct(Session["productID"].ToString()); SelectAllProduct(); Response.Write("<script>alert('Product Deleted Successfully')</script>"); } }
protected void btnAdd_Click(object sender, EventArgs e) { string report = isValidImage(); if (!report.Equals("valid")) { errorMessage = report; ScriptManager.RegisterStartupScript(this, GetType(), "Error", "invalidImage();", true); } else { string path = "../Uploads/" + imageUpload.FileName; /* * check whether user fill all the required field or not * server-site validation */ if (IsValid) { Product product = new Product { ProductCode = txtProductCode.Text, ProductName = txtProductName.Text, ProductCategory = Convert.ToInt32(ddlProductCategory.SelectedValue), ProductDescription = taProductDesc.InnerText, ProductPrice = txtProductPrice.Text, ProductImage = path, ProductCompany = Convert.ToInt32(ddlProductCompany.SelectedValue), ProductQuantity = Convert.ToInt32(txtProductQuantity.Text) }; ECommerceBusiness ecb = new ECommerceBusiness { ProductObj = product }; ecb.AddNewProduct(); resetForm(); Page.ClientScript.RegisterStartupScript(this.GetType(), "Reg_Conf", "alert('Successfully added a new product into database!')", true); } else { Validation.InnerText = "Please fill up all the necessary fields"; } } }
private void GetCartedProducts(int userID) { ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt = ecb.GetAllCartedProducts(userID); if (dt.Rows.Count > 0) { rpCartedProduct.DataSource = dt; rpCartedProduct.DataBind(); } else { rpCartedProduct.DataSource = dt; rpCartedProduct.DataBind(); lblMessage.Text = "You do not have any carted product!"; } }
private void AddToCart(string productID) { DataTable dt = (DataTable)Session["UserWholeRecord"]; BusinessAccessLayer.Cart cart = new BusinessAccessLayer.Cart { ProductID = Convert.ToInt32(productID), UserID = Convert.ToInt32(dt.Rows[0]["user_id"].ToString()) }; ECommerceBusiness ecb = new ECommerceBusiness { CartObj = cart }; ecb.AddToCart(); }
protected void repeaterItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("RemoveFromCart")) { HiddenField hf = (HiddenField)e.Item.FindControl("hiddenField"); int productID = Convert.ToInt32(hf.Value); ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt = (DataTable)Session["UserWholeRecord"]; int userID = Convert.ToInt32(dt.Rows[0]["user_id"].ToString()); ecb.DeleteCartedProduct(productID, userID); GetCartedProducts(userID); UpdateBadge(); } else if (e.CommandName.Equals("ViewProduct")) { HiddenField hf = (HiddenField)e.Item.FindControl("hfGUID"); string productGUID = hf.Value; Response.Redirect("Product.aspx?id=" + productGUID); } else if (e.CommandName.Equals("OrderProduct")) { HiddenField hf = (HiddenField)e.Item.FindControl("hfGUID"); string productGUID = hf.Value; hf = (HiddenField)e.Item.FindControl("hiddenField"); int productID = Convert.ToInt32(hf.Value); DataTable dt = (DataTable)Session["UserWholeRecord"]; int userID = Convert.ToInt32(dt.Rows[0]["user_id"].ToString()); RemoveFromCart(productID, userID); Response.Redirect("Order.aspx?id=" + productGUID); } }
private void UpdateBadge() { var span = (System.Web.UI.HtmlControls.HtmlGenericControl) this.Master.FindControl("cartBadge"); ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt = (DataTable)Session["UserWholeRecord"]; int userID = Convert.ToInt32(dt.Rows[0]["user_id"].ToString()); dt = ecb.SelectAllCartedProduct(userID); if (dt.Rows.Count == 1) { span.Style.Add("visibility", "visible"); span.InnerText = "1"; } else { span.InnerText = dt.Rows.Count.ToString(); } }
private void GetProductsByProdctId(string productGUID) { ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt = ecb.GetProductsByProductID(productGUID); if (dt == null) { dt = new DataTable(); } if (dt.Rows.Count <= 0) { Panel p = OrderBody; p.Style.Add("display", "none"); p = pCPOD; p.Style.Add("display", "none"); lblMessage.Text = "Sorry something went wrong!"; lblMessage.Style.Add("display", "block"); } else { // TODO ListedProduct.DataSource = dt; ListedProduct.DataBind(); // End TODO // lblProductName.Text = dt.Rows[0]["Product_Name"].ToString(); lblProductCode.Text = dt.Rows[0]["ProductCode"].ToString(); Session["price"] = Convert.ToInt32(dt.Rows[0]["Price"].ToString()); lblTotalPrice.Text = Session["price"].ToString(); DataTable userDt = (DataTable)Session["UserWholeRecord"]; txtCustomerName.Text = userDt.Rows[0]["fullname"].ToString(); int quantity = Convert.ToInt32(dt.Rows[0]["Quantity"].ToString()); InitializeDropDownList(quantity); } }
private void GetProducts(string category) { ECommerceBusiness ecb = new ECommerceBusiness(); DataTable dt; if (category.Equals("all")) { dt = ecb.GetAllProducts(); } else { dt = ecb.GetProducts(category); } if (dt.Rows.Count > 0) { rpProduct.DataSource = dt; rpProduct.DataBind(); //up1.Update(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User user = new User { GlobalUniqueIDForResetPassword = Request.QueryString["uid"] }; ECommerceBusiness ecb = new ECommerceBusiness { UserObj = user }; if (!ecb.IsPasswordResetLinkValid()) { Response.Clear(); Response.Write("<h1 style='color:red;'>Password reset link has expired or invalid link!</h1>"); Response.End(); } } }
public void UserNameExists(string username) { User user = new User(username); user.UserNameInUse = false; ECommerceBusiness ecb = new ECommerceBusiness { UserObj = user }; DataTable dt = ecb.IsUserNameExists(); if (dt.Rows.Count > 0) { user.UserNameInUse = dt.Rows[0]["UserNameExists"].ToString().Equals("0") ? false : true; } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(user)); }
private string retriveSaltedHash() { User user = new User(txtUsername.Text); ECommerceBusiness ecb = new ECommerceBusiness { UserObj = user }; string takeSalt = ecb.RetriveSaltAgainstUser(); string takeHash; if (takeSalt != null) { takeHash = generateTempHashWithSalt(takeSalt); } else { takeHash = null; } return(takeHash); }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { flag = 0; } if (Session["User"] != null) { if (!IsPostBack) { UserName.Text = Session["User"].ToString(); lblUserName.Text = Session["User"].ToString(); if (!string.IsNullOrEmpty(Session["UserImage"].ToString())) { userImage.ImageUrl = Session["UserImage"].ToString(); userImage2.ImageUrl = Session["UserImage"].ToString(); } } DataTable dt = (DataTable)Session["UserWholeRecord"]; int userID = Convert.ToInt32(dt.Rows[0]["user_id"].ToString()); ECommerceBusiness ecb = new ECommerceBusiness(); dt = ecb.SelectAllCartedProduct(userID); string noOfCartedProduct = dt.Rows.Count.ToString(); if (Convert.ToInt32(noOfCartedProduct) > 0) { cartBadge.InnerText = noOfCartedProduct; cartBadge.Style.Add("visibility", "visible"); } } }
protected void addButtonClickPerformed(object sender, EventArgs e) { /* * check whether user fill all the required filed or not * server-site validation */ if (IsValid) { Category category = new Category { CategoryName = txtCategoryName.Text, CategoryDescription = taDescription.InnerText, }; ECommerceBusiness ecb = new ECommerceBusiness { CategoryObj = category }; ecb.AddNewCategory(); resetForm(); Page.ClientScript.RegisterStartupScript(this.GetType(), "Confirmation", "alert('Successfully added a new category into database')", true); } }
private void RemoveFromCart(int productID, int userID) { ECommerceBusiness ecb = new ECommerceBusiness(); ecb.TriggerCartToOrder(productID, userID); }
private void CartedList(int userID) { ECommerceBusiness ecb = new ECommerceBusiness(); Application["CartList"] = ecb.SelectAllCartedProduct(userID); }