protected void btnSubmit_OnClick(object sender, EventArgs e) { Mxm.Model.article mo = new Mxm.Model.article(); mo.author = txtAuthor.Text; mo.content = txtContent.Value; mo.create_time = DateTime.Now; mo.title = txtTitle.Text; mo.update_time = DateTime.Now; if(Request.Form["ddlType"]!=null) { mo.Type_id = int.Parse(Request.Form["ddlType"].ToString()); } if (fileUp1.HasFile) { string tmp = DateTime.Now.Ticks.ToString(); string path = Server.MapPath( ConfigurationManager.AppSettings["imgPath"].ToString()) + tmp + fileUp1.FileName; fileUp1.SaveAs(path); if (CheckImg.CheckImgSize(path, _picSize, _picSize)) { mo.Picture_small = tmp + fileUp1.FileName; } else { System.IO.File.Delete(path); Mxm.Common.MessageBox.Show(this, "上传图片不符合规格,请重新选择"); return; } } try { Mxm.DAL.article mgr = new Mxm.DAL.article(); mgr.Add(mo); Mxm.Common.MessageBox.Show(this, "提交完成"); } catch (Exception ex) { throw ex; } }
private void SetPager() { int count = new Mxm.DAL.article().GetCount(""); pager1.RecordCount = count; pager1.PageSize = mPageSize; }