/// <summary> /// 更新一条数据 /// </summary> public void Update(CardCenter.Entity.SendLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SendLog set "); strSql.Append("IsSend=@IsSend,"); strSql.Append("Error=@Error,"); strSql.Append("SendPhone=@SendPhone,"); strSql.Append("SendContext=@SendContext"); strSql.Append(" where Guid=@Guid "); SqlParameter[] parameters = { new SqlParameter("@IsSend", SqlDbType.Bit, 1), new SqlParameter("@Error", SqlDbType.NVarChar, 512), new SqlParameter("@SendPhone", SqlDbType.NVarChar, 32), new SqlParameter("@SendContext", SqlDbType.NVarChar, 512), new SqlParameter("@Guid", SqlDbType.NVarChar, 64) }; parameters[0].Value = model.IsSend; parameters[1].Value = model.Error; parameters[2].Value = model.SendPhone; parameters[3].Value = model.SendContext; parameters[4].Value = model.Guid; TranHelper.AddTran(strSql, parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public CardCenter.Entity.SendLog DataRowToModel(DataRow row) { CardCenter.Entity.SendLog model = new CardCenter.Entity.SendLog(); if (row != null) { if (row["Guid"] != null) { model.Guid = row["Guid"].ToString(); } if (row["IsSend"] != null && row["IsSend"].ToString() != "") { if ((row["IsSend"].ToString() == "1") || (row["IsSend"].ToString().ToLower() == "true")) { model.IsSend = true; } else { model.IsSend = false; } } if (row["Error"] != null) { model.Error = row["Error"].ToString(); } if (row["SendPhone"] != null) { model.SendPhone = row["SendPhone"].ToString(); } if (row["SendContext"] != null) { model.SendContext = row["SendContext"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(CardCenter.Entity.SendLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SendLog("); strSql.Append("Guid,IsSend,Error,SendPhone,SendContext)"); strSql.Append(" values ("); strSql.Append("@Guid,@IsSend,@Error,@SendPhone,@SendContext)"); SqlParameter[] parameters = { new SqlParameter("@Guid", SqlDbType.NVarChar, 64), new SqlParameter("@IsSend", SqlDbType.Bit, 1), new SqlParameter("@Error", SqlDbType.NVarChar, 512), new SqlParameter("@SendPhone", SqlDbType.NVarChar, 32), new SqlParameter("@SendContext", SqlDbType.NVarChar, 512) }; parameters[0].Value = model.Guid; parameters[1].Value = model.IsSend; parameters[2].Value = model.Error; parameters[3].Value = model.SendPhone; parameters[4].Value = model.SendContext; TranHelper.AddTran(strSql, parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public CardCenter.Entity.SendLog GetModel(string Guid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Guid,IsSend,Error,SendPhone,SendContext from SendLog "); strSql.Append(" where Guid=@Guid "); SqlParameter[] parameters = { new SqlParameter("@Guid", SqlDbType.NVarChar, 64) }; parameters[0].Value = Guid; CardCenter.Entity.SendLog model = new CardCenter.Entity.SendLog(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }