public NV_Menu_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_Menu_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@id", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_Menu_ChiTiet model = new NV_Menu_ChiTiet(); myConnection.Open(); using (SqlDataAdapter mData = new SqlDataAdapter(myCommand)) { dt = new DataTable(); mData.Fill(dt); } if (dt != null && dt.Rows.Count > 0) { model = new NV_Menu_ChiTiet(dt); } return(model); } } }
public NV_Menu_ChiTiet GetByUrl(string url) { string sql = "select top 1 *,dbo.getUrl(MenuID,'Menu',null) as UrlFull from Menu where Duyet=1 and TenUrl='" + url + "'"; DataTable dt = Sys_Common.getDataByQuery(sql); NV_Menu_ChiTiet menu = new NV_Menu_ChiTiet(); if (dt != null && dt.Rows.Count > 0) { menu = new NV_Menu_ChiTiet(dt); } return(menu); }
public int getLevel(int menuCha) { try { NV_Menu_ChiTiet ct = GetById(menuCha); return(ct.Level + 1); } catch { return(1); } }
public bool update(NV_Menu_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_Menu_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@MenuID", SqlDbType.Int); pID.Value = model.MenuID; myCommand.Parameters.Add(pID); SqlParameter pTenMenu = new SqlParameter("@TenMenu", SqlDbType.NVarChar, 250); pTenMenu.Value = model.TenMenu; myCommand.Parameters.Add(pTenMenu); SqlParameter pFrameViewID = new SqlParameter("@ChucNangID", SqlDbType.Int); pFrameViewID.Value = model.ChucNangID; myCommand.Parameters.Add(pFrameViewID); SqlParameter pUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 250); pUrl.Value = model.Url; myCommand.Parameters.Add(pUrl); SqlParameter pTenUrl = new SqlParameter("@TenUrl", SqlDbType.NVarChar, 250); pTenUrl.Value = model.TenUrl; myCommand.Parameters.Add(pTenUrl); SqlParameter pDuyet = new SqlParameter("@Duyet", SqlDbType.Bit); pDuyet.Value = model.Duyet; myCommand.Parameters.Add(pDuyet); SqlParameter pNoiBat = new SqlParameter("@NoiBat", SqlDbType.Bit); pNoiBat.Value = model.NoiBat; myCommand.Parameters.Add(pNoiBat); SqlParameter pStt = new SqlParameter("@Stt", SqlDbType.Int); pStt.Value = model.Stt; myCommand.Parameters.Add(pStt); SqlParameter pVitri = new SqlParameter("@Vitri", SqlDbType.Int); pVitri.Value = model.Vitri; myCommand.Parameters.Add(pVitri); SqlParameter pLevel = new SqlParameter("@Level", SqlDbType.Int); pLevel.Value = model.Level; myCommand.Parameters.Add(pLevel); SqlParameter pParentID = new SqlParameter("@ParentID", SqlDbType.Int); pParentID.Value = model.ParentID; myCommand.Parameters.Add(pParentID); SqlParameter pPageTitle = new SqlParameter("@PageTitle", SqlDbType.NVarChar, 200); pPageTitle.Value = model.PageTitle; myCommand.Parameters.Add(pPageTitle); SqlParameter pMetaKeyword = new SqlParameter("@MetaKeyword", SqlDbType.NVarChar, 200); pMetaKeyword.Value = model.MetaKeyword; myCommand.Parameters.Add(pMetaKeyword); SqlParameter pMetaDescription = new SqlParameter("@MetaDescription", SqlDbType.NVarChar, 300); pMetaDescription.Value = model.MetaDescription; myCommand.Parameters.Add(pMetaDescription); SqlParameter pMota = new SqlParameter("@Mota", SqlDbType.NVarChar, 300); pMota.Value = model.Mota; myCommand.Parameters.Add(pMota); SqlParameter pHinhAnh = new SqlParameter("@HinhAnh", SqlDbType.Int, 300); pHinhAnh.Value = model.HinhAnh; myCommand.Parameters.Add(pHinhAnh); SqlParameter pLang = new SqlParameter("@Lang", SqlDbType.VarChar); pLang.Value = model.Lang; myCommand.Parameters.Add(pLang); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }