/// <summary> /// 得到一个对象实体 /// </summary> public ND.PolicyService.DbEntity.UploadPolicyRecord GetModel(string uId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,UId,PolicyId,CommisionMoney,CommsionPoint,CreateTime,UpdateTime,UpdateSuccessCount,UpdateFailedCount,PartenerPolicyId,PolicyType from UploadPolicyRecord "); strSql.Append(" where UId=@UId ORDER BY CreateTime desc "); SqlParameter[] parameters = { new SqlParameter("@UId", SqlDbType.VarChar) }; parameters[0].Value = uId; ND.PolicyService.DbEntity.UploadPolicyRecord model = new ND.PolicyService.DbEntity.UploadPolicyRecord(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = new Guid(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["UId"].ToString() != "") { model.UId = long.Parse(ds.Tables[0].Rows[0]["UId"].ToString()); } model.PolicyId = ds.Tables[0].Rows[0]["PolicyId"].ToString(); if (ds.Tables[0].Rows[0]["CommisionMoney"].ToString() != "") { model.CommisionMoney = decimal.Parse(ds.Tables[0].Rows[0]["CommisionMoney"].ToString()); } if (ds.Tables[0].Rows[0]["CommsionPoint"].ToString() != "") { model.CommsionPoint = decimal.Parse(ds.Tables[0].Rows[0]["CommsionPoint"].ToString()); } if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } if (ds.Tables[0].Rows[0]["UpdateTime"].ToString() != "") { model.UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateTime"].ToString()); } if (ds.Tables[0].Rows[0]["UpdateSuccessCount"].ToString() != "") { model.UpdateSuccessCount = int.Parse(ds.Tables[0].Rows[0]["UpdateSuccessCount"].ToString()); } if (ds.Tables[0].Rows[0]["UpdateFailedCount"].ToString() != "") { model.UpdateFailedCount = int.Parse(ds.Tables[0].Rows[0]["UpdateFailedCount"].ToString()); } model.PartenerPolicyId = ds.Tables[0].Rows[0]["PartenerPolicyId"].ToString(); model.PolicyType = ds.Tables[0].Rows[0]["PolicyType"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ND.PolicyService.DbEntity.UploadPolicyRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update UploadPolicyRecord set "); strSql.Append("UId=@UId,"); strSql.Append("PolicyId=@PolicyId,"); strSql.Append("CommisionMoney=@CommisionMoney,"); strSql.Append("CommsionPoint=@CommsionPoint,"); strSql.Append("CreateTime=@CreateTime,"); strSql.Append("UpdateTime=@UpdateTime,"); strSql.Append("UpdateSuccessCount=@UpdateSuccessCount,"); strSql.Append("UpdateFailedCount=@UpdateFailedCount,"); strSql.Append("PartenerPolicyId=@PartenerPolicyId,"); strSql.Append("PolicyType=@PolicyType"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@UId", SqlDbType.BigInt, 8), new SqlParameter("@PolicyId", SqlDbType.VarChar, 50), new SqlParameter("@CommisionMoney", SqlDbType.Decimal, 9), new SqlParameter("@CommsionPoint", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@UpdateSuccessCount", SqlDbType.Int, 4), new SqlParameter("@UpdateFailedCount", SqlDbType.Int, 4), new SqlParameter("@PartenerPolicyId", SqlDbType.VarChar, 50), new SqlParameter("@PolicyType", SqlDbType.VarChar, 50), new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 16) }; parameters[0].Value = model.UId; parameters[1].Value = model.PolicyId; parameters[2].Value = model.CommisionMoney; parameters[3].Value = model.CommsionPoint; parameters[4].Value = model.CreateTime; parameters[5].Value = model.UpdateTime; parameters[6].Value = model.UpdateSuccessCount; parameters[7].Value = model.UpdateFailedCount; parameters[8].Value = model.PartenerPolicyId; parameters[9].Value = model.PolicyType; parameters[10].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(ND.PolicyService.DbEntity.UploadPolicyRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into UploadPolicyRecord("); strSql.Append("Id,UId,PolicyId,CommisionMoney,CommsionPoint,CreateTime,UpdateTime,UpdateSuccessCount,UpdateFailedCount,PartenerPolicyId,PolicyType)"); strSql.Append(" values ("); strSql.Append("@Id,@UId,@PolicyId,@CommisionMoney,@CommsionPoint,@CreateTime,@UpdateTime,@UpdateSuccessCount,@UpdateFailedCount,@PartenerPolicyId,@PolicyType)"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@UId", SqlDbType.BigInt, 8), new SqlParameter("@PolicyId", SqlDbType.VarChar, 50), new SqlParameter("@CommisionMoney", SqlDbType.Decimal, 9), new SqlParameter("@CommsionPoint", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@UpdateSuccessCount", SqlDbType.Int, 4), new SqlParameter("@UpdateFailedCount", SqlDbType.Int, 4), new SqlParameter("@PartenerPolicyId", SqlDbType.VarChar, 50), new SqlParameter("@PolicyType", SqlDbType.VarChar, 50) }; parameters[0].Value = model.Id; parameters[1].Value = model.UId; parameters[2].Value = model.PolicyId; parameters[3].Value = model.CommisionMoney; parameters[4].Value = model.CommsionPoint; parameters[5].Value = model.CreateTime; parameters[6].Value = model.UpdateTime; parameters[7].Value = model.UpdateSuccessCount; parameters[8].Value = model.UpdateFailedCount; parameters[9].Value = model.PartenerPolicyId; parameters[10].Value = model.PolicyType; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }