/// <summary> /// 得到一个对象实体 /// </summary> public TF.RunSafty.Entry.Diary DataRowToModel(DataRow row) { TF.RunSafty.Entry.Diary model = new TF.RunSafty.Entry.Diary(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["UserId"] != null && row["UserId"].ToString() != "") { model.UserId = int.Parse(row["UserId"].ToString()); } if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } if (row["DiaryContent"] != null) { model.DiaryContent = row["DiaryContent"].ToString(); } if (row["FileName"] != null) { model.FileName = row["FileName"].ToString(); } if (row["FileUrl"] != null) { model.FileUrl = row["FileUrl"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(TF.RunSafty.Entry.Diary model) { string strSql = @"update Tab_Diary set AddTime=@AddTime,DiaryContent=@DiaryContent,UserId=@UserId where Id=@id"; SqlParameter[] sqlParameter = { new SqlParameter("id", model.Id), new SqlParameter("AddTime", model.AddTime), new SqlParameter("DiaryContent", model.DiaryContent), new SqlParameter("UserId", model.UserId) }; return(SqlHelps.ExecuteNonQuery(ConnectionString, CommandType.Text, strSql, sqlParameter)); }
/// <summary> /// 得到一个对象实体 /// </summary> public TF.RunSafty.Entry.Diary GetModel(int Id) { string strSql = "select * from Tab_Diary where Id='" + Id + "'"; DataSet ds = SqlHelps.ReturnDataSet(ConnectionString, CommandType.Text, strSql); TF.RunSafty.Entry.Diary model = new TF.RunSafty.Entry.Diary(); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TF.RunSafty.Entry.Diary model) { string strSql = @"insert into Tab_Diary (AddTime,DiaryContent,UserId) values (@AddTime,@DiaryContent,@UserId)"; SqlParameter[] sqlParameter = { new SqlParameter("AddTime", model.AddTime), new SqlParameter("DiaryContent", model.DiaryContent), new SqlParameter("UserId", model.UserId) }; object obj = SqlHelps.ExecuteNonQuery(ConnectionString, CommandType.Text, strSql, sqlParameter); if (DBNull.Value.Equals(obj)) { return(0); } return(Convert.ToInt32(obj)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(TF.RunSafty.Entry.Diary model) { return(DBUtilsDy.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TF.RunSafty.Entry.Diary model) { return(DBUtilsDy.Add(model)); }