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; } }
public ActionResult Login(LoginModel Model, string ReturnUrl) { if (Model.Username == null || Model.Password == null) { // ModelState.AddModelError("Empty", "Username or Password Cannot be empty"); ViewBag.Message = "Username or Password cannot be empty"; return(View()); } else { IBusinessAuthentication _IBusinessAuthentication = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance(); string CheckingAccountNumber = _IBusinessAuthentication.IsValidUser(Model.Username, Model.Password); if (CheckingAccountNumber == null) { ViewBag.Message = "Invalid User"; //ModelState.AddModelError("Valid", "Username or Password is not valid"); return(View()); } else { FormsAuthentication.SetAuthCookie(CheckingAccountNumber, false); if (ReturnUrl == "/" | ReturnUrl == null) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(ReturnUrl)); } } } }
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 AddInCart_Click(object sender, EventArgs e) { decimal amountToBePaid = 0; int selectedItemValue = 0; int updateQuantity = 0; if (Quantity.SelectedValue == "-1") { Message.Text = "Please select a quantity"; } else { selectedItemValue = Convert.ToInt32(Quantity.SelectedValue); updateQuantity = (Convert.ToInt32(productsRow["Inventory"])) - selectedItemValue; amountToBePaid = (itemPrice * selectedItemValue); IBusinessDataAccount _IBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); if (_IBusinessDataAccount.UpdateProducts(PID, updateQuantity)) { UpdateMessage.Text = "Database has been updated"; } else { UpdateMessage.Text = null; } if (_IBusinessDataAccount.AddToCart(SessionFacade.USERNAME, PID, (string)productsRow["ProductSmallDescription"], selectedItemValue, amountToBePaid) == 1) { Message.Text = "Your item has been added to the shopping cart to buy it later"; } else { Message.Text = "Items are not added"; } } }
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 Page_Load(object sender, EventArgs e) { int ID = 0; if (SessionFacade.USERNAME == null) { SessionFacade.PAGEREQUESTED = Request.ServerVariables["HTTP_URL"]; Response.Redirect("Login.aspx"); } else { IBusinessDataAccount _IBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); ID = Convert.ToInt32(Request.QueryString["ID"]); if (ID == 10) { TableName.Text = "Electronics Products"; } else if (ID == 20) { TableName.Text = "Kitchen Products"; } else { TableName.Text = "Luggages"; } ProductsGridView.DataSource = _IBusinessDataAccount.ProductsByID(ID); ProductsGridView.DataBind(); } }
protected void btnlogin_Click(object sender, EventArgs e) { string username = txtusername.Text; string password = txtpassword.Text; IBusinessAuthentication ibau = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance(); string acceslevel = ibau.isValidUser(username, password); if (acceslevel != "") { string roles = ibau.GetRolesForUser(username); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddMinutes(30), false, roles); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie authCookie = new HttpCookie (FormsAuthentication.FormsCookieName, encryptedTicket); Response.Cookies.Add(authCookie); //FormsAuthentication.RedirectFromLoginPage(username.ToString(), true); SessionFacade.USERNAME = username; SessionFacade.ROLE = roles; Response.Redirect(FormsAuthentication.GetRedirectUrl(username, true)); } else { lblStatus.Text = "Invalid login for Requested Page"; } }
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 (SessionFacade.USERNAME == null) { SessionFacade.PAGEREQUESTED = Request.ServerVariables["SCRIPT_NAME"]; Response.Redirect("Login.aspx"); } else { IBusinessDataAccount _IBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); cartDataSet = _IBusinessDataAccount.ViewCart(SessionFacade.USERNAME); // Not working - ask doubt if (cartDataSet.Tables.Count == 0) { Message.Text = "You haven't added items to the cart"; } else { Message.Text = null; foreach (DataTable tables in cartDataSet.Tables) { foreach (DataRow dataRow in tables.Rows) { totalPriceToPay += Convert.ToDecimal(dataRow["Price"]); totalItems += (dataRow["ProductSmallDescription"] + " "); } } //Message.Text = "Total amount to pay : " + totalPriceToPay + " and the products bought are : " + totalItems; CartGridView.DataSource = cartDataSet; CartGridView.DataBind(); } } }
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; } } } }
public BusinessLayer() : this(GenericFactory <Repository, IDataAccount> .CreateInstance(), GenericFactory <Repository, IDataAuthentication> .CreateInstance(), GenericFactory <Repository, AdminFunctions> .CreateInstance()) { }
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 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 btnLogin_Click(object sender, EventArgs e) { IBusinessAbstraction iba = GenericFactory <BusinessAbstraction, IBusinessAbstraction> .CreateInstance(); try { string chkAcctNum = iba.IsValidUser(Utils.StripPunctuation(txtUsername.Text), Utils.StripPunctuation(txtPassword.Text)); if (chkAcctNum != "") { lblStatus.Text = "Welcome User"; SessionFacade.USERNAME = txtUsername.Text; SessionFacade.CHECKINGACCTNUM = chkAcctNum; if (SessionFacade.PAGEREQUESTED != null) { Response.Redirect(SessionFacade.PAGEREQUESTED); } } else { lblStatus.Text = "Invalid User.."; } } catch (Exception ex) { lblStatus.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { //Quantity.Items.Clear(); int InStockValue = 0; if (SessionFacade.USERNAME == null) { SessionFacade.PAGEREQUESTED = Request.ServerVariables["HTTP_URL"]; Response.Redirect("Login.aspx"); } else { PID = Convert.ToInt32(Request.QueryString["ProductID"]); IBusinessDataAccount _IBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); productsDataSet = _IBusinessDataAccount.GetProductsByPID(PID); productsDataTable = productsDataSet.Tables[0]; productsRow = productsDataTable.Rows[0]; PSmallDesc.Text = (string)productsRow["ProductSmallDescription"]; PLargeDesc.Text = (string)productsRow["ProductLargeDescription"]; PImage.Text = (string)productsRow["ProductImage"]; itemPrice = Convert.ToDecimal(productsRow["Price"]); Price.Text = Convert.ToString(productsRow["Price"]); InStockValue = Convert.ToInt32(productsRow["Inventory"]); InStock.Text = Convert.ToString(productsRow["Instock"]); if (InStockValue == 0) { Message.Text = "You cannot purchase this item at the moment"; Quantity.Visible = false; QuantityLable.Visible = false; AddInCart.Visible = false; BuyNow.Visible = false; } else { Message.Text = null; AddInCart.Visible = true; Quantity.Visible = true; QuantityLable.Visible = true; BuyNow.Visible = true; if (!IsPostBack) { string items = null; ListItem listItem = null; for (int i = 1; i <= InStockValue; i++) { if (i == 1) { listItem = new ListItem("Select Quantity", "-1"); Quantity.Items.Add(listItem); } items = Convert.ToString(i); listItem = new ListItem(items, items); Quantity.Items.Add(listItem); } } } } }
protected override void Initialize(RequestContext requestContext) { iBusinessShop = GenericFactory <BusinessShop, IBusinessShop> .CreateInstance(); iBusinessAuth = GenericFactory <BusinessShop, IBusinessAuth> .CreateInstance(); base.Initialize(requestContext); }
public RepositoryAbstraction() { // _irepdacc = GenericFactory<RepositoryMySql, IRepositoryDataAccount>.CreateInstance(); // _irepdauth = GenericFactory<RepositoryMySql, IRepositoryDataAuthentication>.CreateInstance(); _irepdacc = GenericFactory <Repository, IRepositoryDataAccount> .CreateInstance(); _irepdauth = GenericFactory <Repository, IRepositoryDataAuthentication> .CreateInstance(); }
protected override void Initialize(RequestContext requestContext) { if (_business == null) { _business = GenericFactory <BusinessLayer, IBusinessAccount> .CreateInstance(); } base.Initialize(requestContext); }
protected override void Initialize(RequestContext requestContext) { if (AuthService == null) { AuthService = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance(); } base.Initialize(requestContext); }
public ActionResult TransferHistoryRetrieve() { TransferHistoryList history = new TransferHistoryList(); string username = HttpContext.User.Identity.Name; IBusinessAccount iba = GenericFactory <BusinessLayer, IBusinessAccount> .CreateInstance(); string checkingAccountNumber = iba.GetCheckingAccountNumber(username); history.transferHistoryList = iba.GetTransferHistory(checkingAccountNumber); return(View(history)); }
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; } } }
public ActionResult SavingtoChecking() { Transfer chkToSav = new Transfer(); string username = HttpContext.User.Identity.Name; IBusinessAccount iba = GenericFactory <BusinessLayer, IBusinessAccount> .CreateInstance(); string chkAcctNum = iba.GetCheckingAccountNumber(username); chkToSav.chkBalance = iba.GetCheckingBalance(chkAcctNum); chkToSav.savBalance = iba.GetSavingBalance(chkAcctNum + "1"); chkToSav.amtToTransfer = 0; chkToSav.status = ""; return(View(chkToSav)); }
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); } }
void ShowTransferHistory(string chkAcctNum) { try { IBusinessAbstraction iba = GenericFactory <BusinessAbstraction, IBusinessAbstraction> .CreateInstance(); List <TransferHistory> TList = iba.GetTransferHistory(chkAcctNum); gv1.DataSource = TList; gv1.DataBind(); } catch (Exception ex) { lblStatus.Text = ex.Message; } }
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 (SessionFacade.USERNAME == null) { SessionFacade.PAGEREQUESTED = Request.ServerVariables["SCRIPT_NAME"]; Response.Redirect("Login.aspx"); } IBusinessAccount iba = GenericFactory <BusinessLayer, IBusinessAccount> .CreateInstance(); string chkAcctNum = SessionFacade.CHECKINGACCTNUM; string savAcctNum = chkAcctNum + "1"; lblCheckingBalance.Text = iba.GetCheckingBalance(chkAcctNum).ToString(); lblSavingBalance.Text = iba.GetSavingBalance(savAcctNum).ToString(); }
// GET: XferChkToSav public ActionResult XferChkToSav() { string checkingAccountNumber = FormsAuthentication.FormsCookieName; HttpCookie authCookie = HttpContext.Request.Cookies[checkingAccountNumber]; FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); ViewBag.CheckingAccountNumber = ticket.Name; string savAccountNumber = ticket.Name + "1"; IBusinessDataAccount _IBusinessAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); XferChkToSavModel xferModel = new XferChkToSavModel(); xferModel.ChkAccountBalance = _IBusinessAccount.GetCheckingBalance(ticket.Name); xferModel.SavAccountBalance = _IBusinessAccount.GetSavingBalance(savAccountNumber); return(View(xferModel)); }