/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Information model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Information set "); strSql.Append("GUID=@GUID,"); strSql.Append("FromAccton=@FromAccton,"); strSql.Append("Credentials=@Credentials,"); strSql.Append("EailSuffix=@EailSuffix"); strSql.Append(" where GUID=@GUID and FromAccton=@FromAccton and Credentials=@Credentials and EailSuffix=@EailSuffix "); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.NVarChar, -1), new SqlParameter("@FromAccton", SqlDbType.NVarChar, -1), new SqlParameter("@Credentials", SqlDbType.NVarChar, -1), new SqlParameter("@EailSuffix", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.GUID; parameters[1].Value = model.FromAccton; parameters[2].Value = model.Credentials; parameters[3].Value = model.EailSuffix; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.Information model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Information("); strSql.Append("GUID,FromAccton,Credentials,EailSuffix)"); strSql.Append(" values ("); strSql.Append("@GUID,@FromAccton,@Credentials,@EailSuffix)"); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.NVarChar, -1), new SqlParameter("@FromAccton", SqlDbType.NVarChar, -1), new SqlParameter("@Credentials", SqlDbType.NVarChar, -1), new SqlParameter("@EailSuffix", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.GUID; parameters[1].Value = model.FromAccton; parameters[2].Value = model.Credentials; parameters[3].Value = model.EailSuffix; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Information GetModel(string GUID, string FromAccton, string Credentials, string EailSuffix) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 GUID,FromAccton,Credentials,EailSuffix from Information "); strSql.Append(" where GUID=@GUID and FromAccton=@FromAccton and Credentials=@Credentials and EailSuffix=@EailSuffix "); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.NVarChar, -1), new SqlParameter("@FromAccton", SqlDbType.NVarChar, -1), new SqlParameter("@Credentials", SqlDbType.NVarChar, -1), new SqlParameter("@EailSuffix", SqlDbType.NVarChar, -1) }; parameters[0].Value = GUID; parameters[1].Value = FromAccton; parameters[2].Value = Credentials; parameters[3].Value = EailSuffix; Maticsoft.Model.Information model = new Maticsoft.Model.Information(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public Maticsoft.Model.Information ExGetModel(string GUID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 GUID,FromAccton,Credentials,EailSuffix from Information "); strSql.Append(" where GUID=@GUID"); SqlParameter[] parameters = { new SqlParameter("@GUID", SqlDbType.NVarChar, -1) }; parameters[0].Value = GUID; Maticsoft.Model.Information model = new Maticsoft.Model.Information(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Information DataRowToModel(DataRow row) { Maticsoft.Model.Information model = new Maticsoft.Model.Information(); if (row != null) { if (row["GUID"] != null) { model.GUID = row["GUID"].ToString(); } if (row["FromAccton"] != null) { model.FromAccton = row["FromAccton"].ToString(); } if (row["Credentials"] != null) { model.Credentials = row["Credentials"].ToString(); } if (row["EailSuffix"] != null) { model.EailSuffix = row["EailSuffix"].ToString(); } } return(model); }