protected void SeeShoppingBag_Click(object sender, EventArgs e) { User temp = (User)Session["user"]; if (temp == null) { Response.Write("<script>alert('על מנת לרכוש מוצרים עליך להיות לקוח רשום')</script>"); Response.Write("<script>window.open('http://localhost:49675/GuestHome.aspx');</script>"); return; } ShoppingBag sb = (ShoppingBag)Session["myShoppingBag"]; if (sb == null || sb.isEmpty()) { Response.Write("<script>alert('הסל ריק')</script>"); return; } Response.Write("<script>window.open('http://localhost:49675/UserShoppingBag.aspx','_blank');</script>"); }
protected void CheckoutButton_Click(object sender, EventArgs e) { User temp = (User)Session["user"]; if (temp == null) { Response.Write("<script>alert('על מנת לרכוש מוצרים עליך להיות לקוח רשום')</script>"); Response.Write("<script>window.open('http://localhost:49675/GuestHome.aspx');</script>"); return; } ShoppingBag sb = (ShoppingBag)Session["myShoppingBag"]; if (sb == null || sb.isEmpty()) { Response.Write("<script>alert('הסל ריק')</script>"); return; } //delete all the prescription from database presList = (List <DataSet>)Session["presList"]; int presId; PrescriptioService ps = new PrescriptioService(); if (presList != null) { foreach (DataSet d in presList) { presId = Convert.ToInt32(d.Tables[0].Rows[0]["PrescriptionId"].ToString()); ps.DeletePrescription(presId); } } //update all the medicine stock according to the current count Pharmcy.PharmcyWS webser = new Pharmcy.PharmcyWS(); int totalPrice = sb.GetTotalPrice(); List <MedicineInBag> medList = sb.GetProducts(); int countOfMedicine = 0, size = sb.getSize(), index = 0; //create medicineInBag variables string[] id = new string[size], name = new string[size], pn = new string[size], cn = new string[size]; int[] price = new int[size], s = new int[size], pro = new int[size], cat = new int[size], count = new int[size]; bool[] p = new bool[size]; foreach (MedicineInBag m in medList) { id[index] = m.CMedicineId; name[index] = m.CMedicineName; pn[index] = m.CMedicineInBagProducerName; cn[index] = m.CMedicineInBagCatagoryName; price[index] = m.CMedicinePrice; s[index] = m.CMedicineStock; pro[index] = m.CMedicineProducer; cat[index] = m.CMedicineCatagory; p[index] = m.CMedicineNeedPrescription; count[index] = m.CMedicineInBagMedicineCount; index++; ///////////////////////////////////////////////////////////////////////// /* * int currentStock = webser.GetMedicineStock(Convert.ToInt32(m.CMedicineId)); * countOfMedicine = currentStock - m.CMedicineInBagMedicineCount; * webser.UpdateMedCount(countOfMedicine,Convert.ToInt32(m.CMedicineId)); */ ////////////////////////////////////////////////////////////////////////// } //inseat to data base User u = (User)Session["user"]; /* * * /////////// * os.InsertOrder(o); * //////////////// * ///*/ //////////////////////////////////////////////////////////////////////////// webser.InseartOrder(id, name, price, p, s, pro, cat, pn, cn, count, u.CUserId); //////////////////////////////////////////////////////////////////////////// //init the shopping bag and the prescription list presList = new List <DataSet>(); Session["presList"] = new List <DataSet>(); sb = new ShoppingBag(); Session["myShoppingBag"] = new ShoppingBag(); Response.Write("<script>alert('ההזמנה בוצעה בהצלחה, עלות ההזמנה היא: " + totalPrice + " שקלים')</script>"); SortButton_Click(sender, e); }