protected override void BindValueToPageControls() { foreach (var doc in DocumentServices.GetList(userId: Sessions.UserID).OrderByDescending(item => item.ReleaseDate)) { VanBan.AddSelectItem($"{doc.DocumentCode} - {doc.ReleaseDate.ToDateString()} - {doc.MainContent}", doc.DocumentID.ToString()); } }
public static void DeleteToDb(this VanBan entity, DbContext context, string userName = null) { entity.IsDeleted = true; if (string.IsNullOrWhiteSpace(userName)) { entity.LastUpdatedBy = userName; } entity.LastUpdated = DateTime.Now; context.Entry(entity).State = EntityState.Modified; }
public ActionResult Edit([Bind(Include = "VanBanId,TenVanBan,Content,ImagePath,CoQuanBanHanh,NgayBanHanh,SoHieu,ApDung,LinhVucId,LoaiVanBanId,SoCongBao,NgayDangCongBao,NguoiKy,NgayHetHieuLuc,TinhTrangHieuLuc,OrderHint,CreatedDate,CreatedBy,UpdatedDate,UpdatedBy,MetaKeyword,MetaDescription,Status")] VanBan vanBan) { if (ModelState.IsValid) { _vanBanService.Update(vanBan); _vanBanService.Save(); return(RedirectToAction("Index")); } ViewBag.LinhVucId = new SelectList(db.LinhVucs, "LinhVucId", "TenLinhVuc", vanBan.LinhVucId); ViewBag.LoaiVanBanId = new SelectList(db.LoaiVanBans, "LoaiVanBanId", "TenLoaiVanBan", vanBan.LoaiVanBanId); return(View(vanBan)); }
public ActionResult Update([FromBody] VanBan c) { try { vanbanRepo.Update(c); return(Json(c)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } return(View(c)); }
// GET: Admin/VanBans/Delete/5 public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VanBan vanBan = _vanBanService.SelectById(id); if (vanBan == null) { return(HttpNotFound()); } return(View(vanBan)); }
public static void UpdateToDb(this VanBan entity, VanBanResult data, DbContext context) { entity.TrichYeu = data.TrichYeu; entity.TenVanBan = data.TenVanBan; entity.SoVanBan = data.SoVanBan; entity.CoQuanBanHanhId = data.CoQuanBanHanhId; entity.LoaiVanBanId = data.LoaiVanBanId; entity.LinhVucVanBanId = data.LinhVucVanBanId; entity.NgayBanHanh = data.NgayBanHanh; entity.IsDeleted = data.IsDeleted; entity.LastUpdatedBy = data.LastUpdatedBy; entity.LastUpdated = DateTime.Now; context.Entry(entity).State = EntityState.Modified; }
// GET: Admin/VanBans/Edit/5 public ActionResult Edit(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VanBan vanBan = _vanBanService.SelectById(id); if (vanBan == null) { return(HttpNotFound()); } ViewBag.LinhVucId = new SelectList(db.LinhVucs, "LinhVucId", "TenLinhVuc", vanBan.LinhVucId); ViewBag.LoaiVanBanId = new SelectList(db.LoaiVanBans, "LoaiVanBanId", "TenLoaiVanBan", vanBan.LoaiVanBanId); return(View(vanBan)); }
public ActionResult Create([FromBody] VanBanInsert c) { try { VanBan vanBan = new VanBan(); vanBan.VbdiDen = c.VbdiDen; vanBan.MaLoaiVb = c.MaLoaiVb; vanBan.MaCqbh = c.MaCqbh; vanBan.DoKhan = c.DoKhan; vanBan.DoMat = c.DoMat; vanBan.SoDen = c.SoDen; vanBan.SoVb = c.SoVb; vanBan.TrichYeu = c.TrichYeu; vanBan.NoiNhan = c.NoiNhan; vanBan.NguoiKy = c.NguoiKy; vanBan.FileDinhKem = c.FileDinhKem; vanBan.KetQuaXuLy = c.KetQuaXuLy; if (!string.IsNullOrEmpty(c.NgayDen)) { vanBan.NgayDen = DateTime.ParseExact(c.NgayDen, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture); } if (!string.IsNullOrEmpty(c.NgayKy)) { vanBan.NgayKy = DateTime.ParseExact(c.NgayKy, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture); } if (!string.IsNullOrEmpty(c.HanXuLy)) { vanBan.HanXuLy = DateTime.ParseExact(c.HanXuLy, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture); } vanbanRepo.Create(vanBan); return(Json(c)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } return(View(c)); }
protected void btn_Save_Click(object sender, EventArgs e) { int ID = 0; int.TryParse(Request.QueryString["ID"], out ID); String SoHieu = textbox_SoHieu.Value.Trim(); String CoQuanBH = textbox_CoQuanBH.Value.Trim(); DateTime NgayBH = input_NgayBanHanh.Value.ToDateTime(); DateTime NgayHL = input_NgayHieuLuc.Value.ToDateTime(); string LinkFile = imageLink.Value; LinkFile = LinkFile.Replace(@"C:\fakepath\", @"\FilesUpload\").Replace(@"\\", @"\"); String MoTa = textarea_Detail.Value; DBEntities db = new DBEntities(); if (SoHieu == String.Empty) { message.Visible = true; message.InnerHtml = "Nhập số hiệu!"; textbox_SoHieu.Focus(); return; } if (CoQuanBH == String.Empty) { message.Visible = true; message.InnerHtml = "Nhập cơ quan ban hành!"; textbox_CoQuanBH.Focus(); return; } if (NgayBH == null) { message.Visible = true; message.InnerHtml = "Nhập ngày ban hành!"; input_NgayBanHanh.Focus(); return; } if (NgayHL == null) { message.Visible = true; message.InnerHtml = "Nhập ngày hiệu lực!"; input_NgayHieuLuc.Focus(); return; } if (LinkFile == String.Empty) { message.Visible = true; message.InnerHtml = "chọn file của văn bản"; return; } if (MoTa == String.Empty) { message.Visible = true; message.InnerHtml = "nhập mô tả của văn bản"; textarea_Detail.Focus(); return; } if (ID == 0) { using (db) { var newItem = new VanBan() { SoHieu = SoHieu, NgayBanHanh = NgayBH, NgayHieuLuc = NgayHL, CoQuanBH = CoQuanBH, link = LinkFile, MoTa = MoTa, NguoiDungID = Session["ID"].ToInt() }; try { db.VanBans.Add(newItem); db.SaveChanges(); LoadData(); message.InnerHtml = "Lưu Tin Mới Thành Công"; message.Visible = true; Reset(); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Có lỗi')", true); return; } } return; } var query = (from d in db.VanBans where d.VanBanID == ID select d).FirstOrDefault(); query.SoHieu = SoHieu; query.CoQuanBH = CoQuanBH; query.NgayBanHanh = NgayBH; query.NgayHieuLuc = NgayHL; query.link = LinkFile; query.MoTa = MoTa; try { db.SaveChanges(); Response.Redirect("/admin/DanhMucVanBanPhapLuat.aspx"); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Có lỗi!')", true); return; } }
public void Update(VanBan vanBan) { _vanBanRepository.Update(vanBan); }
public VanBan Insert(VanBan vanBan) { return(_vanBanRepository.Add(vanBan)); }