/// <summary> /// Parses a SpotLocation element. /// </summary> SpotLocation ParseSpotLocation() { Debug.Assert(this.reader.Name == ""); bool isEmptyElement = this.reader.IsEmptyElement; SpotLocation spotLocation = new SpotLocation(); while (MoveToNextAttribute()) { switch (this.reader.Name) { case "StartX": spotLocation.StartX = double.Parse(this.reader.Value); break; case "StartY": spotLocation.StartY = double.Parse(this.reader.Value); break; case "PageURI": spotLocation.PageURI = this.reader.Value; break; default: UnexpectedAttribute(this.reader.Name); break; } } MoveToNextElement(); return(spotLocation); }
protected void imgBtn_Click(object sender, ImageClickEventArgs e) { String arg = (String)((ImageButton)sender).CommandArgument; String[] values = arg.Split('|'); SpotModel spot = new SpotModel(); SpotLocation location = new SpotLocation(); location.state = values[0]; location.city = values[1]; location.zipcode = values[2]; spot.location = location; spot.name = values[3]; spot.introduction = values[4]; spot.price = values[5]; SpotRootObject rootObj = new SpotRootObject(); rootObj.key = spot; String json = JsonConvert.SerializeObject(rootObj); Session["SpotDetails"] = json; Response.Redirect("~/Member/SpotDetails"); }
protected void btnAddSpot_Click(Object sender, EventArgs e) { try { SpotRootObject rootObj = new SpotRootObject(); SpotModel spot = new SpotModel(); spot.name = Name.Text; MemoryStream ms = new MemoryStream(Img.FileBytes); byte[] array = ms.ToArray(); spot.imgBytes = array; //spot.imgStr = Encoding.UTF8.GetString(array,0,array.Length); SpotLocation location = new SpotLocation(); location.state = State.Text; location.city = City.Text; location.zipcode = ZipCode.Text; spot.location = location; spot.introduction = Introduction.Text; spot.price = Price.Text; rootObj.key = spot; String json = JsonConvert.SerializeObject(rootObj); Boolean flag = haishengService.addSpot(json); if (!flag) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "<script>$('#remindModal').modal('show');</script>", false); } } catch (Exception ex) { throw ex; } }