private static Tab_CourseMain_Type ToModel(DataRow row) { Tab_CourseMain_Type model = new Tab_CourseMain_Type(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.CourseMainType = row.IsNull("CourseMainType")?null:(System.String)row["CourseMainType"]; model.CreatedDate = row.IsNull("CreatedDate")?null:(System.DateTime?)row["CreatedDate"]; return(model); }
public int AddNew(Tab_CourseMain_Type model) { string sql = "insert into Tab_CourseMain_Type(CourseMainType,CreatedDate) values(@CourseMainType,@CreatedDate); select @@identity ;"; int idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@CourseMainType", model.CourseMainType) , new SqlParameter("@CreatedDate", model.CreatedDate) )); return(idx); }
public bool Update(Tab_CourseMain_Type model) { string sql = "update Tab_CourseMain_Type set CourseMainType=@CourseMainType,CreatedDate=@CreatedDate where idx=@idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@CourseMainType", model.CourseMainType) , new SqlParameter("@CreatedDate", model.CreatedDate) , new SqlParameter("idx", model.Idx) ); return(rows > 0); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { string idx = Request["Idx"]; if (!String.IsNullOrEmpty(idx)) { DBEntity.Tab_CourseMain_Type ent = new DBEntity.Tab_CourseMain_Type(); ent = ent.Get(idx); this.CourseMainType.Text = ent.CourseMainType; this.CreatedDate.Text = ent.CreatedDate.ToString(); } } }
public Tab_CourseMain_Type Get(string idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_CourseMain_Type 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_Type model = ToModel(row); return(model); }