public Rain.Model.user_amount_log DataRowToModel(DataRow row) { Rain.Model.user_amount_log userAmountLog = new Rain.Model.user_amount_log(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { userAmountLog.id = int.Parse(row["id"].ToString()); } if (row["user_id"] != null && row["user_id"].ToString() != "") { userAmountLog.user_id = int.Parse(row["user_id"].ToString()); } if (row["user_name"] != null) { userAmountLog.user_name = row["user_name"].ToString(); } if (row["value"] != null && row["value"].ToString() != "") { userAmountLog.value = Decimal.Parse(row["value"].ToString()); } if (row["remark"] != null) { userAmountLog.remark = row["remark"].ToString(); } if (row["add_time"] != null && row["add_time"].ToString() != "") { userAmountLog.add_time = DateTime.Parse(row["add_time"].ToString()); } } return(userAmountLog); }
public bool Update(Rain.Model.user_amount_log model) { using (OleDbConnection connection = new OleDbConnection(DbHelperOleDb.connectionString)) { connection.Open(); using (OleDbTransaction trans = connection.BeginTransaction()) { try { StringBuilder stringBuilder1 = new StringBuilder(); stringBuilder1.Append("update " + this.databaseprefix + "user_amount_log set "); stringBuilder1.Append("user_id=@user_id,"); stringBuilder1.Append("user_name=@user_name,"); stringBuilder1.Append("[value]=@value,"); stringBuilder1.Append("[remark]=@remark,"); stringBuilder1.Append("add_time=@add_time"); stringBuilder1.Append(" where id=@id"); OleDbParameter[] oleDbParameterArray1 = new OleDbParameter[6] { new OleDbParameter("@user_id", OleDbType.Integer, 4), new OleDbParameter("@user_name", OleDbType.VarChar, 100), new OleDbParameter("@value", OleDbType.Decimal, 5), new OleDbParameter("@remark", OleDbType.VarChar, 500), new OleDbParameter("@add_time", OleDbType.Date), new OleDbParameter("@id", OleDbType.Integer, 4) }; oleDbParameterArray1[0].Value = (object)model.user_id; oleDbParameterArray1[1].Value = (object)model.user_name; oleDbParameterArray1[2].Value = (object)model.value; oleDbParameterArray1[3].Value = (object)model.remark; oleDbParameterArray1[4].Value = (object)model.add_time; oleDbParameterArray1[5].Value = (object)model.id; DbHelperOleDb.ExecuteSql(connection, trans, stringBuilder1.ToString(), oleDbParameterArray1); StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.Append("update " + this.databaseprefix + "users set amount=amount+" + (object)model.value); stringBuilder2.Append(" where id=@id"); OleDbParameter[] oleDbParameterArray2 = new OleDbParameter[1] { new OleDbParameter("@id", OleDbType.Integer, 4) }; oleDbParameterArray2[0].Value = (object)model.user_id; DbHelperOleDb.ExecuteSql(connection, trans, stringBuilder2.ToString(), oleDbParameterArray2); trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(true); }
public int Add(Rain.Model.user_amount_log model) { using (OleDbConnection oleDbConnection = new OleDbConnection(DbHelperOleDb.connectionString)) { oleDbConnection.Open(); using (OleDbTransaction trans = oleDbConnection.BeginTransaction()) { try { StringBuilder stringBuilder1 = new StringBuilder(); stringBuilder1.Append("insert into " + this.databaseprefix + "user_amount_log("); stringBuilder1.Append("user_id,user_name,[value],[remark],add_time)"); stringBuilder1.Append(" values ("); stringBuilder1.Append("@user_id,@user_name,@value,@remark,@add_time)"); OleDbParameter[] oleDbParameterArray1 = new OleDbParameter[5] { new OleDbParameter("@user_id", OleDbType.Integer, 4), new OleDbParameter("@user_name", OleDbType.VarChar, 100), new OleDbParameter("@value", OleDbType.Decimal, 5), new OleDbParameter("@remark", OleDbType.VarChar, 500), new OleDbParameter("@add_time", OleDbType.Date) }; oleDbParameterArray1[0].Value = (object)model.user_id; oleDbParameterArray1[1].Value = (object)model.user_name; oleDbParameterArray1[2].Value = (object)model.value; oleDbParameterArray1[3].Value = (object)model.remark; oleDbParameterArray1[4].Value = (object)model.add_time; DbHelperOleDb.ExecuteSql(oleDbConnection, trans, stringBuilder1.ToString(), oleDbParameterArray1); model.id = this.GetMaxId(oleDbConnection, trans); StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.Append("update " + this.databaseprefix + "users set amount=amount+" + (object)model.value); stringBuilder2.Append(" where id=@id"); OleDbParameter[] oleDbParameterArray2 = new OleDbParameter[1] { new OleDbParameter("@id", OleDbType.Integer, 4) }; oleDbParameterArray2[0].Value = (object)model.user_id; DbHelperOleDb.ExecuteSql(oleDbConnection, trans, stringBuilder2.ToString(), oleDbParameterArray2); trans.Commit(); } catch { trans.Rollback(); return(-1); } } } return(model.id); }
public Rain.Model.user_amount_log GetModel(int id) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("select top 1 id,user_id,user_name,[value],[remark],add_time from " + this.databaseprefix + "user_amount_log "); stringBuilder.Append(" where id=@id"); OleDbParameter[] oleDbParameterArray = new OleDbParameter[1] { new OleDbParameter("@id", OleDbType.Integer, 4) }; oleDbParameterArray[0].Value = (object)id; Rain.Model.user_amount_log userAmountLog = new Rain.Model.user_amount_log(); DataSet dataSet = DbHelperOleDb.Query(stringBuilder.ToString(), oleDbParameterArray); if (dataSet.Tables[0].Rows.Count > 0) { return(this.DataRowToModel(dataSet.Tables[0].Rows[0])); } return((Rain.Model.user_amount_log)null); }
public bool Update(Rain.Model.user_amount_log model) { return(this.dal.Update(model)); }
public int Add(Rain.Model.user_amount_log model) { return(this.dal.Add(model)); }