private static Tab_CourseMain_ViewLog ToModel(DataRow row) { Tab_CourseMain_ViewLog model = new Tab_CourseMain_ViewLog(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.UIdx = row.IsNull("UIdx")?null:(System.Int32?)row["UIdx"]; model.CourseMainIdx = row.IsNull("CourseMainIdx")?null:(System.Int32?)row["CourseMainIdx"]; model.IpAddress = row.IsNull("IpAddress")?null:(System.String)row["IpAddress"]; model.CreatedDate = row.IsNull("CreatedDate")?null:(System.DateTime?)row["CreatedDate"]; return(model); }
public int AddNew(Tab_CourseMain_ViewLog model) { string sql = "insert into Tab_CourseMain_ViewLog(UIdx,CourseMainIdx,IpAddress,CreatedDate) values(@UIdx,@CourseMainIdx,@IpAddress,@CreatedDate); select @@identity ;"; int Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@UIdx", model.UIdx) , new SqlParameter("@CourseMainIdx", model.CourseMainIdx) , new SqlParameter("@IpAddress", model.IpAddress) , new SqlParameter("@CreatedDate", model.CreatedDate) )); return(Idx); }
public bool Update(Tab_CourseMain_ViewLog model) { string sql = "update Tab_CourseMain_ViewLog set UIdx=@UIdx,CourseMainIdx=@CourseMainIdx,IpAddress=@IpAddress,CreatedDate=@CreatedDate where Idx=@Idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@UIdx", model.UIdx) , new SqlParameter("@CourseMainIdx", model.CourseMainIdx) , new SqlParameter("@IpAddress", model.IpAddress) , new SqlParameter("@CreatedDate", model.CreatedDate) , new SqlParameter("Idx", model.Idx) ); return(rows > 0); }
public Tab_CourseMain_ViewLog Get(string Idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_CourseMain_ViewLog 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_CourseMain_ViewLog model = ToModel(row); return(model); }