protected void btnAdd_Click(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { if (Request.QueryString["proc_id"] != null) { int proc_id = Convert.ToInt32(Request.QueryString["proc_id"]); tblProcessor p = db.tblProcessors.FirstOrDefault(v => v.proc_id == proc_id); p.proc_name = tbName.Text; p.proc_desc = tbDesc.Text; db.SaveChanges(); lblStatus.Text = "Processor updated successfully!"; Response.Redirect("catagoriesrecord.aspx"); } else { db.addProc(tbName.Text, tbDesc.Text); db.SaveChanges(); tbName.Text = ""; tbDesc.Text = ""; lblStatus.Text = "New processor added successfully!"; } } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Session["ItemList"] != null) { List <int> lst = new List <int>(); lst = (List <int>)Session["ItemList"]; string ItemList = ""; foreach (var item in lst) { ItemList += (ItemList == "" ? "" : ",") + item; } using (var db = new bigshopeEntities()) { var query = db.addToCart(ItemList); GV.DataSource = query; GV.DataBind(); } } }
protected void GV_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "delete") { List <int> lst = new List <int>(); lst = (List <int>)Session["ItemList"]; lst.Remove(Convert.ToInt32(e.CommandArgument)); string itemList = ""; foreach (var item in lst) { itemList += (itemList == "" ? "" : ",") + item; } using (var db = new bigshopeEntities()) { var query = db.addToCart(itemList); GV.DataSource = query; GV.DataBind(); } Session["ItemList"] = lst; } }
protected void btnAdd_Click(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { if (Request.QueryString["brnd_id"] != null) { int brnd_id = Convert.ToInt32(Request.QueryString["brnd_id"]); tblBrand b = db.tblBrands.FirstOrDefault(v => v.brnd_id == brnd_id); b.brnd_name = tbName.Text; b.brnd_desc = tbDesc.Text; db.SaveChanges(); lblStatus.Text = "Brands updated successfully!"; Response.Redirect("catagoriesrecord.aspx"); } else { db.addBrands(tbName.Text, tbDesc.Text); db.SaveChanges(); tbName.Text = ""; tbDesc.Text = ""; lblStatus.Text = "Brand added successfully!"; } } }
protected void Page_Load(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { var q = db.showProducts(); } }
protected void btnAdd_Click(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { if (Request.QueryString["gen_id"] != null) { int gen_id = Convert.ToInt32(Request.QueryString["gen_id"]); tblGen g = db.tblGens.FirstOrDefault(v => v.gen_id == gen_id); g.gen_name = tbName.Text; g.gen_desc = tbDesc.Text; db.SaveChanges(); lblStatus.Text = "Generation updated successfully!"; Response.Redirect("catagoriesrecord.aspx"); } else { db.addGenration(tbName.Text, tbDesc.Text); db.SaveChanges(); tbName.Text = ""; tbDesc.Text = ""; lblStatus.Text = "New gen added successfully!"; } } }
private void FillClients() { using (var db = new bigshopeEntities()) { var query = db.showCustomers(); GV.DataSource = query; GV.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { var query = db.getOrder(); GV.DataSource = query; GV.DataBind(); } }
private void FillProducts() { using (var db = new bigshopeEntities()) { var query = db.showProducts(); GV.DataSource = query; GV.DataBind(); } }
protected void btnAdd_Click(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { if (Request.QueryString["prod_id"] != null) { int prod_id = Convert.ToInt32(Request.QueryString["prod_id"]); tblProduct p = db.tblProducts.FirstOrDefault(v => v.prod_id == prod_id); p.prod_name = tbName.Text; p.prod_desc = tbDesc.Text; p.prod_price = Convert.ToInt32(tbPrice.Text); p.prod_qnty = Convert.ToInt32(tbQty.Text); p.prod_ram = tbRAM.Text; db.SaveChanges(); Response.Redirect("productrecord.aspx"); } else { //Forign Keys int brnd_key = Convert.ToInt32(slctBrand.SelectedValue); int proc_key = Convert.ToInt32(slctProc.SelectedValue); int gen_key = Convert.ToInt32(slctGen.SelectedValue); String img = fileImage.FileName.ToString(); int prod_qnty = Convert.ToInt32(tbQty.Text); string folderPath = Server.MapPath("Files/"); //Check whether Directory (Folder) exists. if (Directory.Exists(folderPath) != true) { //If Directory (Folder) does not exists Create it. Directory.CreateDirectory(folderPath + fileImage.FileName); } //Save the File to the Directory (Folder). fileImage.SaveAs(folderPath + Path.GetFileName(fileImage.FileName)); db.addProducts(tbName.Text, tbDesc.Text, tbPrice.Text, img, prod_qnty, tbRAM.Text, brnd_key, proc_key, gen_key); lblStatus.Text = "Product added successfully!"; tbName.Text = ""; tbDesc.Text = ""; tbPrice.Text = ""; tbQty.Text = ""; tbRAM.Text = ""; db.SaveChanges(); } } }
protected void GV_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "delete") { using (var db = new bigshopeEntities()) { int client_id = Convert.ToInt32(e.CommandArgument); db.deleteCustomer(client_id); db.SaveChanges(); FillClients(); } } }
protected void GV_Gen_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "edit") { Response.Redirect("setupgen.aspx?gen_id=" + e.CommandArgument); } else if (e.CommandName == "delete") { using (var db = new bigshopeEntities()) { int gen_id = Convert.ToInt32(e.CommandArgument); db.deleteGen(gen_id); FillCatagories(); } } }
private void FillCatagories() { using (var db = new bigshopeEntities()) { var query_brnd = db.showBrands(); GV_Brnds.DataSource = query_brnd; GV_Brnds.DataBind(); var query_proc = db.showProcessor(); GV_Proc.DataSource = query_proc; GV_Proc.DataBind(); var query_gen = db.showGen(); GV_Gen.DataSource = query_gen; GV_Gen.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["gen_id"] != null) { using (var db = new bigshopeEntities()) { int gen_id = Convert.ToInt32(Request.QueryString["gen_id"]); tblGen g = db.tblGens.FirstOrDefault(v => v.gen_id == gen_id); tbName.Text = g.gen_name; tbDesc.Text = g.gen_desc; } } }
protected void GV_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "edit") { Response.Redirect("setupproducts.aspx?prod_id=" + e.CommandArgument); } else if (e.CommandName == "delete") { using (var db = new bigshopeEntities()) { int prod_id = Convert.ToInt32(e.CommandArgument); db.deleteProduct(prod_id); db.SaveChanges(); FillProducts(); } } }
protected void Page_Load(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { var query = db.showBrands(); DLBrnd.DataSource = query; DLBrnd.DataBind(); var qury = db.showProcessor(); DLProc.DataSource = qury; DLProc.DataBind(); var qry = db.showGen(); DLGen.DataSource = qry; DLGen.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["prod_id"] != null) { using (var db = new bigshopeEntities()) { int prod_id = Convert.ToInt32(Request.QueryString["prod_id"]); tblProduct p = db.tblProducts.FirstOrDefault(v => v.prod_id == prod_id); tbName.Text = p.prod_name; tbDesc.Text = p.prod_desc; tbPrice.Text = Convert.ToString(p.prod_price); tbQty.Text = Convert.ToString(p.prod_qnty); tbRAM.Text = p.prod_ram; } } using (var db = new bigshopeEntities()) { var query_brnd = db.showBrands(); slctBrand.DataSource = query_brnd; slctBrand.DataValueField = "brnd_id"; slctBrand.DataTextField = "brnd_name"; slctBrand.DataBind(); slctBrand.Items.Insert(0, new ListItem("-- Select a brand --", "0")); var query_proc = db.showProcessor(); slctProc.DataSource = query_proc; slctProc.DataValueField = "proc_id"; slctProc.DataTextField = "proc_name"; slctProc.DataBind(); slctProc.Items.Insert(0, new ListItem("-- Select a processor --", "0")); var query_gen = db.showGen(); slctGen.DataSource = query_gen; slctGen.DataValueField = "gen_id"; slctGen.DataTextField = "gen_name"; slctGen.DataBind(); slctGen.Items.Insert(0, new ListItem("-- Select a generation --", "0")); } }
protected void btnLogin_Click(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { var query = db.adminLogin(tbEmail.Text, tbPassword.Text).ToList(); if (query.Count > 0) { Session["username"] = query[0].adminName; Session.Timeout = 720; Response.Redirect("dashboard.aspx"); } else { lblStatus.Text = "Invalid username or password"; } } }
protected void btnLogin_Click(object sender, EventArgs e) { using (var db = new bigshopeEntities()) { var query = db.loginCustomer(tbUser.Text, EncDec.Encrypt(tbPassword.Text)).ToList(); if (query.Count > 0) { Session["customer_id"] = query[0].customer_id; Session["email"] = query[0].customer_email; Session.Timeout = 720; Response.Redirect("profile.aspx"); } else { lblLoginStatus.Text = "Invalid username or password"; } } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } using (var db = new bigshopeEntities()) { if (Request.QueryString["prod_id"] != null) { int prod_id = Convert.ToInt32(Request.QueryString["prod_id"]); var query = db.showProdDetails(prod_id); RP.DataSource = query; RP.DataBind(); } else { Response.Redirect("collection.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["customer_id"] != null) { // Auto fill the entire form using (var db = new bigshopeEntities()) { int customer_id = Convert.ToInt32(Session["customer_id"]); tblCustomer c = db.tblCustomers.FirstOrDefault(v => v.customer_id == customer_id); tbFName.Text = c.customer_name; tbLName.Text = c.customer_surname; tbEmail.Text = c.customer_email; tbPhone.Text = c.customer_phone; tbAddress.Text = c.customer_address; tbCity.Text = c.customer_city; tbState.Text = c.customer_state; tbPost.Text = Convert.ToString(c.customer_zip); tbPass.Enabled = false; tbCnfrmPass.Enabled = false; SetFocus(tbCardNo); } } }
protected void btnCheckOut_Click(object sender, EventArgs e) { var gateway = new StripeGateway("sk_test_Biqolmcf9wmzviLy2J0xHfjg"); var cardToken = gateway.Post(new CreateStripeToken { Card = new StripeCard { Name = tbFName.Text + tbLName.Text, Number = tbCardNo.Text, Cvc = tbCVC.Text, ExpMonth = Convert.ToInt32(tbMonth.Text), ExpYear = Convert.ToInt32(tbYear.Text), AddressLine1 = tbAddress.Text, AddressLine2 = tbAddress.Text, AddressZip = tbCity.Text, AddressState = tbState.Text, AddressCountry = "Pakistan", }, }); var customer = gateway.Post(new CreateStripeCustomerWithToken { Card = cardToken.Id, Description = "Purchasing Purpose", Email = tbEmail.Text, }); var temp = customer.Id; var charge = gateway.Post(new ChargeStripeCustomer { Amount = 100 * 10, Customer = customer.Id, Currency = "usd", Description = "Test Charge Customer", }); using (var db = new bigshopeEntities()) { tblCustomer cus = new tblCustomer(); cus.customer_name = tbFName.Text; cus.customer_surname = tbLName.Text; cus.customer_email = tbEmail.Text; cus.customer_phone = tbPhone.Text; cus.customer_address = tbAddress.Text; cus.customer_city = tbCity.Text; cus.customer_address = tbAddress.Text; cus.customer_city = tbCity.Text; cus.customer_state = tbState.Text; cus.customer_zip = Convert.ToInt32(tbPost.Text); cus.customer_password = EncDec.Encrypt(tbPass.Text); //cus.customer_stripe_id = "sk_test_Biqolmcf9wmzviLy2J0xHfjg"; cus.customer_stripe_id = temp; db.tblCustomers.Add(cus); db.SaveChanges(); // Order Insertion tblOrder order = new tblOrder(); order.order_prod_id = 1; order.order_total_amount = Request.Cookies["grandTotal"].Value.ToString(); order.order_time = DateTime.Now; db.tblOrders.Add(order); db.SaveChanges(); //sendMail(); Response.Redirect("thanks_for_shopping.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["brnd_id"] != null) { using (var db = new bigshopeEntities()) { int brnd_id = Convert.ToInt32(Request.QueryString["brnd_id"]); var qryBrnd = db.showProdByBrnds(brnd_id); RP.DataSource = qryBrnd; RP.DataBind(); } } else if (Request.QueryString["proc_id"] != null) { using (var db = new bigshopeEntities()) { int proc_id = Convert.ToInt32(Request.QueryString["proc_id"]); var qryProc = db.showProdByProc(proc_id); RP.DataSource = qryProc; RP.DataBind(); } } else if (Request.QueryString["gen_id"] != null) { using (var db = new bigshopeEntities()) { int gen_id = Convert.ToInt32(Request.QueryString["gen_id"]); var qryGen = db.showProdByProc(gen_id); RP.DataSource = qryGen; RP.DataBind(); } } else if (Request.QueryString["search"] != null) { using (var db = new bigshopeEntities()) { var qrySrch = db.searchProducts(Request.QueryString["search"].ToString()); RP.DataSource = qrySrch; RP.DataBind(); } } else { using (var db = new bigshopeEntities()) { var query = db.showProducts(); RP.DataSource = query; RP.DataBind(); var queryBrnd = db.showBrands(); DLBrnd.DataSource = queryBrnd; DLBrnd.DataBind(); var quryProc = db.showProcessor(); DLProc.DataSource = quryProc; DLProc.DataBind(); var qryGen = db.showGen(); DLGen.DataSource = qryGen; DLGen.DataBind(); } } }