public void add(AdvsModel advs) { SqlConnection cn = null; SqlTransaction tc = null; try { cn = DbHelperSQL.getConnection(); tc = DbHelperSQL.startTransaction(cn); //执行新增写进数据库 _advsDal.add(cn, tc, advs); DbHelperSQL.commitTransaction(tc); } catch (Exception dalEx) { DbHelperSQL.rollBackTransaction(tc); throw new MakeException(ExpSort.数据库, dalEx.Message); } finally { DbHelperSQL.closeConnection(cn); } }
protected void ImageBtnSave_Click(object sender, ImageClickEventArgs e) { var row = Convert.ToInt32(Rows.Value); var advs = new List<AdvsModel>(); try { var paperno = DateTime.Now.ToString("yyyyMMddHHmmssfff"); var schoolNos = MakeUtil.getStringFromRequestByName(Request, "SchoolNos", -1); if (schoolNos == "") { throw new Exception("请选择学校"); } for (int i = 1; i <= row; i++) { var filename = SaveFile("UploadImg" + i); if (filename != "") { var link = MakeUtil.getStringFromRequestByName(Request, "Link", i); var adv = new AdvsModel(); adv.ImgPath = filename; adv.PaperNo = paperno; adv.SchoolNos = schoolNos; adv.Link = link; advs.Add(adv); } } _bll.add(advs); MakeUtil.addOperationNote(Request.UserHostAddress, UserId.Value.Trim(), "广告资料新增", paperno); Script.alertMsg("新增成功", Page); Script.scriptRedirect(Request.RawUrl, this.Page); } catch (Exception ex) { Script.alertMsg(ex.Message, Page); } }
public bool update(SqlConnection cn, SqlTransaction tc, AdvsModel model) { return DbHelperSQL.updateModel<AdvsModel>(model, "Advs", "Evenid", model.Evenid.ToString(), "'", cn, tc); }
public bool add(SqlConnection cn, SqlTransaction tc, AdvsModel model) { return DbHelperSQL.insertModel<AdvsModel>(model, "Advs", cn, tc); }