private static Tab_SmartPerson ToModel(DataRow row) { Tab_SmartPerson model = new Tab_SmartPerson(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.DarenName = row.IsNull("DarenName")?null:(System.String)row["DarenName"]; model.HeaderImg = row.IsNull("HeaderImg")?null:(System.String)row["HeaderImg"]; model.Title = row.IsNull("Title")?null:(System.String)row["Title"]; model.BeautyResume = row.IsNull("BeautyResume")?null:(System.String)row["BeautyResume"]; model.BeautyShare = row.IsNull("BeautyShare")?null:(System.String)row["BeautyShare"]; model.SinaShareContent = row.IsNull("SinaShareContent")?null:(System.String)row["SinaShareContent"]; model.CreatedDate = row.IsNull("CreatedDate")?null:(System.DateTime?)row["CreatedDate"]; model.showPageBool = row.IsNull("showPageBool")?null:(System.String)row["showPageBool"]; return(model); }
public int AddNew(Tab_SmartPerson model) { string sql = "insert into Tab_SmartPerson(DarenName,HeaderImg,Title,BeautyResume,BeautyShare,SinaShareContent,CreatedDate,showPageBool) values(@DarenName,@HeaderImg,@Title,@BeautyResume,@BeautyShare,@SinaShareContent,@CreatedDate,@showPageBool); select @@identity ;"; int Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@DarenName", model.DarenName) , new SqlParameter("@HeaderImg", model.HeaderImg) , new SqlParameter("@Title", model.Title) , new SqlParameter("@BeautyResume", model.BeautyResume) , new SqlParameter("@BeautyShare", model.BeautyShare) , new SqlParameter("@SinaShareContent", model.SinaShareContent) , new SqlParameter("@CreatedDate", model.CreatedDate) , new SqlParameter("@showPageBool", model.showPageBool) )); return(Idx); }
public bool Update(Tab_SmartPerson model) { string sql = "update Tab_SmartPerson set DarenName=@DarenName,HeaderImg=@HeaderImg,Title=@Title,BeautyResume=@BeautyResume,BeautyShare=@BeautyShare,SinaShareContent=@SinaShareContent,CreatedDate=@CreatedDate,showPageBool=@showPageBool where Idx=@Idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@DarenName", model.DarenName) , new SqlParameter("@HeaderImg", model.HeaderImg) , new SqlParameter("@Title", model.Title) , new SqlParameter("@BeautyResume", model.BeautyResume) , new SqlParameter("@BeautyShare", model.BeautyShare) , new SqlParameter("@SinaShareContent", model.SinaShareContent) , new SqlParameter("@CreatedDate", model.CreatedDate) , new SqlParameter("@showPageBool", model.showPageBool) , new SqlParameter("Idx", model.Idx) ); return(rows > 0); }
public Tab_SmartPerson Get(string Idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_SmartPerson where Idx=@Idx", new SqlParameter("Idx", Idx)).Tables[0]; if (dt.Rows.Count > 1) { throw new Exception("more than 1 row was found"); } if (dt.Rows.Count <= 0) { return(null); } DataRow row = dt.Rows[0]; Tab_SmartPerson model = ToModel(row); return(model); }