public void LoadThongTinLoaiTin(int idLoaiTin) { WebPortal.LoaiTin lt = new LoaiTin(); WebPortal.Model.LoaiTin loaiTin = lt.Single(idLoaiTin); Name.Text = loaiTin.TenLoai; Summary.Text = loaiTin.MoTa; }
public int InsertSubCate(JObject cate) { try { var catetitle = cate["catename"].ToString(); while (catetitle.Contains(" ")) { catetitle.Replace(" ", " "); } catetitle = TienIchController.RemoveUnicode(catetitle); catetitle = catetitle.Replace(" ", "-"); LoaiTin data = new LoaiTin(); data.Ten = cate["catename"].ToString(); data.Ten_KhongDau = catetitle; data.AnHien = (byte)cate["cateactive"]; data.ThuTu = (byte)cate["catenumber"]; data.idTL = (int)cate["cate"]; db.LoaiTins.Add(data); db.SaveChanges(); return(1); } catch (Exception) { return(0); } }
protected void btnSua_Click(object sender, EventArgs e) { LoaiTin lt = new LoaiTin(); if (txtMaLoaiTin.Text == "") { Response.Write("<script language='javascript'>alert('" + "Bạn chưa nhập mã loại tin!" + "')</script>"); txtMaLoaiTin.Focus(); } else { if (txtTenLoaiTin.Text == "") { Response.Write("<script language='javascript'>alert('" + "Bạn chưa nhập tên loại tin!" + "')</script>"); txtTenLoaiTin.Focus(); } else { lt.MaLoaiTin = txtMaLoaiTin.Text; lt.MaTheLoai = ddlMaTheLoai.SelectedValue; lt.TenLoaiTin = txtTenLoaiTin.Text; Response.Write("<script language=''javascript>alert('" + " Sửa thành công! " + "')</script>"); ltbll.SuaLoaiTin(lt); Page_Load(sender, e); txtMaLoaiTin.Text = ""; txtTenLoaiTin.Text = ""; } } }
public ActionResult Create(string TenLoai) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(TenLoai)) { LoaiTin lt = db.LoaiTin.SingleOrDefault(x => x.TenLoai == TenLoai); if (lt != null) { ModelState.AddModelError("", "Loại tin đã có"); } else { LoaiTin t = new LoaiTin(); t.TenLoai = TenLoai; db.LoaiTin.Add(t); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ModelState.AddModelError("", "Vui lòng nhập tên loại"); } } return(RedirectToAction("Index")); }
public void LoadChiTietTin() { int idTinTuc = Convert.ToInt32(Request.QueryString["id"]); WebPortal.Model.TinTuc tinTuc = GetNews(idTinTuc); WebPortal.Model.LoaiTin loaiTin = GetLoaiTin(tinTuc.IDLoaiTin); WebPortal.LoaiTin lt = new LoaiTin(); List<string> list = new List<string>(); foreach (WebPortal.Model.LoaiTin l in lt.All()) { list.Add(l.TenLoai); } dropDownListLoaiTin.DataSource = list; for (int i = 0; i < list.Count; i++) { if (list[i] == loaiTin.TenLoai) { dropDownListLoaiTin.SelectedIndex = i; } } dropDownListLoaiTin.DataBind(); titleNews.Text = tinTuc.TenTinTuc; ImageUpLoad.ImageUrl = "~/" + tinTuc.HinhAnh; summary.Text = tinTuc.MoTaTinTuc; }
public void ThemLoaiTin(LoaiTin lt) { string sql = "insert into LoaiTin values('" + lt.MaLoaiTin + "',N'" + lt.TenLoaiTin + "','" + lt.MaTheLoai + "')"; db = new DBACCESS(); db.open(); db.ExcuteQuery(sql); db.close(); }
public void SuaLoaiTin(LoaiTin lt) { string sql = "update LoaiTin set TenLoaiTin=N'" + lt.TenLoaiTin + "',MaTheLoai='" + lt.MaTheLoai + "' where MaLoaiTin='" + lt.MaLoaiTin + "'"; db = new DBACCESS(); db.open(); db.ExcuteQuery(sql); db.close(); }
public ActionResult ConfirmOnEditLoaiTin(int id, LoaiTin tin) { if (ModelState.IsValid) { tin = db.LoaiTins.SingleOrDefault(n => n.LoaiTinID == id); UpdateModel(tin); db.SubmitChanges(); } return(RedirectToAction("LoaiTin")); }
public ActionResult ConfirmOnDeleteLoaiTin(int id) { LoaiTin tin = db.LoaiTins.SingleOrDefault(n => n.LoaiTinID == id); if (tin == null) { Response.StatusCode = 404; return(null); } db.LoaiTins.DeleteOnSubmit(tin); db.SubmitChanges(); return(RedirectToAction("LoaiTin")); }
public ActionResult DeleteLoaiTin(int id) { LoaiTin tin = db.LoaiTins.SingleOrDefault(n => n.LoaiTinID == id); if (tin == null) { Response.StatusCode = 404; return(null); } else if (Session["Taikhoanadmin"] == null || Session["Taikhoanadmin"].ToString() == "") { return(RedirectToAction("Login", "Admin")); } else { return(View(tin)); } }
public bool Create(LoaiTin model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_loaitin_create", "@tenloai", model.tenloai, "@mota", model.mota); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
//protected void Save_Click(object sender, EventArgs e) //{ // int idLoaiTin = Convert.ToInt32(Request.QueryString["id"]); // WebPortal.LoaiTin lt = new LoaiTin(); // int idLoaiTin_Lv1 = GetIDLoaiTin1FollowName(ListLoaiTin.SelectedValue); // WebPortal.Model.LoaiTin loaiTin = lt.Single(idLoaiTin); // loaiTin.LoaiTin_Lv1ID = idLoaiTin_Lv1; // loaiTin.MoTa = Summary.Text; // loaiTin.TenLoai = Name.Text; // try // { // lt.Update(loaiTin); // SaveChange.Text = "Cập nhật thành công"; // } // catch (Exception ex) // { // SaveChange.Text = "Quá trình lưu xảy ra lỗi! Vui lòng thử lại"; // } //} public bool UpdateLoaiTinLv2() { int idLoaiTin = Convert.ToInt32(Request.QueryString["id"]); WebPortal.LoaiTin lt = new LoaiTin(); int idLoaiTin_Lv1 = GetIDLoaiTin1FollowName(ListLoaiTin.SelectedValue); WebPortal.Model.LoaiTin loaiTin = lt.Single(idLoaiTin); loaiTin.LoaiTin_Lv1ID = idLoaiTin_Lv1; loaiTin.MoTa = Summary.Text; loaiTin.TenLoai = Name.Text; try { lt.Update(loaiTin); return true; } catch (Exception ex) { return false; } }
//protected void Save_Click(object sender, EventArgs e) //{ // string strLoaiTin1 = ListLoaiTin.SelectedValue; // string tenLoaiTin = Name.Text; // string moTa = Summary.Text; // WebPortal.Model.LoaiTin loaiTin = new Model.LoaiTin(); // loaiTin.TenLoai = tenLoaiTin; // loaiTin.MoTa = moTa; // WebPortal.LoaiTin lt = new LoaiTin(); // loaiTin.LoaiTin_Lv1ID = GetIDLoaiTin1FollowName(strLoaiTin1); // try // { // lt.Add(loaiTin); // SaveChange.Text = "Lưu thành công!"; // } // catch (Exception ex) // { // SaveChange.Text = "Quá trình lưu xảy ra lỗi! Vui lòng thử lại."; // } //} public bool SaveLoaiTinLv2() { string strLoaiTin1 = ListLoaiTin.SelectedValue; string tenLoaiTin = Name.Text; string moTa = Summary.Text; WebPortal.Model.LoaiTin loaiTin = new Model.LoaiTin(); loaiTin.TenLoai = tenLoaiTin; loaiTin.MoTa = moTa; WebPortal.LoaiTin lt = new LoaiTin(); loaiTin.LoaiTin_Lv1ID = GetIDLoaiTin1FollowName(strLoaiTin1); try { lt.Add(loaiTin); return true; } catch (Exception ex) { return false; } }
public List <LoaiTin> AllLoaiTin() { string sql = "select * from LoaiTin"; db = new DBACCESS(); db.open(); DataTable dt = db.getTable(sql); db.close(); List <LoaiTin> ds = new List <LoaiTin>(); foreach (DataRow dr in dt.Rows) { LoaiTin lt = new LoaiTin(); lt.MaLoaiTin = dr[0].ToString(); lt.MaTheLoai = dr[1].ToString(); lt.TenLoaiTin = dr[2].ToString(); ds.Add(lt); } this.DanhSachLoaiTin = ds; return(ds); }
public bool Update(LoaiTin model) { return(_res.Update(model)); }
public LoaiTin UpdateUser([FromBody] LoaiTin model) { _itemGroupBusiness.Update(model); return(model); }
public LoaiTin CreateTintuc([FromBody] LoaiTin model) { _itemGroupBusiness.Create(model); return(model); }
public void SuaLoaiTin(LoaiTin lt) { ltdal.SuaLoaiTin(lt); }
public void ThemLoaiTin(LoaiTin lt) { ltdal.ThemLoaiTin(lt); }
public bool Create(LoaiTin model) { return(_res.Create(model)); }
public WebPortal.Model.LoaiTin GetLoaiTin(int idLoaiTin) { WebPortal.LoaiTin loaiTin = new LoaiTin(); return loaiTin.Single(idLoaiTin); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack != true) { List<WebPortal.Model.LoaiTin> list = new List<Model.LoaiTin>(); WebPortal.LoaiTin loai = new LoaiTin(); list = loai.All(); List<string> listLoai = new List<string>(); for (int i = 0; i < list.Count; i++) { listLoai.Add(list[i].TenLoai); } dropDownListLoaiTin.DataSource = listLoai; dropDownListLoaiTin.DataBind(); } }
public ActionResult CreateLoaiTin(LoaiTin tin) { db.LoaiTins.InsertOnSubmit(tin); db.SubmitChanges(); return(RedirectToAction("LoaiTin")); }
public List<WebPortal.Model.LoaiTin> GetAllLoaiTin() { WebPortal.LoaiTin loaiTin = new LoaiTin(); return loaiTin.All(); }
private int GetIDLoaiTinFollowTenLoai(string tenLoai) { List<WebPortal.Model.LoaiTin> list = new List<Model.LoaiTin>(); WebPortal.LoaiTin loai = new LoaiTin(); list = loai.All(); foreach (WebPortal.Model.LoaiTin l in list) { if (l.TenLoai == tenLoai) return l.IDLoaiTin; } return -1; }
public List<WebPortal.Model.LoaiTin> GetListLoaiTinFollowIdLoaiTin_Lv1(int idLoaiTin_Lv1) { WebPortal.LoaiTin loaiTin = new LoaiTin(); return loaiTin.GetListFollowIDLoaiTin_Lv1(idLoaiTin_Lv1); }