protected void Page_Load(object sender, EventArgs e) { MasterPagePropertiesInterface m = Master as MasterPagePropertiesInterface; if (m != null) m.themeTitle = "Prizes Edit"; prize _prizes = new prize(); string id = Request.QueryString["id"]; Guid _guid = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id); _prizes = _dal.GetPrizesBYID(_guid); if (!Page.IsPostBack) { txtPrizeName.Text = _prizes.prizeName; txtFoundationPayout.Text = _prizes.foundation.ToString(); txtKidsPayout.Text = _prizes.kids.ToString(); txtpointsRequired.Text = _prizes.points.ToString(); txtTotalPayout.Text = _prizes.totalpayout.ToString(); txtGifDescription.InnerText = _prizes.gift.ToString(); } }
protected void btnSave_Click(object sender, EventArgs e) { string id = Request.QueryString["id"]; if (id != "00000000-0000-0000-0000-000000000000") { _prizesID = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id); } prize _prize = new prize(); _prize = _dal.GetPrizesBYID(_prizesID); _prize.prizeName = txtPrizeName.Text; _prize.points = Convert.ToInt32(txtpointsRequired.Text); _prize.kids =Convert.ToDecimal(txtKidsPayout.Text); _prize.authUserName = User.Identity.Name.ToString(); _prize.authCreatedDate = DateTime.Now; _prize.gift = txtGifDescription.InnerText; if (id == "00000000-0000-0000-0000-000000000000") { _dal.SoccerEntities.prizes.Add(_prize); } _dal.SoccerEntities.SaveChanges(); Response.Redirect("default.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { try { string id = Request.QueryString["id"]; if (id != "00000000-0000-0000-0000-000000000000") { _prizesID = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id); } prize _prize = new prize(); _prize = _dal.GetPrizesBYID(_prizesID); _prize.prizeName = txtPrizeName.Text; _prize.points = Convert.ToInt32(txtpointsRequired.Text); _prize.kids =Convert.ToDecimal(txtKidsPayout.Text); _prize.authUserName = User.Identity.Name.ToString(); _prize.authCreatedDate = DateTime.Now; if (rdUploadGift.UploadedFiles.Count > 0) { foreach (UploadedFile file in rdUploadGift.UploadedFiles) { string filename = string.Empty; string filenameNew = string.Empty; string path = string.Empty; filename = file.FileName; Guid _fileNameGuid = new Guid(); path = System.IO.Path.GetFileName(filename); string Withoutext = System.IO.Path.GetFileNameWithoutExtension(filename); file.SaveAs(Server.MapPath("~/uploads/images/gifts/") + path); _prize.gifImage = "~/uploads/images/gifts/"+ path; } } if (id == "00000000-0000-0000-0000-000000000000") { _dal.SoccerEntities.AddToprizes(_prize); } _dal.SoccerEntities.SaveChanges(); Response.Redirect("default.aspx"); } catch (Exception ex) { Log.Error(string.Format("Prizes Edit Exception {0}", ex.ToString())); } }
public prize GetPrizesBYID(Guid _prizeId) { try { if (_prizeId == Guid.Empty) { prize _prize = new prize(); return _prize; } else { var q = SoccerEntities.prizes.Where(p => p.id == _prizeId); if (q == null) throw new EntityContextException(string.Format("A Prize could not be found {0}!", _prizeId)); else return q.ToList()[0]; } } catch (Exception ex) { throw new EntityContextException("GetPrizesBYID failed.", ex); } }
/// <summary> /// Deprecated Method for adding a new object to the prizes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToprizes(prize prize) { base.AddObject("prizes", prize); }
/// <summary> /// Create a new prize object. /// </summary> /// <param name="id">Initial value of the id property.</param> public static prize Createprize(global::System.Guid id) { prize prize = new prize(); prize.id = id; return prize; }