/// <summary>
 /// update a info object already stored in the database
 /// </summary>
 /// <param name="info"></param>
 public void UpdateAdminTinTuc(AdminTinTucInfo info)
 {
     DataProvider.Instance().UpdateAdminTinTuc(info.ID, info.LoaiTinID, info.TieuDe, info.TomTat, info.NoiDung, info.TacGia, info.NguoiTao, info.Anh, info.NgayTao, info.LuotXem, info.NguonTin, info.NoiBat, info.Lang, info.TinhTrang);
 }
        /// <summary>
        /// update a info object already stored in the database
        /// </summary>
        /// <param name="info"></param>
        public void UpdateAdminTinTuc(AdminTinTucInfo info)
        {

            DataProvider.Instance().UpdateAdminTinTuc(info.ID,info.LoaiTinID, info.TieuDe, info.TomTat, info.NoiDung, info.TacGia, info.NguoiTao, info.Anh, info.NgayTao, info.LuotXem, info.NguonTin, info.NoiBat, info.Lang, info.TinhTrang);
        }
Beispiel #3
0
        protected void lbtnGhiLai_Click(object sender, EventArgs e)
        {
            AdminTinTucController control = new AdminTinTucController();
            // UPDATE
            if (Request["action"] != null)
            {
                AdminTinTucInfo cv = control.GetAdminTinTuc(int.Parse(Request["action"]));

                cv.TieuDe = tbxTieuDe.Text;
                cv.LoaiTinID = Convert.ToInt32(ddlLoaiTin.SelectedValue);
                cv.TomTat = txtTomTat.Value;
                cv.NoiDung = txtNoiDung.Value;
                cv.TacGia = tbxtacgia.Text;
                cv.NguoiTao = tbxNguoiTao.Text;
                //Upload ảnh
                string urlImage = string.Empty;
                if (Common.CheckContainImage(fulAnh))
                {
                    if (Common.UploadImage(fulAnh, Server.MapPath("~/"), Constants.IMAGE_TINTUC, ref urlImage))
                    {
                        cv.Anh = urlImage;
                    }
                }
                cv.NgayTao = DateTime.Now;
                cv.NguonTin = (ddlNguonTin.SelectedValue);
                cv.NoiBat = cbNoiBat.Checked;
                cv.Lang = ddlNgonNgu.SelectedValue;
                cv.TinhTrang = cbxTinhTrang.Checked;

                try
                {
                    control.UpdateAdminTinTuc(cv);
                    this.lblThongBao.Text = "Ghi lại thành công";
                }
                catch (Exception ex)
                {
                    this.lblThongBao.Text = "Có lỗi: " + ex.ToString();
                }
            }
            else // INSERT
            {
                AdminTinTucInfo cv = new AdminTinTucInfo();

                cv.TieuDe = tbxTieuDe.Text;
                cv.LoaiTinID = Convert.ToInt32(ddlLoaiTin.SelectedValue);
                cv.TomTat = txtTomTat.Value;
                cv.NoiDung = txtNoiDung.Value;
                cv.TacGia = tbxtacgia.Text;
                cv.NguoiTao = tbxNguoiTao.Text;
                //Upload ảnh
                string urlImage = string.Empty;
                if (Common.CheckContainImage(fulAnh))
                {
                    if (Common.UploadImage(fulAnh, Server.MapPath("~/"), Constants.IMAGE_TINTUC, ref urlImage))
                    {
                        cv.Anh = urlImage;
                    }
                }
                cv.NgayTao = DateTime.Now;
                cv.NguonTin = (ddlNguonTin.SelectedValue);
                cv.NoiBat = cbNoiBat.Checked;
                cv.Lang = ddlNgonNgu.SelectedValue;
                cv.TinhTrang = cbxTinhTrang.Checked;
                try
                {
                    control.AddAdminTinTuc(cv);
                    this.lblThongBao.Text = "Ghi lại thành công";
                }
                catch (Exception ex)
                {
                    this.lblThongBao.Text = "Có lỗi: " + ex.ToString();
                }
            }

        }