private static Model.SMS DataRowToModel(DataRow row) { yny_002.Model.SMS model = new yny_002.Model.SMS(); if (row != null) { if (row["SID"] != null && row["SID"].ToString() != "") { model.SID = int.Parse(row["SID"].ToString()); } if (row["SType"] != null) { model.SType = (Model.SMSType)Enum.Parse(typeof(Model.SMSType), row["SType"].ToString()); } if (row["SContent"] != null) { model.SContent = row["SContent"].ToString(); } if (row["Tel"] != null) { model.Tel = row["Tel"].ToString(); } if (row["Email"] != null) { model.Email = row["Email"].ToString(); } if (row["SMSKey"] != null) { model.SMSKey = row["SMSKey"].ToString(); } if (row["CreateDate"] != null && row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["MID"] != null) { model.MID = row["MID"].ToString(); } if (row["SendState"] != null && row["SendState"].ToString() != "") { model.SendState = bool.Parse(row["SendState"].ToString()); } } return(model); }
public static Model.SMS GetModel(object obj) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from SMS "); strSql.Append(" where SID=@SID"); SqlParameter[] parameters = { new SqlParameter("@SID", SqlDbType.Int, 4) }; parameters[0].Value = obj; yny_002.Model.SMS model = new yny_002.Model.SMS(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }