public bool danhsachloaisach(List <loaisachDTO> list) { string query = string.Format("select* from [cacloaisach] order by loaisach asc "); SqlParameter[] parm = new SqlParameter[1]; // ko can thiet nhung phai co docgiaDTO dg = new docgiaDTO(); parm[0] = new SqlParameter("@masach", SqlDbType.Int); parm[0].Value = dg.MaThe; DataTable datatable = new DataTable(); datatable = conn.excuteNonQuery(query, parm); //gan value trong datatable vao DTO foreach (DataRow dr in datatable.Rows) { loaisachDTO loaisach = new loaisachDTO(); loaisach.Theloaisach = dr["loaisach"].ToString(); list.Add(loaisach); } return(true); }
/// <summary> /// Thêm thể loại sách /// </summary> /// <param name="loaisach"></param> /// <returns></returns> public bool ThemTheLoaisach(loaisachDTO loaisach) { cacloaisachDAL loaisachDAL = new cacloaisachDAL(); if (!loaisachDAL.themTheLoai(loaisach)) { BUS_notification.mess = "Không thể thêm loại sách"; return(false); } return(true); }
public bool themTheLoai(loaisachDTO lsDTO) { string query = string.Format("insert into [cacloaisach] values (@loaisach)"); SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@loaisach", SqlDbType.NVarChar); param[0].Value = Convert.ToString(lsDTO.Theloaisach); conn.excuteNonQuery2(query, param); return(true); }