public static string GetDefaultTerms() { using (var cn = new SqlConnection(WebInfo.Conn)) { StringBuilder sql = new StringBuilder(); sql.Append(" SELECT Text "); sql.Append(" FROM RewardText "); sql.Append(" WHERE ID = 'DefaultTerms' "); RewardTextModel text = cn.Query <RewardTextModel>(sql.ToString()).SingleOrDefault(); return(text.Text); } }
public static void SetItemText(RewardTextModel item) { SQLData.Database db = new SQLData.Database(WebInfo.Conn); SQLData.TableObject tableObj = db.GetTableObject("RewardText"); tableObj.GetDataFromObject(item); string sql = "Select top 1 * From RewardText Where ID = @ID and SiteID= @SiteID "; ParameterCollection a1 = new ParameterCollection(); a1.Add("ID", item.ID); a1.Add("SiteID", item.SiteID); bool isNew = db.GetFirstValue(sql, a1) == null; if (isNew) { tableObj["Creator"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; tableObj["CreateTime"] = DateTime.Now; tableObj.Insert(); } else { //tableObj.Remove("SiteID"); //tableObj.Remove("Creator"); //tableObj.Remove("CreateTime"); //tableObj["Modifier"] = WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id; //tableObj["ModifyTime"] = DateTime.Now; string a = "UPDATE RewardText set Text =@Text ,Modifier=@Modifier,ModifyTime=@ModifyTime Where ID = @ID2 and SiteID= @SiteID2"; SQLData.ParameterCollection paraList = new SQLData.ParameterCollection(); paraList.Add("ID2", item.ID); paraList.Add("SiteID2", item.SiteID); paraList.Add("Text", item.Text); paraList.Add("Modifier", WorkV3.Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id); paraList.Add("ModifyTime", DateTime.Now); int exeCount = db.ExecuteNonQuery(a, paraList); } }