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) { 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 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) { //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); } } } } }
// 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)); }
protected void CartGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteItemFromCart") { int selectedRow = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; //CartGridView.SelectRow(selectedRow); int PID = Convert.ToInt32(CartGridView.DataKeys[selectedRow].Values[0]); string userName = (string)CartGridView.DataKeys[selectedRow].Values[1]; int quantity = Convert.ToInt32(CartGridView.DataKeys[selectedRow].Values[2]); IBusinessDataAccount _IBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); if (_IBusinessDataAccount.DeleteCartUpdProducts(PID, userName, quantity)) { Message.Text = "Item successfully deleted from the cart and the database is updated"; Response.Redirect("ViewCart.aspx"); } else { Message.Text = "Not deleted from the cart. Please try again later"; } } }
protected void LoginButton_Click(object sender, EventArgs e) { IBusinessDataAuthentication _IBusinessDataAuthentication = GenericFactory <BusinessLayer, IBusinessDataAuthentication> .CreateInstance(); IBusinessDataAccount _IBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); try { string userName = (string)_IBusinessDataAuthentication.ValidUser(TxtUsername.Text, TxtPassword.Text); if (userName != null) { Message.Text = ""; SessionFacade.USERROLE = (string)_IBusinessDataAccount.GetUserRole(userName); //if(SessionFacade.USERROLE == "Admin") //{ // ((ShoppingMasterPage)Master).AddProductLink.Visible = true; // ((ShoppingMasterPage)Master).UploadImageLink.Visible = true; //} SessionFacade.USERNAME = userName; if (SessionFacade.PAGEREQUESTED != null) { Response.Redirect(SessionFacade.PAGEREQUESTED); } else { Response.Redirect("Home.aspx"); } } else { Message.Text = "Enter Valid Credentials"; } } catch (Exception exception) { throw exception; } }
public ActionResult XferChkToSav(XferChkToSavModel xferModel) { 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(); if (_IBusinessAccount.TransferFromChkgToSav(ticket.Name, savAccountNumber, xferModel.Amount)) { xferModel.ChkAccountBalance = _IBusinessAccount.GetCheckingBalance(ticket.Name); xferModel.SavAccountBalance = _IBusinessAccount.GetSavingBalance(savAccountNumber); xferModel.Amount = 0.0; ViewBag.Message = "Transfer Successful"; } else { ViewBag.Message = "Transfer Unsuccessful"; } return(View(xferModel)); }
// GET: TransferHistory public ActionResult TransferHistory() { List <TransferHistoryModel> xferHistoryModel = new List <TransferHistoryModel>(); string CheckingAccountNumber = FormsAuthentication.FormsCookieName; HttpCookie AuthCookie = HttpContext.Request.Cookies[CheckingAccountNumber]; FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(AuthCookie.Value); ViewBag.CheckingAccountNumber = ticket.Name; IBusinessDataAccount _IBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); DataTable XferHistoryDataTable = _IBusinessDataAccount.GetTransferHistory(ticket.Name); foreach (DataRow rows in XferHistoryDataTable.Rows) { xferHistoryModel.Add(new TransferHistoryModel { FromAccountNum = rows["FromAccountNum"].ToString(), ToAccountNum = rows["ToAccountNum"].ToString(), Date = rows["Date"].ToString(), Amount = rows["Amount"].ToString(), CheckingAccountNumber = rows["CheckingAccountNumber"].ToString() }); } return(View(xferHistoryModel)); }
public ToDosController(IBusinessDataAccount businessDataAccount) { // Reference to the Business Layer _iBusinessDataAccount = businessDataAccount; }
public ToDosController() { // Reference to the Business Layer _iBusinessDataAccount = GenericFactory <BusinessLayer, IBusinessDataAccount> .CreateInstance(); }