/// <summary> /// 得到一个对象实体 /// </summary> public SubjectCashModel GetModel(decimal SubjectCashId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SubjectCashId, MemberId, CreateTime, Amount, SubjectCashStatusId, Memo, DoneTime, MemberBankCardId "); strSql.Append(" from CORE.dbo.SubjectCash "); strSql.Append(" where SubjectCashId=@SubjectCashId"); SqlParameter[] parameters = { new SqlParameter("@SubjectCashId", SqlDbType.Decimal) }; parameters[0].Value = SubjectCashId; SubjectCashModel model = new SubjectCashModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SubjectCashId"].ToString() != "") { model.SubjectCashId = decimal.Parse(ds.Tables[0].Rows[0]["SubjectCashId"].ToString()); } if (ds.Tables[0].Rows[0]["MemberId"].ToString() != "") { model.MemberId = decimal.Parse(ds.Tables[0].Rows[0]["MemberId"].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]["Amount"].ToString() != "") { model.Amount = decimal.Parse(ds.Tables[0].Rows[0]["Amount"].ToString()); } if (ds.Tables[0].Rows[0]["SubjectCashStatusId"].ToString() != "") { model.SubjectCashStatusId = int.Parse(ds.Tables[0].Rows[0]["SubjectCashStatusId"].ToString()); } model.Memo = ds.Tables[0].Rows[0]["Memo"].ToString(); if (ds.Tables[0].Rows[0]["DoneTime"].ToString() != "") { model.DoneTime = DateTime.Parse(ds.Tables[0].Rows[0]["DoneTime"].ToString()); } if (ds.Tables[0].Rows[0]["MemberBankCardId"].ToString() != "") { model.MemberBankCardId = decimal.Parse(ds.Tables[0].Rows[0]["MemberBankCardId"].ToString()); } return(model); } else { return(model); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SubjectCashModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update CORE.dbo.SubjectCash set "); strSql.Append(" MemberId = @MemberId , "); strSql.Append(" CreateTime = @CreateTime , "); strSql.Append(" Amount = @Amount , "); strSql.Append(" SubjectCashStatusId = @SubjectCashStatusId , "); strSql.Append(" Memo = @Memo , "); strSql.Append(" DoneTime = @DoneTime , "); strSql.Append(" MemberBankCardId = @MemberBankCardId "); strSql.Append(" where SubjectCashId=@SubjectCashId "); SqlParameter[] parameters = { new SqlParameter("@SubjectCashId", SqlDbType.Decimal, 9), new SqlParameter("@MemberId", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Amount", SqlDbType.Decimal, 9), new SqlParameter("@SubjectCashStatusId", SqlDbType.Int, 4), new SqlParameter("@Memo", SqlDbType.VarChar, 500), new SqlParameter("@DoneTime", SqlDbType.DateTime), new SqlParameter("@MemberBankCardId", SqlDbType.Decimal, 9) }; parameters[0].Value = model.SubjectCashId; parameters[1].Value = model.MemberId; parameters[2].Value = model.CreateTime; parameters[3].Value = model.Amount; parameters[4].Value = model.SubjectCashStatusId; parameters[5].Value = model.Memo; parameters[6].Value = model.DoneTime; parameters[7].Value = model.MemberBankCardId; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(SubjectCashModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CORE.dbo.SubjectCash ("); strSql.Append("MemberId,CreateTime,Amount,SubjectCashStatusId,Memo,DoneTime,MemberBankCardId"); strSql.Append(") values ("); strSql.Append("@MemberId,@CreateTime,@Amount,@SubjectCashStatusId,@Memo,@DoneTime,@MemberBankCardId"); strSql.Append(") "); strSql.Append(";"); SqlParameter[] parameters = { new SqlParameter("@MemberId", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Amount", SqlDbType.Decimal, 9), new SqlParameter("@SubjectCashStatusId", SqlDbType.Int, 4), new SqlParameter("@Memo", SqlDbType.VarChar, 500), new SqlParameter("@DoneTime", SqlDbType.DateTime), new SqlParameter("@MemberBankCardId", SqlDbType.Decimal, 9) }; parameters[0].Value = model.MemberId; parameters[1].Value = model.CreateTime; parameters[2].Value = model.Amount; parameters[3].Value = model.SubjectCashStatusId; parameters[4].Value = model.Memo; parameters[5].Value = model.DoneTime; parameters[6].Value = model.MemberBankCardId; bool result = false; try { model.SubjectCashId = decimal.Parse(helper.ExecuteNonQueryBackId(strSql.ToString(), "SubjectCashId", parameters)); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }