コード例 #1
0
 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;
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
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 = "";
                }
            }
        }
コード例 #4
0
 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"));
 }
コード例 #5
0
        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;
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
 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"));
 }
コード例 #9
0
        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"));
        }
コード例 #10
0
        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));
            }
        }
コード例 #11
0
        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;
            }
        }
コード例 #12
0
        //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;
            }
        }
コード例 #13
0
        //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;
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
 public bool Update(LoaiTin model)
 {
     return(_res.Update(model));
 }
コード例 #16
0
 public LoaiTin UpdateUser([FromBody] LoaiTin model)
 {
     _itemGroupBusiness.Update(model);
     return(model);
 }
コード例 #17
0
 public LoaiTin CreateTintuc([FromBody] LoaiTin model)
 {
     _itemGroupBusiness.Create(model);
     return(model);
 }
コード例 #18
0
 public void SuaLoaiTin(LoaiTin lt)
 {
     ltdal.SuaLoaiTin(lt);
 }
コード例 #19
0
 public void ThemLoaiTin(LoaiTin lt)
 {
     ltdal.ThemLoaiTin(lt);
 }
コード例 #20
0
 public bool Create(LoaiTin model)
 {
     return(_res.Create(model));
 }
コード例 #21
0
 public WebPortal.Model.LoaiTin GetLoaiTin(int idLoaiTin)
 {
     WebPortal.LoaiTin loaiTin = new LoaiTin();
     return loaiTin.Single(idLoaiTin);
 }
コード例 #22
0
        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();
            }
        }
コード例 #23
0
 public ActionResult CreateLoaiTin(LoaiTin tin)
 {
     db.LoaiTins.InsertOnSubmit(tin);
     db.SubmitChanges();
     return(RedirectToAction("LoaiTin"));
 }
コード例 #24
0
 public List<WebPortal.Model.LoaiTin> GetAllLoaiTin()
 {
     WebPortal.LoaiTin loaiTin = new LoaiTin();
     return loaiTin.All();
 }
コード例 #25
0
 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;
 }
コード例 #26
0
 public List<WebPortal.Model.LoaiTin> GetListLoaiTinFollowIdLoaiTin_Lv1(int idLoaiTin_Lv1)
 {
     WebPortal.LoaiTin loaiTin = new LoaiTin();
     return loaiTin.GetListFollowIDLoaiTin_Lv1(idLoaiTin_Lv1);
 }