protected void SubmitButton_Click(object sender, EventArgs e) { bool flag = false; if (!ImageUpload.HasFile) { PicValid.CssClass = "alert alert-warning"; Bind(); return; } else { WMGoodImages gi = new WMGoodImages(); gi.GoodId = GoodId; string fileName = string.Format("/share/upload/good/{0}/{1}.jpg", gi.GoodId, DateTime.Now.ToFileTime()); Jumpcity.IO.FileUpload upload = new Jumpcity.IO.FileUpload("~" + fileName, 0, 0); if (upload.Upload(ImageUpload.PostedFile.InputStream)) { gi.URL = fileName; flag = gi.Add(); } } if (flag) Bind(); Helper.MessageBox(flag); }
public static WMGoodImages Get(string id) { WMGoodImages image = null; if (!General.IsNullable(id)) { using (WMContext context = new WMContext()) { image = ( from gi in context.GoodImages where gi.Id.Equals(id) select new WMGoodImages { Id = gi.Id, GoodId = gi.GoodId, URL = gi.URL, IsCover = gi.IsCover, AddDate = gi.AddDate } ).FirstOrDefault(); } } return(image); }