コード例 #1
0
ファイル: vet.aspx.cs プロジェクト: Mitch1000/pet-store
        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