/// <summary> /// 得到一个对象实体 /// </summary> public MonthlyStatementAppendMoneyDataInfo GetMonthlyStatementAppendMoneyDataInfoModel(int MonthlyStatementAppendMoneyDataID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 MonthlyStatementAppendMoneyDataID,MonthlyStatementID,mMoney,mDateTime,mState,mRemake,mAppendTime from tbMonthlyStatementAppendMoneyDataInfo "); strSql.Append(" where MonthlyStatementAppendMoneyDataID=@MonthlyStatementAppendMoneyDataID"); SqlParameter[] parameters = { new SqlParameter("@MonthlyStatementAppendMoneyDataID", SqlDbType.Int, 4) }; parameters[0].Value = MonthlyStatementAppendMoneyDataID; MonthlyStatementAppendMoneyDataInfo model = new MonthlyStatementAppendMoneyDataInfo(); DataSet ds = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["MonthlyStatementAppendMoneyDataID"] != null && ds.Tables[0].Rows[0]["MonthlyStatementAppendMoneyDataID"].ToString() != "") { model.MonthlyStatementAppendMoneyDataID = int.Parse(ds.Tables[0].Rows[0]["MonthlyStatementAppendMoneyDataID"].ToString()); } if (ds.Tables[0].Rows[0]["MonthlyStatementID"] != null && ds.Tables[0].Rows[0]["MonthlyStatementID"].ToString() != "") { model.MonthlyStatementID = int.Parse(ds.Tables[0].Rows[0]["MonthlyStatementID"].ToString()); } if (ds.Tables[0].Rows[0]["mMoney"] != null && ds.Tables[0].Rows[0]["mMoney"].ToString() != "") { model.mMoney = decimal.Parse(ds.Tables[0].Rows[0]["mMoney"].ToString()); } if (ds.Tables[0].Rows[0]["mDateTime"] != null && ds.Tables[0].Rows[0]["mDateTime"].ToString() != "") { model.mDateTime = DateTime.Parse(ds.Tables[0].Rows[0]["mDateTime"].ToString()); } if (ds.Tables[0].Rows[0]["mState"] != null && ds.Tables[0].Rows[0]["mState"].ToString() != "") { model.mState = int.Parse(ds.Tables[0].Rows[0]["mState"].ToString()); } if (ds.Tables[0].Rows[0]["mRemake"] != null && ds.Tables[0].Rows[0]["mRemake"].ToString() != "") { model.mRemake = ds.Tables[0].Rows[0]["mRemake"].ToString(); } if (ds.Tables[0].Rows[0]["mAppendTime"] != null && ds.Tables[0].Rows[0]["mAppendTime"].ToString() != "") { model.mAppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["mAppendTime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateMonthlyStatementAppendMoneyDataInfo(MonthlyStatementAppendMoneyDataInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tbMonthlyStatementAppendMoneyDataInfo set "); strSql.Append("MonthlyStatementID=@MonthlyStatementID,"); strSql.Append("mMoney=@mMoney,"); strSql.Append("mDateTime=@mDateTime,"); strSql.Append("mState=@mState,"); strSql.Append("mRemake=@mRemake,"); strSql.Append("mAppendTime=@mAppendTime"); strSql.Append(" where MonthlyStatementAppendMoneyDataID=@MonthlyStatementAppendMoneyDataID"); SqlParameter[] parameters = { new SqlParameter("@MonthlyStatementID", SqlDbType.Int, 4), new SqlParameter("@mMoney", SqlDbType.Decimal, 9), new SqlParameter("@mDateTime", SqlDbType.DateTime), new SqlParameter("@mState", SqlDbType.Int, 4), new SqlParameter("@mRemake", SqlDbType.VarChar, 512), new SqlParameter("@mAppendTime", SqlDbType.DateTime), new SqlParameter("@MonthlyStatementAppendMoneyDataID", SqlDbType.Int, 4) }; parameters[0].Value = model.MonthlyStatementID; parameters[1].Value = model.mMoney; parameters[2].Value = model.mDateTime; parameters[3].Value = model.mState; parameters[4].Value = model.mRemake; parameters[5].Value = model.mAppendTime; parameters[6].Value = model.MonthlyStatementAppendMoneyDataID; int rows = DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int AddMonthlyStatementAppendMoneyDataInfo(MonthlyStatementAppendMoneyDataInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tbMonthlyStatementAppendMoneyDataInfo("); strSql.Append("MonthlyStatementID,mMoney,mDateTime,mState,mRemake,mAppendTime)"); strSql.Append(" values ("); strSql.Append("@MonthlyStatementID,@mMoney,@mDateTime,@mState,@mRemake,@mAppendTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MonthlyStatementID", SqlDbType.Int, 4), new SqlParameter("@mMoney", SqlDbType.Decimal, 9), new SqlParameter("@mDateTime", SqlDbType.DateTime), new SqlParameter("@mState", SqlDbType.Int, 4), new SqlParameter("@mRemake", SqlDbType.VarChar, 512), new SqlParameter("@mAppendTime", SqlDbType.DateTime) }; parameters[0].Value = model.MonthlyStatementID; parameters[1].Value = model.mMoney; parameters[2].Value = model.mDateTime; parameters[3].Value = model.mState; parameters[4].Value = model.mRemake; parameters[5].Value = model.mAppendTime; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj == null) { return(-1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool UpdateMonthlyStatementAppendMoneyDataInfo(MonthlyStatementAppendMoneyDataInfo model) { return(DatabaseProvider.GetInstance().UpdateMonthlyStatementAppendMoneyDataInfo(model)); }