Exemplo n.º 1
0
        /// <summary>
        /// 插入新纪录
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public IDataShell <AccountDBModel> Insert(AccountDBModel account)
        {
            using (var conn = ConnFactory.GetUserConn())
            {
                using (var dal = new UserAccountTDAL(conn))
                {
                    var uid = dal.NewUserID();
                    account.AccountID = Convert.ToString(uid.Data);

                    var result = dal.Insert(account);
                    return(result);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 事务方式插入新纪录
 /// 事务范例
 /// </summary>
 /// <param name="account"></param>
 /// <returns></returns>
 public IDataShell <AccountDBModel> TranWork(AccountDBModel account)
 {
     using (var conn = ConnFactory.GetUserConn()) //打开链接
     {
         using (var uk = new UniteWork(conn))     //启动事务
         {
             var dal = new UserAccountTDAL(conn, uk.Tran);
             var uid = dal.NewUserID();
             account.AccountID = Convert.ToString(uid.Data);
             var result = dal.Insert(account);
             account.Account = "XXEW";
             result          = dal.Update(account);
             account.Email   = "XXEW11";
             result          = dal.Update(account);
             uk.Commit();//成功就提交事务
             return(result);
         }
     }
 }