protected void btnAddProduct_Click(object sender, EventArgs e) { try { string catId = ddlCategory.SelectedItem.Value; string ProdName = txtShortDesc.Text; string Longdesc = txtLongDesc.Text; pImage = lblProdImage.Text; string price = txtPrice.Text; string Inventory = txtInventory.Text; string ShippingCost = txtShipping.Text; string inStock = "0"; if (chkInStock.Checked == true) { inStock = "1"; } IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); int rows = ibf.InsertProducts(catId, ProdName, Longdesc, pImage, price, inStock, Inventory, ShippingCost); if (rows > 0) { lblStatus.Text = "Product Added successfully"; } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string catID = Request["catID"]; if (catID == null) { return; } catID = Utils.StripPunctuation(catID); SessionFacade.CATID = catID; try { IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); List <Products> Plist = ibf.GetProductsByCategory(catID); gv1.DataSource = Plist; gv1.DataBind(); } catch (Exception ex) { lblStatus.Text = ex.Message; } } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { string pid = lblProductID.Text; string shortDesc = txtShortDesc.Text; string LongDesc = txtLongDesc.Text.Replace("'", "''"); string price = txtPrice.Text; string inStock = "0"; bool InStock = chkInStock.Checked; if (InStock == true) { inStock = "1"; } string pImage = lblProdImage.Text; string Inventory = txtInventory.Text; IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); int rows = ibf.UpdateProducts(shortDesc, LongDesc, pImage, price, inStock, Inventory, pid); if (rows > 0) { lblStatus.Text = "Product specs updated successfully"; } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
protected void btnAddUsers_Click(object sender, EventArgs e) { try { string username = txtusername.Text; string pwd = txtpassword.Text; string pHint = txtpaswordques.Text; string pAns = txtpasswordans.Text; IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); bool check = ibf.checkUsername(username); if (check) { int rows = ibf.RegisterUsers(username, pwd, pHint, pAns); if (rows > 0) { lblStatus.Text = "User added successfully"; } } else { lblStatus.Text = "Username already exists"; } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); dt = ibf.getProductCategories(); if (SessionFacade.ROLE != null) { if (SessionFacade.ROLE == "ElectronicsManager") { lblCategory.Text = dt.Rows[0]["CatDesc"].ToString(); category = dt.Rows[0]["CatID"].ToString(); } else if (SessionFacade.ROLE == "LuggageManager") { lblCategory.Text = dt.Rows[2]["CatDesc"].ToString(); category = dt.Rows[2]["CatID"].ToString(); } else if (SessionFacade.ROLE == "BeautyManager") { lblCategory.Text = dt.Rows[4]["CatDesc"].ToString(); category = dt.Rows[4]["CatID"].ToString(); } else if (SessionFacade.ROLE == "SportsManager") { lblCategory.Text = dt.Rows[3]["CatDesc"].ToString(); category = dt.Rows[3]["CatID"].ToString(); } else if (SessionFacade.ROLE == "KitchenManager") { lblCategory.Text = dt.Rows[1]["CatDesc"].ToString(); category = dt.Rows[1]["CatID"].ToString(); } } }
protected void btnUpdateInfo_Click(object sender, EventArgs e) { string uid = ""; if (Page.IsValid) { try { if (SessionFacade.CUSTOMERID != null) { uid = (string)SessionFacade.CUSTOMERID; string street = txtStreet.Text.Trim(); string city = txtCity.Text; string state = txtState.Text; string zipcode = txtZipcode.Text; string ccnum = txtCCNumber.Text; string cctype = ddlCCType.SelectedItem.ToString(); string expdate = txtExpiration.Text; string email = txtEmail.Text; IBusinessFunctions ibaf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); int res = ibaf.UpdateCustomerInfo(uid, street, city, state, zipcode, ccnum, cctype, expdate, email); if (res != null) { lblStatus.Text = "Updated successfully"; } } } catch (Exception ex) { lblStatus.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string uid = ""; if (SessionFacade.CUSTOMERID != null) { uid = (string)SessionFacade.CUSTOMERID; try { IBusinessFunctions ibaf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); DataTable dt = ibaf.GetCustomerInfo(uid); lblfirstname.Text = dt.Rows[0]["FirstName"].ToString(); lbllastname.Text = dt.Rows[0]["LastName"].ToString(); txtStreet.Text = dt.Rows[0]["Address"].ToString(); txtCity.Text = dt.Rows[0]["City"].ToString();; txtState.Text = dt.Rows[0]["State"].ToString(); txtZipcode.Text = dt.Rows[0]["Zipcode"].ToString(); txtCCNumber.Text = dt.Rows[0]["CCNumber"].ToString(); txtExpiration.Text = dt.Rows[0]["CCExpiration"].ToString(); txtEmail.Text = dt.Rows[0]["Email"].ToString(); } catch (Exception ex) { lblStatus.Text = ex.Message; } } } }
protected void btnUpdate_Click(object sender, EventArgs e) { Session["MYCARTOLD"] = mycart.Clone(); mycart.list.Clear(); Cart newcart = new Cart(); int i = 0; foreach (GridViewRow row in gv1.Rows) { if (i < gv1.Rows.Count - 1) { CartItem item = new CartItem(); if (row.RowType == DataControlRowType.DataRow) { dl = (TextBox)row.FindControl("txtqty"); item.PID = gv1.Rows[i].Cells[0].Text; item.PName = gv1.Rows[i].Cells[1].Text; item.Price = gv1.Rows[i].Cells[2].Text; item.ShippingCost = gv1.Rows[i].Cells[4].Text; item.Qty = dl.Text; newcart.list.Add(item); } i++; } } Session["MyCart"] = newcart; IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); dt = ibf.ShowShoppingCart(newcart); refresh(dt); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string pid = ""; string dd = Request["PID"]; if (dd == null) { pid = "-1"; } else { pid = Request["PID"]; } try { IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); DataTable dt = ibf.GetProductDetails(pid); int rows = dt.Rows.Count; if (rows == 0) { lblStatus.Text = "No Product ID was specified, please " + "go to View Products Page and select a product first"; } else { string catID = dt.Rows[0]["CatID"].ToString(); string catDesc = ibf.getCategoryDesc(catID); lblCategory.Text = catDesc; lblProductID.Text = dt.Rows[0]["ProductID"].ToString(); txtShortDesc.Text = dt.Rows[0]["ProductSDesc"].ToString(); txtLongDesc.Text = dt.Rows[0]["ProductLDesc"].ToString(); txtPrice.Text = dt.Rows[0]["Price"].ToString(); lblProdImage.Text = dt.Rows[0]["ProductImage"].ToString(); bool inStock = (bool)dt.Rows[0]["InStock"]; if (inStock == true) { chkInStock.Checked = true; } else { chkInStock.Checked = false; } txtInventory.Text = dt.Rows[0]["Inventory"].ToString(); imgProduct.ImageUrl = "../PImages/" + lblProdImage.Text; } } catch (Exception ex) { lblStatus.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); dt = ibf.getProductCategories(); for (int i = 0; i < dt.Rows.Count; i++) { ddlCategory.Items.Add(dt.Rows[i]["CatDesc"].ToString()); ddlCategory.Items[i].Value = dt.Rows[i]["CatID"].ToString(); } } }
protected void removeItem_Command(object sender, CommandEventArgs e) { if (e.CommandName == "Remove") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gv1.Rows[index]; mycart = (Cart)Session["MyCart"]; mycart.list.RemoveAt(index); IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); dt = ibf.ShowShoppingCart(mycart); refresh(dt); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (SessionFacade.ROLE != null) { if (SessionFacade.ROLE == "ElectronicsManager") { catID = "10"; } else if (SessionFacade.ROLE == "LuggageManager") { catID = "30"; } else if (SessionFacade.ROLE == "BeautyManager") { catID = "50"; } else if (SessionFacade.ROLE == "SportsManager") { catID = "40"; } else if (SessionFacade.ROLE == "KitchenManager") { catID = "20"; } } if (catID == null) { return; } catID = Utils.StripPunctuation(catID); SessionFacade.CATID = catID; try { IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); List <Products> Plist = ibf.GetProductsByCategory(catID); gv1.DataSource = Plist; gv1.DataBind(); } catch (Exception ex) { lblStatus.Text = ex.Message; } } }
protected void btnRegister_Click(object sender, EventArgs e) { if (Page.IsValid) { try { string uname = txtUsername.Text; string fname = txtFirstName.Text; string lname = txtLastName.Text; string street = txtAddress.Text; string city = txtCity.Text; string state = txtState.Text; string zipcode = txtZipcode.Text; string email = txtEmail.Text; string ccnum = txtCCNumber.Text; string expdate = txtCCExpiration.Text; string cctype = ddlCCType.SelectedItem.ToString(); string password = txtPW.Text; string phint = txtPWHintQ.Text; string pAns = txtPWHintA.Text; IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); IBusinessAuthentication ibu = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance(); bool isvalidUsername = ibf.checkUsername(uname); if (isvalidUsername) { lblStatus.Text = "Please choose a different Username as this already exists"; throw new Exception("duplicate username"); } else { int regusers = ibf.RegisterUsers(uname, password, phint, pAns); string userId = ibu.isValidUser(uname, password); int rows_affected = ibf.RegisterCustomer(userId, fname, lname, street, city, state, zipcode, ccnum, cctype, expdate, email); if (rows_affected > 0) { SessionFacade.CUSTOMERID = userId; Response.Redirect("ConfirmCheckOut.aspx"); } } } catch (Exception ex) { lblStatus.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["MyCart"] == null) { Session["MyCart"] = mycart; } else { mycart = (Cart)Session["MyCart"]; } if (!IsPostBack) { IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); dt = ibf.ShowShoppingCart(mycart); refresh(dt); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["MyCart"] == null) { Session["MyCart"] = myCart; } else { myCart = (Cart)Session["MyCart"]; } string PID = Request["PID"]; IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); dt = ibf.GetProductDetails(PID); lblProdDesc.Text = dt.Rows[0]["ProductSDesc"].ToString(); string price = dt.Rows[0]["Price"].ToString(); SessionFacade.PRODUCTID = dt.Rows[0]["ProductId"].ToString(); SessionFacade.PRODNAME = dt.Rows[0]["ProductSDesc"].ToString(); lblPrice.Text = "$" + price.Substring(0, 5); SessionFacade.PRICE = price.Substring(0, 5); string shippingcost = dt.Rows[0]["ShippingCost"].ToString(); shippingcost = shippingcost.Substring(0, 4); SessionFacade.SHIPPING = shippingcost; if (shippingcost == "0.00") { lblShipping.Text = "Free Shipping"; } else { lblShipping.Text = shippingcost; } if (!IsPostBack) { ddl.DataSource = Enumerable.Range(1, 15); ddl.DataBind(); } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
protected void btnRegisterRoles_Click(object sender, EventArgs e) { try { string roleName = txtRoleName.Text; string roleDesc = txtRoleDesc.Text; IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); int rows = ibf.RegisterNewRole(roleName, roleDesc); if (rows > 0) { lblStatus.Text = "Role added successfully"; } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
protected void btnAssignRole_Click(object sender, EventArgs e) { try { string userId = ddlUserNames.SelectedItem.Value; string roleId = ddlRoles.SelectedItem.Value; IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); int rows = ibf.RegisterRoles(userId, roleId); if (rows > 0) { lblStatus.Text = "Role assigned successfully"; } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IBusinessFunctions ibf = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance(); dt = ibf.DisplayUsers(); dt1 = ibf.DisplayRoles(); for (int i = 0; i < dt.Rows.Count; i++) { ddlUserNames.Items.Add(dt.Rows[i]["Username"].ToString()); ddlUserNames.Items[i].Value = dt.Rows[i]["UserID"].ToString(); } for (int i = 0; i < dt1.Rows.Count; i++) { ddlRoles.Items.Add(dt1.Rows[i]["Role"].ToString()); ddlRoles.Items[i].Value = dt1.Rows[i]["RoleID"].ToString(); } } }