}//end dayrender void protected void cal_SelectionChanged(object sender, EventArgs e) { if (Session["User"] == null) { } else { DateTime day; DataTable dtDates = new DataTable(); oUser = (PetStore.Class.User)Session["User"]; dtDates = oDB.GetDates(oUser.ID); int i = 0; foreach (DataRow row in dtDates.Rows) { if (dtDates.Rows[i]["Pet"].ToString() == Pet) { day = Convert.ToDateTime(dtDates.Rows[i]["Date"]); day = day.Date; if (cal.SelectedDate == day) { DateInfo.Text = dtDates.Rows[i]["Info"].ToString(); } } i++; } } // end else } // end void
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.GetPet(oUser.ID, ""); //, categoryName); rptLeftNav.DataSource = dtPets; rptLeftNav.DataBind(); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["User"] == null) { oUser = new Class.User(); oUser.ID = -1; if (String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtPassword.Text)) { error.Style.Add("display", ""); error.Text = "Email and Password are required fields."; } else { oUser.Email = txtEmail.Text; oUser.FirstName = txtFirstname.Text; oUser.LastName = txtLastName.Text; oUser.Password = txtPassword.Text; oUser.Address = txtAddress.Text; oUser.City = txtCity.Text; //oUser.PetType = ddlPettype.SelectedItem.Value; oUser.Phone = txtPhone.Text; oUser.PostalCode = txtPostal.Text; oUser.Province = txtProv.Text; if (!oDB.IsUserExist(oUser)) { if (oDB.UpdateUser(oUser)) { result.Style.Add("display", ""); result.Text = "The profile has been created."; Session["User"] = oUser; // Response.Redirect("register.aspx?reg=1"); Response.Redirect("home.aspx"); } else { error.Style.Add("display", ""); error.Text = "Unexpected Error occurs. Please try it again later."; } } else { error.Style.Add("display", ""); error.Text = "The Email address already exists"; } } } }
protected void Page_Load(object sender, EventArgs e) { notRegisteredError.Style.Add("display", "none"); if (Session["User"] == null) { notRegisteredError.Style.Add("display", ""); notRegisteredError.Text = "Only registered users can use this feature"; } else { PetStore.Class.User oUser = (PetStore.Class.User)Session["User"]; DataTable dtCity = new DataTable(); PetStore.DB.Data oDB = new PetStore.DB.Data(); rptOrder.DataSource = oDB.GetOrders(oUser.ID);; rptOrder.DataBind(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { oUser = new Class.User(); if (String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtPassword.Text)) { error.Style.Add("display", ""); error.Text = "Please enter Email and Password."; } else { oUser = oDB.Login(txtEmail.Text, txtPassword.Text); if (oUser != null) { Session["User"] = oUser; Response.Redirect("home.aspx?login=Y"); } else { error.Style.Add("display", ""); error.Text = "Please check your email and password."; } } }
protected void Page_Load(object sender, EventArgs e) { oDB = new DB.Data(); oUser = (PetStore.Class.User)Session["User"]; btnUpdate.Text = "ADD"; }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Session["User"] == null) { oUser = new Class.User(); oUser.ID = -1; if (String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtPassword.Text)) { error.Style.Add("display", ""); error.Text = "Email and Password are required fields."; } else { oUser.Email = txtEmail.Text; oUser.FirstName = txtFirstname.Text; oUser.LastName = txtLastName.Text; oUser.Password = txtPassword.Text; oUser.Address = txtAddress.Text; oUser.City = txtCity.Text; //oUser.PetType = ddlPettype.SelectedItem.Value; oUser.Phone = txtPhone.Text; oUser.PostalCode = txtPostal.Text; oUser.Province = txtProv.Text; if (!oDB.IsUserExist(oUser)) { if (oDB.UpdateUser(oUser)) { SmtpClient smtpClient = new SmtpClient(); MailMessage oMessage1 = new MailMessage(); oMessage1.Subject = "Registration confirmation"; oMessage1.Body = "Hi, <br/><br/><br/> Thanks for register to One Stop Pet Shop. <br /> Your User name is " + oUser.Email + "'. <br/><br/><br/><br/><br/><br/><br/><br/>One Stop Pet Shop team. "; oMessage1.IsBodyHtml = true; oMessage1.To.Add(new MailAddress(txtEmail.Text)); oMessage1.From = new MailAddress("*****@*****.**"); // https://www.google.com/settings/security/lesssecureapps smtpClient.Send(oMessage1); oUser = oDB.Login(oUser.Email, oUser.Password); Session["User"] = oUser; result.Style.Add("display", ""); result.Text = "The profile has been created."; Session["User"] = oUser; Response.Redirect("profile.aspx?Created=Y"); } else { error.Style.Add("display", ""); error.Text = "Unexpected Error occurs. Please try it again later."; } } else { error.Style.Add("display", ""); error.Text = "The Email address already exists"; } } } else { oUser = (PetStore.Class.User)Session["User"]; if (txtPassword.Text == "") { error.Style.Add("display", ""); error.Text = "Please enter your password."; } else { oUser.Email = txtEmail.Text; oUser.FirstName = txtFirstname.Text; oUser.LastName = txtLastName.Text; oUser.Password = txtPassword.Text; oUser.Address = txtAddress.Text; oUser.City = txtCity.Text; oUser.Phone = txtPhone.Text; oUser.PostalCode = txtPostal.Text; oUser.Province = txtProv.Text; oDB.UpdateUser(oUser); Session["User"] = oUser; result.Style.Add("display", ""); result.Text = "The profile has been updated."; } } }
protected void Page_Load(object sender, EventArgs e) { oDB = new DB.Data(); error.Style.Add("display", "none"); result.Style.Add("display", "none"); string CreateMsg = ""; CreateMsg = Request.QueryString["Created"]; if (CreateMsg == "Y") { result.Style.Add("display", ""); result.Text = "The profile has been created."; PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty( "IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic); // make collection editable isreadonly.SetValue(this.Request.QueryString, false, null); // remove this.Request.QueryString.Remove("Created"); } if (!IsPostBack) { btnSubmit.Style.Add("display", "none"); btnUpdate.Style.Add("display", "none"); if (Session["User"] != null) { PageTitle.Text = "Update my account"; btnUpdate.Style.Add("display", ""); oUser = (PetStore.Class.User)Session["User"]; update = true; txtFirstname.Text = oUser.Address; oUser.City = txtLastName.Text = oUser.City; txtEmail.Text = oUser.Email; txtEmail.Enabled = false; txtFirstname.Text = oUser.FirstName; txtLastName.Text = oUser.LastName; txtPassword.Text = oUser.Password; txtAddress.Text = oUser.Address; txtCity.Text = oUser.City; //oUser.PetType = ddlPettype.SelectedItem.Value; txtPhone.Text = oUser.Phone; txtPostal.Text = oUser.PostalCode; txtProv.Text = oUser.Province; } else { PageTitle.Text = "Register"; btnSubmit.Style.Add("display", ""); DataTable dtPetType = new DataTable(); dtPetType = oDB.GetPetType(); //ddlPettype.DataSource = dtPetType; //ddlPettype.DataValueField = "PetType"; //ddlPettype.DataTextField = "Description"; //ddlPettype.DataBind(); //ddlPettype.Items.Insert(0, new ListItem("--Select your pet type--", "")); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtEmail.Text)) { error.Style.Add("display", ""); result.Style.Add("display", "none"); } else { oUser = new Class.User(); oDB = new PetStore.DB.Data(); oUser.Email = txtEmail.Text; if (oDB.IsUserExist(oUser)) { oUser = oDB.Login(txtEmail.Text, "tempassword12345"); //Guid oGuid = Guid.NewGuid(); Random oRandom = new Random(); int tempPassword = oRandom.Next(100000); oUser.Password = oUser.LastName + tempPassword.ToString(); oDB.UpdateUser(oUser); //update the password with new password //send an email witht the Guid password SmtpClient smtpClient = new SmtpClient(); MailMessage oMessage1 = new MailMessage(); oMessage1.Subject = "New password for One stop pet shop"; oMessage1.Body = "Hi, here is the new password, '" + oUser.Password + "'. <br/> Once you log in the site, please update your password again."; oMessage1.IsBodyHtml = true; oMessage1.To.Add(new MailAddress(txtEmail.Text)); oMessage1.From = new MailAddress("*****@*****.**"); // https://www.google.com/settings/security/lesssecureapps smtpClient.Send(oMessage1); //// SmtpClient client1 = new SmtpClient(); //// client1.Host = "smtp.gmail.com"; //// client1.Port = 587; //// client1.UseDefaultCredentials = false; //// client1.DeliveryMethod = SmtpDeliveryMethod.Network; //// client1.EnableSsl = true; //// client1.Credentials = new NetworkCredential("*****@*****.**", "sendingemail"); ////MailMessage oMessage = new MailMessage(); //// oMessage.Subject = "hello"; //// oMessage.Body = "body"; //// oMessage.To.Add(new MailAddress(txtEmail.Text)); //// oMessage.From = new MailAddress("*****@*****.**"); //// client1.Send(oMessage); //// MailMessage objeto_mail = new MailMessage(); //// SmtpClient client3 = new SmtpClient(); //// client3.Port = 587; //// client3.Host = "smtp.gmail.com"; //// client3.Timeout = 10000; //// client3.DeliveryMethod = SmtpDeliveryMethod.Network; //// client3.UseDefaultCredentials = false; //// client3.EnableSsl = true; //// client3.Credentials = new System.Net.NetworkCredential("*****@*****.**", "sendingemail"); //// objeto_mail.From = new MailAddress("*****@*****.**"); //// objeto_mail.To.Add(new MailAddress(txtEmail.Text)); //// objeto_mail.Subject = "Password Recover"; //// objeto_mail.Body = "Message"; //// client3.Send(objeto_mail); result.Style.Add("display", ""); } else { error.Style.Add("display", ""); } } }
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
/// <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
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
protected void Page_Load(object sender, EventArgs e) { oDB = new DB.Data(); PetName = ""; PetName = Request.QueryString["Name"]; notRegisteredError.Style.Add("display", "none"); if (Session["User"] == null) { notRegisteredError.Style.Add("display", ""); notRegisteredError.Text = "Only registered users can use this feature"; pageContent.Style.Add("display", "none"); btnUpdate.Text = "ADD"; btnDelete.Style.Add("style", "none"); } else if (PetName == null) { oUser = (PetStore.Class.User)Session["User"]; PetName = oDB.GetFirstPetName(oUser.ID); if (PetName == "") { oUser = (PetStore.Class.User)Session["User"]; Div1.Style.Add("display", "none"); } else { btnUpdate.Text = "UPDATE"; NewButton.Style.Add("display", "none"); DataTable dtPets = new DataTable(); dtPets = oDB.GetPet(oUser.ID, PetName); //, categoryName); sFirstName = txtFirstname.Text; sOldName = dtPets.Rows[0]["Name"].ToString(); txtFirstname.Text = sOldName; sWeight = Weight.Text; sOldWeight = dtPets.Rows[0]["Weight"].ToString(); Weight.Text = sOldWeight; sAge = Age.Text; sOldAge = dtPets.Rows[0]["DOB"].ToString(); Age.Text = sOldAge; sType = ddlType.SelectedValue; sOldType = dtPets.Rows[0]["Type"].ToString(); ddlType.ClearSelection(); ddlType.Items.FindByValue(sOldType).Selected = true; } } else { oUser = (PetStore.Class.User)Session["User"]; btnUpdate.Text = "UPDATE"; NewButton.Style.Add("display", "none"); DataTable dtPets = new DataTable(); dtPets = oDB.GetPet(oUser.ID, PetName); sFirstName = txtFirstname.Text; sOldName = dtPets.Rows[0]["Name"].ToString(); txtFirstname.Text = sOldName; sWeight = Weight.Text; sOldWeight = dtPets.Rows[0]["Weight"].ToString(); Weight.Text = sOldWeight; sAge = Age.Text; sOldAge = dtPets.Rows[0]["DOB"].ToString(); Age.Text = sOldAge; sType = ddlType.SelectedValue; sOldType = dtPets.Rows[0]["Type"].ToString();; ddlType.ClearSelection(); ddlType.Items.FindByValue(sOldType).Selected = true; } }