// POST: Admin/GioiThieu/Delete/5 public JsonResult Delete(int id) { GioiThieu gioiThieu = db.GioiThieux.Find(id); db.GioiThieux.Remove(gioiThieu); return(Json(db.SaveChanges())); }
public ActionResult Create([Bind(Include = "Id,Ten,NoiDung,NgayTao,NguoiSuDung,KhachHang,NguoiDiCho")] GioiThieu gioiThieu) { if (ModelState.IsValid) { try { db.GioiThieu.Add(gioiThieu); db.SaveChanges(); List <int> khachhangId = db.KhachHang.Where(m => m.RegistrationId != null).Select(m => m.Id).ToList(); List <int> nguoidichoId = db.KhachHang.Where(m => m.NguoiDiCho == true).Select(m => m.Id).ToList(); if (gioiThieu.KhachHang == true) { for (int i = 0; i < khachhangId.Count(); i++) { Common.SendNotification.SendNotifications(gioiThieu.NoiDung, gioiThieu.Ten, khachhangId[i]); } } if (gioiThieu.NguoiDiCho == true) { for (int i = 0; i < nguoidichoId.Count(); i++) { Common.SendNotification.SendNotifications(gioiThieu.NoiDung, gioiThieu.Ten, nguoidichoId[i]); } } } catch (Exception ex) { string str = ex.Message; } } return(RedirectToAction("Index")); }
public ActionResult Edit(GioiThieu gt) { var gioithieu = db.GioiThieux.Find(gt.MaGioiThieu); gioithieu = gt; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { GioiThieu gioiThieu = db.GioiThieu.Find(id); db.GioiThieu.Remove(gioiThieu); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ChiTietGioiThieu(int?id) { GioiThieu gt = db.GioiThieux.SingleOrDefault(n => n.MaGioiThieu == id); if (gt == null) { return(HttpNotFound()); } return(View(gt)); }
public ActionResult Edit([Bind(Include = "Id,Ten,NoiDung,NgayTao,NguoiSuDung,KhachHang,NguoiDiCho")] GioiThieu gioiThieu) { if (ModelState.IsValid) { db.Entry(gioiThieu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gioiThieu)); }
public HttpResponseMessage Create(HttpRequestMessage request, CoSoThuY coSoThuY) { CoSoThuY modelCoSoThuY = null; try { var tenTaiKhoan1 = coSoThuY.TenCoSoThuY.ToLower(); var tenTaiKhoan2 = _coSoThuYService.ThayDoiChuoi(tenTaiKhoan1); var tenTaiKhoan3 = tenTaiKhoan2.Replace(" ", ""); var pass = coSoThuY.SDT.Substring(6); var taikhoan = new TaiKhoan { UserName = tenTaiKhoan3, Pass = pass, IdQuyen = 2, TrangThai = true, }; var taiKhoan = _taiKhoanService.Add(taikhoan); _coSoThuYService.SaveChange(); if (taiKhoan.IdTaiKhoan != 0) { coSoThuY.IdTaiKhoan = taikhoan.IdTaiKhoan; modelCoSoThuY = _coSoThuYService.Add(coSoThuY); _coSoThuYService.SaveChange(); if (modelCoSoThuY != null) { Message = "Tạo mới người dùng và tài khoản thành công thành công"; _taiKhoanService.SaveChange(); } } if (modelCoSoThuY != null) { var gioiThieu = new GioiThieu() { IdCoSoThuY = modelCoSoThuY.IdCoSoThuY, NoiDung = "Phần giới thiệu của cơ sở thú y ở đây", }; _gioiThieuService.Add(gioiThieu); _coSoThuYService.SaveChange(); Message = "Tạo mới cơ sở thú y thành công"; } else { throw new DbEntityValidationException("tạo mới cơ sở thú y không thành công"); } } catch (DbEntityValidationException ex) { LogException(ex); } return(GetResponseMessage(IsSuccess, Message, 1, modelCoSoThuY)); }
private void BtnGioiThieu_Click(object sender, EventArgs e) { if (KiemTraTenTabConTrol("&Giới Thiệu") == false) { SuperTabItem Tab = superTabControl1.CreateTab("&Giới Thiệu"); GioiThieu frm = new GioiThieu(); frm.Dock = DockStyle.Fill; Tab.AttachedControl.Controls.Add(frm); frm.Show(); superTabControl1.SelectedTabIndex = superTabControl1.Tabs.Count - 1; } }
public ActionResult Edit(int?id) { GioiThieu gioiThieu = new GioiThieu(); if (id.HasValue) { gioiThieu = db.GioiThieux.Find(id); } if (gioiThieu == null) { return(HttpNotFound()); } return(View(gioiThieu)); }
}//End Index Actions // GET: /GioiThieu/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GioiThieu gioiThieu = db.GioiThieu.Find(id); if (gioiThieu == null) { return(HttpNotFound()); } return(View(gioiThieu)); }
public ActionResult Edit(GioiThieu gioiThieu) { gioiThieu.SaveFor(q => q.HinhAnh); gioiThieu.SaveFor(q => q.HinhAnh2); gioiThieu.SaveFor(q => q.HinhAnh3); if (gioiThieu.IDGioiThieu > 0) { db.Entry(gioiThieu).State = EntityState.Modified; } else { db.GioiThieux.Add(gioiThieu); } db.SaveChanges(); return(RedirectToAction("Index")); }
public bool Edit(GioiThieu entity) { try { var user = db.GioiThieus.Find(1); user.Name = entity.Name; user.Conten = entity.Conten; db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public ActionResult XoaGT(int id) { if (id == null) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } GioiThieu model = db.GioiThieux.SingleOrDefault(n => n.MaGioiThieu == id); if (model == null) { return(HttpNotFound()); } db.GioiThieux.Remove(model); db.SaveChanges(); return(RedirectToAction("QuanLyGT")); }
private void button9_Click(object sender, EventArgs e) { GioiThieu hh = new GioiThieu() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true }; hh.FormBorderStyle = FormBorderStyle.None; this.panelControl.Controls.Add(hh); foreach (Control ctrl in panelControl.Controls) { if (ctrl != hh) { ctrl.Dispose(); } } hh.Show(); }
public ActionResult XoaGT(int?id) { //lấy sản phẩm theo id ra để chỉnh sửa if (id == null) { Response.StatusCode = 404; return(null); } GioiThieu gt = db.GioiThieux.SingleOrDefault(n => n.MaGioiThieu == id); if (gt == null) { return(HttpNotFound()); } ViewBag.MaLoaiGT = new SelectList(db.LoaiGioiThieux.OrderBy(n => n.MaLoaiGT), "MaLoaiGT", "TenLoaiGT", gt.MaLoaiGT); return(View(gt)); }
public ActionResult ChinhSuaGT(GioiThieu model, HttpPostedFileBase[] HinhAnh) { if (HinhAnh[0].ContentLength > 0) { // lấy hình ảnh var fileName = Path.GetFileName(HinhAnh[0].FileName); // lấy ảnh chuyển vào thư mục hình ảnh var path = Path.Combine(Server.MapPath("~/Content/images"), fileName); // lưu hình HinhAnh[0].SaveAs(path); model.HinhAnh = fileName; } ViewBag.MaLoaiGT = new SelectList(db.LoaiGioiThieux.OrderBy(n => n.MaLoaiGT), "MaLoaiGT", "TenLoaiGT", model.MaLoaiGT); db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("QuanLyGT")); }
public ActionResult Edit(GioiThieu model) { if (ModelState.IsValid) { var dao = new LienHeDAO(); var result = dao.Edit(model); if (result) { SetAlert("Sửa giới thiệu thành công", "success"); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Cập nhật giới thiệu không thành công"); } } return(View()); }
public HttpResponseMessage GetById(HttpRequestMessage request, int id) { GioiThieu gioiThieuSinger = null; try { gioiThieuSinger = _gioiThieuService.GetById(id); if (gioiThieuSinger != null) { Message = "Thông tin gioi thieu với id: " + id; } else { throw new DbEntityValidationException(string.Format("Không tìm kiếm được gioi thieu với id {0}", id)); } } catch (DbEntityValidationException ex) { LogException(ex); } return(GetResponseMessage(IsSuccess, Message, 1, gioiThieuSinger)); }
private void BtDangNhap_Click(object sender, EventArgs e) { string name = TbName.Text; string pas = TbPass.Text; if (name.Length == 0) { MessageBox.Show("Bạn Chưa điền tên tài khoản", "thông báo"); } User user1 = db.Users.SingleOrDefault(x => x.TenTk == name && x.MatKhau == pas); if (user1 != null) { GioiThieu gt = new GioiThieu(); this.Hide(); gt.ShowDialog(); this.Close(); } else { MessageBox.Show("Tài khoản hoặc mật khẩu không chính xác!", "thông báo"); } }
public ActionResult ThemGT(GioiThieu gt, HttpPostedFileBase HinhAnh) { ViewBag.MaLoaiGT = new SelectList(db.LoaiGioiThieux.OrderBy(n => n.MaLoaiGT), "MaLoaiGT", "TenLoaiGT"); // kiểm tra hình ảnh đã có trong csdl chưa if (HinhAnh.ContentLength > 0) { // lấy hình ảnh var fileName = Path.GetFileName(HinhAnh.FileName); // lấy ảnh chuyển vào thư mục hình ảnh var path = Path.Combine(Server.MapPath("~/Content/images"), fileName); // kiểm tra coi tồn tại hay chưa // lưu hình HinhAnh.SaveAs(path); gt.HinhAnh = fileName; } db.GioiThieux.Add(gt); db.SaveChanges(); return(RedirectToAction("QuanLyGT")); }
public HttpResponseMessage Update(HttpRequestMessage request, GioiThieu gioiThieu) { GioiThieu gioiThieuSinger = null; try { _gioiThieuService.Update(gioiThieu); _gioiThieuService.SaveChange(); gioiThieuSinger = _gioiThieuService.GetById(gioiThieu.IdGioiThieu); if (gioiThieuSinger != null) { Message = "Sửa thông tin gioi thieu thành công"; } else { throw new DbEntityValidationException("sửa thông tin gioi thieu không thành công"); } } catch (DbEntityValidationException ex) { LogException(ex); } return(GetResponseMessage(IsSuccess, Message, 1, gioiThieuSinger)); }
public ActionResult Add(GioiThieu gt) { db.GioiThieux.Add(gt); db.SaveChanges(); return(RedirectToAction("Index")); }
public void hotro() { GioiThieu fr = new GioiThieu(); fr.ShowDialog(); }
public void Update(GioiThieu gioiThieu) { _gioiThieuRepository.Update(gioiThieu); }
public GioiThieu Add(GioiThieu gioiThieu) { return(_gioiThieuRepository.Add(gioiThieu)); }