示例#1
0
        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);
            }
        }
示例#2
0
 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);
     }
 }
示例#3
0
 public bool update(SqlConnection cn, SqlTransaction tc, AdvsModel model)
 {
     return DbHelperSQL.updateModel<AdvsModel>(model, "Advs", "Evenid", model.Evenid.ToString(), "'", cn, tc);
 }
示例#4
0
 public bool add(SqlConnection cn, SqlTransaction tc, AdvsModel model)
 {
     return DbHelperSQL.insertModel<AdvsModel>(model, "Advs", cn, tc);
 }