/// <summary> /// 更新每个月月限数量 /// </summary> /// <returns></returns> public int UpdateRemainingCount() { #region sql string sql = string.Format(@"update [InsuranceUser] set RemainingCount=MonthLimitCount"); #endregion return(CgtInsuranceDB.GetInstance().Execute(sql)); }
/// <summary> /// 查询保险订单(不分页) /// </summary> /// <param name="pageindex"></param> /// <param name="pagesize"></param> /// <param name="model"></param> /// <returns></returns> public List <InsuranceOrder> QueryInsuranceOrder(InsuranceOrder model, DateTime?BeginBillDate, DateTime?EndBillDate) { string sql = GetsqlData(model, BeginBillDate, EndBillDate); return(CgtInsuranceDB.GetInstance().Query <InsuranceOrder>(sql, model.OthOrderCode, model.UserId, Convert.ToDateTime(BeginBillDate).ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToDateTime(EndBillDate).ToString("yyyy-MM-dd") + " 23:59:59" ).ToList()); }
/// <summary> /// 查询保险订单(分页) /// </summary> /// <param name="pageindex"></param> /// <param name="pagesize"></param> /// <param name="model"></param> /// <returns></returns> public Page <dynamic> PageInsuranceOrder(int pageindex, int pagesize, InsuranceOrder model, DateTime?BeginBillDate, DateTime?EndBillDate) { string sql = GetsqlData(model, BeginBillDate, EndBillDate); return(CgtInsuranceDB.GetInstance().Page <dynamic>(pageindex, pagesize, sql, model.OthOrderCode, model.UserId, Convert.ToDateTime(BeginBillDate).ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToDateTime(EndBillDate).ToString("yyyy-MM-dd") + " 23:59:59" )); }
/// <summary> /// 用户登录,返回实体 /// </summary> /// <param name="model"></param> /// <returns></returns> public InsuranceUser Login(InsuranceUser model) { #region sql string sql = string.Format(@" SELECT UserId,UserName,UserAccountId,Status,CreateTime,Ip FROM dbo.InsuranceUser WITH (NOLOCK) WHERE 1=1 AND UserName=@0 AND UserPwd=@1 AND Status=1 "); #endregion return(CgtInsuranceDB.GetInstance().FirstOrDefault <InsuranceUser>(sql, model.UserName, model.UserPwd)); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="list"></param> /// <returns></returns> public int Insert(InsuranceOrder model, List <InsurancedPerson> list, out string msg) { using (var db = CgtInsuranceDB.GetInstance()) { int index = 0; int count = 0; db.BeginTransaction(); try { model.CreateTime = DateTime.Now; var id = db.Insert(model); foreach (var item in list) { item.InsuredOrderId = Convert.ToInt64(id); count += item.ApplyNum; db.Insert(item); index++; } index++; var user = db.SingleOrDefault <InsuranceUser>("select * from InsuranceUser where UserId =@0", model.UserId); var remiancount = user.RemainingCount - count; if (remiancount < 0) { db.AbortTransaction(); msg = "超过月限额数量"; return(-1); } db.Execute("update InsuranceUser set RemainingCount =@1 where UserId =@0", model.UserId, remiancount); db.CompleteTransaction(); } catch (Exception ex) { db.AbortTransaction(); index = -1; throw ex; } msg = ""; return(index); } }