Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PetName = "";
            PetName = Request.QueryString["Name"];

            if (Session["User"] != null)
            {
                oUser = (PetStore.Class.User)Session["User"];
                oDB   = new PetStore.DB.Data();
                if (PetName == null)
                {
                    PetName = oDB.GetFirstPetName(oUser.ID);
                }
                if (PetName == "")
                {
                    noPet.Style.Add("display", "");
                    noPet.Text = "There is no pet registered.";
                }
                else
                {
                    DataTable dtPets = new DataTable();
                    dtPets = oDB.GetPets(oUser.ID, ""); //, categoryName);

                    rptLeftNav.DataSource = dtPets;
                    rptLeftNav.DataBind();
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["Calendar"] = oCalendar;
            oCalendar           = new Class.Calendar();
            oDB     = new DB.Data();
            PetName = "";
            PetName = Request.QueryString["Name"];
            notRegisteredError.Style.Add("display", "none");
            DataTable dtDates = new DataTable();
            DataTable dtPet   = new DataTable();

            DeleteSelection.Style.Add("display", "none");
            DeleteCompleted.Style.Add("display", "none");
            ShowDateInput.Style.Add("display", "none");
            DateMade.Style.Add("display", "none");
            notRegisteredError.Style.Add("display", "none");
            Error.Style.Add("display", "none");

            if (btnAddDate.Text == "1")
            {
                btnAddDate.Text = "ADD DATE";
            }

            if (btnDateDelete.Text == "1")
            {
                btnDateDelete.Text = "DELETE DATE";
            }


            if (Session["User"] == null)
            {
                notRegisteredError.Style.Add("display", "");
                notRegisteredError.Text = "Only registered users can use this feature";
                pagecontent.Style.Add("display", "none");
            }

            // OpenNewWindow("test.aspx");

            else if (PetName == null)
            {
                oUser   = (PetStore.Class.User)Session["User"];
                PetName = oDB.GetFirstPetName(oUser.ID);

                if (PetName == "")
                {
                    oUser = (PetStore.Class.User)Session["User"];
                    btnDateDelete.Style.Add("display", "none");
                    btnAddDate.Style.Add("display", "none");
                }
                else
                {
                    oUser   = (PetStore.Class.User)Session["User"];
                    dtDates = oDB.GetDates(oUser.ID);
                    dtPets  = oDB.GetPets(oUser.ID);
                    System.DateTime Today = DateTime.Now;
                    System.DateTime DateLastDogFoodWasPurchase = Today.AddDays(-7);
                    System.DateTime DateLastCatFoodWasPurchase = Today.AddDays(-7);
                    int             NumberofDogFoodCans        = 20;
                    int             NumberofCatFoodCans        = 20;
                    double          DogFoodCaloriesPerOrder    = 424 * NumberofDogFoodCans;
                    double          CatFoodCaloriesPerOrder    = 424 * NumberofCatFoodCans;
                    int             i = 0;
                    foreach (DataRow row in dtPets.Rows)
                    {
                        if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Dog"))
                        {
                            Date = oCalendar.DogFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastDogFoodWasPurchase, DogFoodCaloriesPerOrder);
                            info = dtPets.Rows[i]["Name"].ToString() + " Needs Food on: " + oCalendar.DogFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastDogFoodWasPurchase, DogFoodCaloriesPerOrder).ToString("MMMM dd, yyyy") + "                ";
                        }

                        if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Cat"))
                        {
                            Date = oCalendar.CatFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastCatFoodWasPurchase, CatFoodCaloriesPerOrder);
                            info = dtPets.Rows[i]["Name"].ToString() + " Needs Food on: " + oCalendar.CatFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastCatFoodWasPurchase, CatFoodCaloriesPerOrder).ToString("MMMM dd, yyyy") + "                ";
                        }


                        if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Fish"))
                        {
                            Date = DateTime.Now.AddDays(7);
                            info = dtPets.Rows[i]["Name"].ToString() + " Needs Their Bowl Cleaned On: " + Date.ToString("MMMM dd, yyyy") + "                ";
                        }


                        if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Bird"))
                        {
                            Date = DateTime.Now.AddDays(9);
                            info = dtPets.Rows[i]["Name"].ToString() + " Needs Their Cage Cleaned On: " + Date.ToString("MMMM dd, yyyy") + "                ";
                        }

                        oDB.DeleteDate(oUser.ID, info);
                        oDB.AddDate(oUser.ID, dtPets.Rows[i]["Name"].ToString(), Date, info, "");

                        i++;
                    }


                    dtPet = oDB.GetPet(oUser.ID, PetName);
                    Pet   = dtPet.Rows[0]["Name"].ToString();


                    /*
                     * int n = 0;
                     * int z = 0;
                     * foreach (DataRow row in dtDates.Rows)
                     * {
                     *   if (dtDates.Rows[z]["Pet"].ToString() == dtPet.Rows[0]["Name"].ToString())
                     *   {
                     *
                     *       switch (n)
                     *       {
                     *           case 0: Day0.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 1: Day1.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 2: Day2.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 3: Day3.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 4: Day4.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 5: Day5.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 6: Day6.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 7: Day7.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 8: Day8.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 9: Day9.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *           case 10: Day10.Text = dtDates.Rows[z]["Info"].ToString(); break;
                     *       }
                     *       n++;
                     *   }
                     *   z++;
                     * }
                     */
                }//end else
            }

            else
            {
                oUser   = (PetStore.Class.User)Session["User"];
                dtDates = oDB.GetDates(oUser.ID);
                dtPets  = oDB.GetPets(oUser.ID);
                System.DateTime Today = DateTime.Now;
                System.DateTime DateLastDogFoodWasPurchase = Today.AddDays(-7);
                System.DateTime DateLastCatFoodWasPurchase = Today.AddDays(-7);
                int             NumberofDogFoodCans        = 20;
                int             NumberofCatFoodCans        = 20;
                double          DogFoodCaloriesPerOrder    = 424 * NumberofDogFoodCans;
                double          CatFoodCaloriesPerOrder    = 424 * NumberofCatFoodCans;
                int             i = 0;

                foreach (DataRow row in dtPets.Rows)
                {
                    if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Dog"))
                    {
                        Date = oCalendar.DogFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastDogFoodWasPurchase, DogFoodCaloriesPerOrder);
                        info = dtPets.Rows[i]["Name"].ToString() + " Needs Food on: " + oCalendar.DogFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastDogFoodWasPurchase, DogFoodCaloriesPerOrder).ToString("MMMM dd, yyyy") + "                ";
                    }

                    if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Cat"))
                    {
                        Date = oCalendar.CatFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastCatFoodWasPurchase, CatFoodCaloriesPerOrder);
                        info = dtPets.Rows[i]["Name"].ToString() + " Needs Food on: " + oCalendar.CatFoodNeeded(Convert.ToDouble(dtPets.Rows[i]["Weight"]), DateLastCatFoodWasPurchase, CatFoodCaloriesPerOrder).ToString("MMMM dd, yyyy") + "                ";
                    }


                    if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Fish"))
                    {
                        Date = DateTime.Now.AddDays(7);
                        info = dtPets.Rows[i]["Name"].ToString() + " Needs Their Bowl Cleaned On: " + Date.ToString("MMMM dd, yyyy") + "                ";
                    }


                    if ((Convert.ToString(dtPets.Rows[i]["Type"]) == "Bird"))
                    {
                        Date = DateTime.Now.AddDays(9);
                        info = dtPets.Rows[i]["Name"].ToString() + " Needs Their Cage Cleaned On: " + Date.ToString("MMMM dd, yyyy") + "                ";
                    }

                    oDB.DeleteDate(oUser.ID, info);
                    oDB.AddDate(oUser.ID, dtPets.Rows[i]["Name"].ToString(), Date, info, "");

                    i++;
                }
                dtPet = oDB.GetPet(oUser.ID, PetName);
                Pet   = dtPet.Rows[0]["Name"].ToString();
            }//end else


            if (!this.IsPostBack)
            {
                ddlDateSelection.Items.Insert(0, new ListItem("", ""));

                int q = 0;

                foreach (DataRow row in dtDates.Rows)
                {
                    if (dtDates.Rows[q]["Pet"].ToString() == dtPet.Rows[0]["Name"].ToString())
                    {
                        ddlDateSelection.Items.Add(new ListItem(dtDates.Rows[q]["Info"].ToString(), dtDates.Rows[q]["Info"].ToString()));
                    }
                    q++;
                }
            }
        }// End page load
Exemplo n.º 3
0
        /// <summary>
        /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DayRender(object sender, DayRenderEventArgs e)
        {
            Session["Calendar"] = oCalendar;
            oCalendar           = new Class.Calendar();
            oDB     = new DB.Data();
            PetName = "";
            PetName = Request.QueryString["Name"];

            DataTable dtDates = new DataTable();
            DataTable dtPet   = new DataTable();

            Debug.WriteLine(PetName);
            if (Session["User"] == null)
            {
            }

            //else if (PetName == null)
            //{
            //    oUser = (PetStore.Class.User)Session["User"];
            //    PetName = oDB.GetFirstPetName(oUser.ID);

            //    if (PetName == "")
            //    {

            //        oUser = (PetStore.Class.User)Session["User"];

            //    }

            else
            {
                oUser   = (PetStore.Class.User)Session["User"];
                dtDates = oDB.GetDates(oUser.ID);
                dtPets  = oDB.GetPets(oUser.ID);
                int      i = 0;
                DateTime day;
                e.Day.IsSelectable = false;
                dtPet = oDB.GetPet(oUser.ID, PetName);

                foreach (DataRow row in dtDates.Rows)
                {
                    if (dtDates.Rows[i]["Pet"].ToString() == Pet)
                    {
                        day = Convert.ToDateTime(dtDates.Rows[i]["Date"]);
                        day = day.Date;


                        if (e.Day.Date == day)
                        {
                            e.Cell.BackColor   = Color.LightBlue;
                            e.Day.IsSelectable = true;
                        }
                    }
                    i++;
                }


                if (e.Day.IsToday)
                {
                    e.Cell.BackColor = Color.Tomato;
                }
                else if (e.Day.IsSelected)
                {
                    e.Cell.BackColor = Color.Orange;
                }

                //    } // end else
                //}//end if PetName==Null
            }
            SqlConnection.ClearAllPools();
        }//end dayrender void
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            oDB     = new DB.Data();
            PetName = "";
            notRegisteredError.Style.Add("display", "none");
            DataTable dtDates = new DataTable();
            DataTable dtPet   = new DataTable();

            oUser = (PetStore.Class.User)Session["User"];


            if (btnBookApnt.Text == "1")
            {
                btnBookApnt.Text = "BOOK APPOINTMENT";
            }

            ApntBooked.Style.Add("display", "none");
            ShowDateInput.Style.Add("display", "none");
            notRegisteredError.Style.Add("display", "none");



            if (Session["User"] == null)
            {
                notRegisteredError.Style.Add("display", "");
                notRegisteredError.Text = "Only registered users can use this feature";
                vetpagecontent.Style.Add("display", "none");
            }


            else
            {
                PetName = oDB.GetFirstPetName(oUser.ID);
                oUser   = (PetStore.Class.User)Session["User"];
                dtVet   = oDB.GetVets();
                int i = 0;
                q = 0;
                string myTable = "";
                foreach (DataRow row in dtVet.Rows)
                {
                    if (dtVet.Rows[i]["City"].ToString() == oUser.City)
                    {
                        description[q] = dtVet.Rows[i]["description"].ToString();
                        VetTitle[q]    = dtVet.Rows[i]["Title"].ToString();
                        Address[q]     = dtVet.Rows[i]["Address"].ToString();
                        City[q]        = dtVet.Rows[i]["City"].ToString();
                        province[q]    = dtVet.Rows[i]["province"].ToString();
                        postalcode[q]  = dtVet.Rows[i]["Postal"].ToString();
                        url[q]         = dtVet.Rows[i]["url"].ToString();
                        logo[q]        = dtVet.Rows[i]["logo"].ToString();
                        vetaddress[q]  = dtVet.Rows[i]["Address"].ToString() + ", " + dtVet.Rows[i]["City"].ToString() + ", " + dtVet.Rows[i]["province"].ToString() + ", " + dtVet.Rows[i]["Postal"].ToString();

                        myTable += "<table>";
                        myTable += "<tr>";
                        myTable += "<td> <a href=" + url[q] + "> <img style='max-height: 180px; max-width: 180px' src=" + logo[q] + " /></a></td>";
                        myTable += "</tr>";
                        myTable += "<tr>";
                        myTable += "<td><b> <a href=" + url[q] + ">" + VetTitle[q] + "</a></b></td>";
                        myTable += "</tr>";
                        myTable += "<tr>";
                        myTable += "<td>" + vetaddress[q] + " </td>";
                        myTable += "</tr>";
                        myTable += "<br>";

                        if (!this.IsPostBack)
                        {
                            ddlVet.Items.Add(new ListItem(VetTitle[q], VetTitle[q]));
                        }

                        q++;
                    }
                    i++;
                }


                myTable += "</table>";
                tablePrint.InnerHtml = myTable;

                if (!this.IsPostBack)
                {
                    ddlPet.Items.Insert(0, new ListItem("", ""));
                    int       n      = 0;
                    DataTable dtPets = new DataTable();
                    dtPets = oDB.GetPets(oUser.ID);

                    foreach (DataRow row in dtPets.Rows)
                    {
                        ddlPet.Items.Add(new ListItem(dtPets.Rows[n]["Name"].ToString(), dtPets.Rows[n]["Name"].ToString()));
                        n++;
                    }
                }
                // rptVet.DataSource = oDB.GetVets(); ;
                //   rptVet.DataBind();

                if (PetName == "")
                {
                    btnBookApnt.Style.Add("display", "none");
                }
            } // end else
        }     // end page load