Ejemplo n.º 1
0
        public int add(NoticeModel notice)
        {
            SqlConnection cn = null;
            SqlTransaction tc = null;
            try
            {
                cn = DbHelperSQL.getConnection();
                tc = DbHelperSQL.startTransaction(cn);

                //执行新增写进数据库
                noticeDal.add(cn, tc, notice);

                IList<QueryModel> qmList = new List<QueryModel>();
                qmList.Add(MakeUtil.getQueryModel("SchoolNo", "'", SqlWhere.WhereOperator.Equal, notice.SchoolNo));
                qmList.Add(MakeUtil.getQueryModel("Headlines", "'", SqlWhere.WhereOperator.Equal, notice.Headlines));
                qmList.Add(MakeUtil.getQueryModel("1", "", SqlWhere.WhereOperator.Equal, "1 ORDER By Evenid DESC"));
                var newnotice = noticeDal.getModel(cn, tc, qmList);
                if (newnotice.Evenid <= 0)
                {
                    throw new Exception("数据库错误");
                }

                DbHelperSQL.commitTransaction(tc);
                return newnotice.Evenid;
            }
            catch (Exception dalEx)
            {
                DbHelperSQL.rollBackTransaction(tc);
                throw new MakeException(ExpSort.数据库, dalEx.Message);
            }
            finally
            {
                DbHelperSQL.closeConnection(cn);
            }
        }
Ejemplo n.º 2
0
 public bool update(SqlConnection cn, SqlTransaction tc, NoticeModel model)
 {
     return DbHelperSQL.updateModel<NoticeModel>(model, "Notice", "Evenid", model.Evenid.ToString(), "'", cn, tc);
 }
Ejemplo n.º 3
0
        public void update(NoticeModel notice)
        {
            SqlConnection cn = null;
            SqlTransaction tc = null;
            try
            {
                cn = DbHelperSQL.getConnection();
                tc = DbHelperSQL.startTransaction(cn);

            noticeDal.update(cn, tc, notice);

                DbHelperSQL.commitTransaction(tc);
            }
            catch (Exception dalEx)
            {
                DbHelperSQL.rollBackTransaction(tc);
                throw new MakeException(ExpSort.数据库, dalEx.Message);
            }
            finally
            {
                DbHelperSQL.closeConnection(cn);
            }
        }
Ejemplo n.º 4
0
 public bool add(SqlConnection cn, SqlTransaction tc, NoticeModel model)
 {
     return DbHelperSQL.insertModel<NoticeModel>(model, "Notice", cn, tc);
 }