Exemplo n.º 1
0
 protected void ShowShoppingbag_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteMedicineFromShoppingBag")
     {
         ShoppingBag       sb        = (ShoppingBag)Session["myShoppingBag"];
         int               rowNumber = Convert.ToInt32(e.CommandArgument);
         MedicineInBag     MIB       = new MedicineInBag();
         Pharmcy.PharmcyWS webser    = new Pharmcy.PharmcyWS();
         MIB.CMedicineId = ShowShoppingbag.Rows[rowNumber].Cells[0].Text;
         MIB.CMedicineNeedPrescription = webser.GetMedicineNeedPres(Convert.ToInt32(MIB.CMedicineId));
         if (MIB.CMedicineNeedPrescription)
         {
             List <DataSet> presList = (List <DataSet>)Session["presList"];
             foreach (DataSet d in presList)
             {
                 if (d.Tables[0].Rows[0]["PrescriptionMedicineId"].ToString() == MIB.CMedicineId)
                 {
                     presList.Remove(d);
                     Session["presList"] = presList;
                     break;
                 }
             }
         }
         sb.DeleteMedicineFromList(MIB);
         Session["myShoppingBag"] = sb;
         Response.Write("<script>alert('המוצר נמחק בהצלחה')</script>");
         showShoppingBag(sb);
     }
 }
Exemplo n.º 2
0
 public void UpdateMedicineLisr(MedicineInBag newMed)
 {
     if (ListMedicine != null)
     {
         foreach (MedicineInBag m in ListMedicine.ToList())
         {
             if (newMed.CMedicineId == m.CMedicineId)
             {
                 m.CMedicineInBagMedicineCount = newMed.CMedicineInBagMedicineCount;
             }
         }
     }
 }
Exemplo n.º 3
0
    public void DeleteMedicineFromList(MedicineInBag detMed)
    {
        bool found = false;

        if (ListMedicine != null)
        {
            foreach (MedicineInBag m in ListMedicine.ToList())
            {
                if (m.CMedicineId == detMed.CMedicineId && !found)
                {
                    ListMedicine.Remove(m);
                    found = true;
                }
            }
        }
    }
Exemplo n.º 4
0
    public void AddMedicine(MedicineInBag newMed)
    {
        bool found = false;

        foreach (MedicineInBag m in ListMedicine.ToList())
        {
            if (newMed.CMedicineId == m.CMedicineId)
            {
                m.CMedicineInBagMedicineCount++;
                found = true;
            }
        }
        if (!found)
        {
            ListMedicine.Add(newMed);
        }
    }
Exemplo n.º 5
0
    protected void SearchReasultGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "AddMedicine")
        {
            //check if the user is logged in, if not get him a message about it and redirect him to the regestrataion page
            User s = (User)Session["user"];
            if (s == null)
            {
                Response.Write("<script>alert('על מנת לרכוש מוצרים עליך להיות לקוח רשום')</script>");
                Response.Write("<script>window.open('http://localhost:49675/GuestHome.aspx','_blank');</script>");
                return;
            }

            //get the shopping bag
            myShoppingBag = (ShoppingBag)Session["myShoppingBag"];

            int rowNumber = Convert.ToInt32(e.CommandArgument);
            //create the medicineInBag var
            Pharmcy.PharmcyWS webser = new Pharmcy.PharmcyWS();
            MedicineInBag     MIB    = new MedicineInBag();
            MIB.CMedicineName  = SearchReasultGrid.Rows[rowNumber].Cells[1].Text;
            MIB.CMedicineId    = SearchReasultGrid.Rows[rowNumber].Cells[0].Text;
            MIB.CMedicinePrice = Convert.ToInt32(SearchReasultGrid.Rows[rowNumber].Cells[2].Text);
            MIB.CMedicineInBagMedicinePrice = Convert.ToInt32(MIB.CMedicinePrice);
            MIB.CMedicineNeedPrescription   = Convert.ToBoolean(SearchReasultGrid.Rows[rowNumber].Cells[6].Text);
            MIB.CMedicineStock = Convert.ToInt32(SearchReasultGrid.Rows[rowNumber].Cells[3].Text);
            //same in MedicineCatagory
            MIB.CMedicineProducer = webser.GetMedicineProducer(Convert.ToInt32(MIB.CMedicineId));
            MIB.CMedicineCatagory = webser.GetMedicineCatagory(Convert.ToInt32(MIB.CMedicineId));
            DataSet temp = webser.GetMedicineCataAndProName(MIB.CMedicineCatagory, MIB.CMedicineProducer);
            MIB.CMedicineInBagCatagoryName = temp.Tables[0].Rows[0]["MedicineCatagoryName"].ToString();
            MIB.CMedicineInBagProducerName = temp.Tables[0].Rows[0]["MedicineProducerName"].ToString();

            ///////////////////////////////////////////////////////////////////////////////////
            //check count of medicine
            //because we didnt change the current stock of the medicine we need to check if there is
            //enough from this medicine to buy
            int  countOfMedicine = myShoppingBag.GetMedicineCount(Convert.ToInt32(MIB.CMedicineId));
            User u = (User)Session["user"];
            if (MIB.CMedicineStock - countOfMedicine <= 0)
            {
                Response.Write("<script>alert('אין מספיק תרופות במלאי')</script>");
                return;
            }

            ///////////////////////////////////////////////////////////////////////////////////

            //check prescription
            int MedIdNumber = Convert.ToInt32(MIB.CMedicineId);
            //still dont change the current stock of medicine
            if (MIB.CMedicineNeedPrescription)
            {
                PrescriptioService ps = new PrescriptioService();
                DataSet            ds = ps.GetPrescriptionByMedicineId(MedIdNumber, u.CUserId);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    Response.Write("<script>alert('תרופה זאת צריכה מרשם')</script>");
                    return;
                }
                else
                {
                    //לבדוק אם הוא באמת הכניס אותה כמות
                    //אם הוא הכניס אותה כמות אז הכל בסדר
                    //צריך לזכור לבטל את המרשם ברגע שהקנייה מתבצעת
                    //אם הכמות לא שווה אז ליידע את הלקוח שהוא צריך לבדוק כמה כדורים נתנו לו
                    //אפשרות לחשוף קישור בדף לעמוד של המרשמים כדי שיוכל להסתכל
                    //או שאפשר להגיד למשתמש כמה כדורים הוא יכול לקחת(מעדיף שלא נשמע קצת מוזר)
                    presList = (List <DataSet>)Session["presList"];
                    if (presList != null)
                    {
                        foreach (DataSet d in presList)
                        {
                            if (ds.Tables[0].Rows[0]["PrescriptionId"].ToString() == d.Tables[0].Rows[0]["PrescriptionId"].ToString())
                            {
                                Response.Write("<script>alert('מרשם זה כבר שומש')</script>");
                                return;
                            }
                        }
                    }
                    presList.Add(ds);
                    Session["presList"] = presList;
                    int count = Convert.ToInt32(ds.Tables[0].Rows[0]["PrescriptionMedicineCount"].ToString());
                    MIB.CMedicineInBagMedicineCount = count;
                }
            }
            else
            {
                MIB.CMedicineInBagMedicineCount = 1;
            }
            myShoppingBag.AddMedicine(MIB);
            Session["myShoppingBag"] = myShoppingBag;
            Response.Write("<script>alert('המוצר הוסף לסל')</script>");
            CheckoutButton.Visible = true;
            SeeShoppingBag.Visible = true;
        }
    }