private void btnHuyAllDiemDanh_Click(object sender, EventArgs e) { if (lueBuoiHoc.EditValue == null) { Thongbao.Canhbao("Bạn chưa chọn buổi học."); return; } int id_Buoihoc = (int)lueBuoiHoc.EditValue; DialogResult f = Thongbao._CauHoi("Có chắc chắn hủy kết quả điểm danh buổi này !"); if (f == System.Windows.Forms.DialogResult.Yes) { var deletes = (from a in db.DiemDanhs where a.IDBuoiHoc == id_Buoihoc select a); foreach (var i in deletes) { db.DiemDanhs.DeleteOnSubmit(i); } try { db.SubmitChanges(); Thongbao.ThanhCong("Hủy thành công !"); } catch (Exception ex) { HeThong.Thongbao.Canhbao(ex.ToString()); } Reload(); } }
public ActionResult Edit(MSlider mSlider) { if (ModelState.IsValid) { String strSlug = XString.ToAscii(mSlider.Name); mSlider.Updated_at = DateTime.Now; mSlider.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mSlider.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Library/images/Slider/"), filename); file.SaveAs(Strpath); } db.Entry(mSlider).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Cập nhập thông tin slider thành công!", "success"); return(RedirectToAction("Index")); } return(View(mSlider)); }
public ActionResult Edit(MPost mPost) { if (ModelState.IsValid) { String strSlug = XString.ToAscii(mPost.Title); mPost.Slug = strSlug; mPost.Type = "page"; mPost.Updated_at = DateTime.Now; mPost.Updated_by = int.Parse(Session["Admin_ID"].ToString()); var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mPost.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Library/images/page/"), filename); file.SaveAs(Strpath); } db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã cập nhật lại nội dung trang đơn!", "success"); return(RedirectToAction("Index")); } return(View(mPost)); }
public ActionResult Create([Bind(Include = "id,tieude,vanban,img,meta,gioithieu,ngay,hide")] Thongbao thongbao, HttpPostedFileBase img) { var path = ""; var filename = ""; if (ModelState.IsValid) { if (img != null) { //filename = Guid.NewGuid().ToString() + img.FileName; filename = DateTime.Now.ToString("dd-MM-yy-hh-mm-ss-") + img.FileName; path = Path.Combine(Server.MapPath("~/Content/upload/img/thongbao"), filename); img.SaveAs(path); thongbao.img = filename; //Lưu ý } // temp.datebegin = Convert.ToDateTime(DateTime.Now.ToShortDateString()); else { thongbao.img = "tdt.png"; } thongbao.ngay = DateTime.Now; thongbao.meta = Functions.ConvertToUnSign(thongbao.meta); //convert Tiếng Việt không dấu db.Thongbao.Add(thongbao); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thongbao)); }
public ActionResult DelTrash(int id) { MCategory MCategory = db.Category.Find(id); if (MCategory == null) { Thongbao.set_flash("Không tồn tại danh mục cần xóa vĩnh viễn!", "warning"); return(RedirectToAction("Index")); } int count_child = db.Category.Where(m => m.ParentID == id).Count(); if (count_child != 0) { Thongbao.set_flash("Không thể xóa, danh mục có chứa danh mục con!", "warning"); return(RedirectToAction("Index")); } MCategory.Status = 0; MCategory.Created_at = DateTime.Now; MCategory.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; MCategory.Updated_at = DateTime.Now; MCategory.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Entry(MCategory).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Ném thành công vào thùng rác!" + " ID = " + id, "success"); return(RedirectToAction("Index")); }
public ActionResult Create(MCategory MCategory) { ViewBag.listCat = new SelectList(db.Category.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Category.Where(m => m.Status == 1), "Orders", "Name", 0); if (ModelState.IsValid) { if (MCategory.ParentID == null) { MCategory.ParentID = 0; } String Slug = XString.ToAscii(MCategory.Name); CheckSlug check = new CheckSlug(); if (!check.KiemTraSlug("Category", Slug, null)) { Thongbao.set_flash("Tên danh mục đã tồn tại, vui lòng thử lại!", "warning"); return(RedirectToAction("Create", "Category")); } MCategory.Slug = Slug; MCategory.Created_at = DateTime.Now; MCategory.Created_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; MCategory.Updated_at = DateTime.Now; MCategory.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Category.Add(MCategory); db.SaveChanges(); Thongbao.set_flash("Danh mục đã được thêm!", "success"); return(RedirectToAction("Index", "Category")); } Thongbao.set_flash("Có lỗi xảy ra khi thêm danh mục!", "warning"); return(View(MCategory)); }
private void btnHuyDiemDanh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gvMain.GetFocusedRowCellValue("ID") == null) { Thongbao.Hoi("Mời bạn chọn hàng cần hủy điểm danh."); } else { int id_tmp = (int)gvMain.GetFocusedRowCellValue("ID"); DialogResult f = Thongbao._CauHoi("Có chắc chắn hủy điểm danh sinh viên"); if (f == System.Windows.Forms.DialogResult.Yes) { var delete = (from a in db.DiemDanhs where a.ID == (int)id_tmp select a).Single(); delete.DenLop = false; try { db.SubmitChanges(); } catch (Exception ex) { HeThong.Thongbao.Canhbao(ex.ToString()); } Reload(); } } }
public ActionResult Edit(MPost mPost) { MTopic mTopic = new MTopic(); ViewBag.ListTopic = new SelectList(db.Topic.ToList(), "ID", "Name", 0); if (ModelState.IsValid) { String strSlug = XString.ToAscii(mPost.Title); mPost.Slug = strSlug; mPost.Type = "post"; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mPost.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/post/"), filename); file.SaveAs(Strpath); } db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã cập nhật lại bài viết!", "success"); return(RedirectToAction("Index")); } return(View(mPost)); }
public IEnumerable <Thongbao> GetThongbao() { List <Thongbao> ThongbaoData = new List <Thongbao>(); string conString = ConfigurationManager.ConnectionStrings["getConnection"].ToString(); conn = new SqlConnection(conString); SqlCommand cmd = new SqlCommand("spThongbao", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Thongbao thongbao = new Thongbao(); thongbao.Id_thongbao = Convert.ToInt32(reader["ID_Thongbao"]); thongbao.Tieude = reader["Tieude"].ToString(); thongbao.Noidung = reader["Noidung"].ToString(); thongbao.Time = reader.GetFieldValue <DateTime>(reader.GetOrdinal("getDate")); ThongbaoData.Add(thongbao); } conn.Close(); return(ThongbaoData); }
public ActionResult Create(MProduct mProduct) { ViewBag.ListCat = new SelectList(db.Category.Where(m => m.Status != 0), "ID", "Name", 0); if (ModelState.IsValid) { mProduct.Price = mProduct.Price; mProduct.ProPrice = mProduct.ProPrice; String strSlug = XString.ToAscii(mProduct.Name); mProduct.Slug = strSlug; mProduct.Created_at = DateTime.Now; mProduct.Created_by = 1; mProduct.Updated_at = DateTime.Now; mProduct.Updated_by = 1; // Upload file var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mProduct.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/product/"), filename); file.SaveAs(Strpath); } db.Product.Add(mProduct); db.SaveChanges(); Thongbao.set_flash("Thêm mới sản phẩm thành công!", "success"); return(RedirectToAction("Index")); } return(View(mProduct)); }
public JsonResult Payment(String Address, String FullName, String Phone, String Email) { var order = new MOrder(); int user_id = Convert.ToInt32(Session["User_ID"]); order.Code = DateTime.Now.ToString("yyyyMMddhhMMss"); // yyyy-MM-dd hh:MM:ss order.UserID = user_id; order.CreateDate = DateTime.Now; order.DeliveryAddress = Address; order.DeliveryEmail = Email; order.DeliveryPhone = Phone; order.DeliveryName = FullName; order.Status = 1; db.Order.Add(order); db.SaveChanges(); var OrderID = order.ID; foreach (var c in (List <ModelCart>)Session["Cart"]) { var orderdetails = new MOrderDetail(); orderdetails.OrderID = OrderID; orderdetails.ProductID = c.ProductID; orderdetails.Price = c.Price; orderdetails.Quantity = c.Quantity; orderdetails.Amount = c.Price * c.Quantity; db.OrderDetail.Add(orderdetails); } db.SaveChanges(); Session.Remove("Cart"); Thongbao.set_flash("Bạn đã đặt hàng thành công!", "success"); return(Json(true)); }
private bool kiemtra() { if (String.IsNullOrEmpty(txtTenHang.Text)) { Thongbao.Canhbao("Bạn chưa nhập tên hàng. xin mời nhập !"); return(true); } if (lueLoaiHang.EditValue == null) { Thongbao.Canhbao("Bạn chưa chọn loại hàng. xin mời nhập !"); return(true); } if (String.IsNullOrEmpty(txt1.Text)) { Thongbao.Canhbao("Bạn chưa nhập ghi chú. xin mời nhập !"); return(true); } if (String.IsNullOrEmpty(txt2.Text)) { Thongbao.Canhbao("Bạn chưa nhập ghi chú. xin mời nhập !"); return(true); } if (String.IsNullOrEmpty(txt3.Text)) { Thongbao.Canhbao("Bạn chưa nhập ghi chú. xin mời nhập !"); return(true); } if (String.IsNullOrEmpty(txt4.Text)) { Thongbao.Canhbao("Bạn chưa nhập ghi chú. xin mời nhập !"); return(true); } return(false); }
public ActionResult Edit(MProduct mProduct) { ViewBag.ListCat = new SelectList(db.Category.ToList(), "ID", "Name", 0); if (ModelState.IsValid) { String strSlug = XString.ToAscii(mProduct.Name); mProduct.Slug = strSlug; mProduct.Updated_at = DateTime.Now; mProduct.Updated_by = 1; // Upload file var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mProduct.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/product/"), filename); file.SaveAs(Strpath); } db.Entry(mProduct).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã cập nhật lại thông tin sản phẩm!", "success"); return(RedirectToAction("Index")); } return(View(mProduct)); }
public ActionResult Create(MPost mPost) { if (ModelState.IsValid) { String strSlug = XString.ToAscii(mPost.Title); mPost.Slug = strSlug; mPost.Type = "post"; mPost.Created_at = DateTime.Now; mPost.Created_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mPost.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/post/"), filename); file.SaveAs(Strpath); } db.Post.Add(mPost); db.SaveChanges(); Thongbao.set_flash("Đã thêm bài viết mới!", "success"); return(RedirectToAction("Index")); } return(View(mPost)); }
public ActionResult DeleteConfirmed(int id) { Thongbao thongbao = db.Thongbao.Find(id); db.Thongbao.Remove(thongbao); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { MTopic mTopic = db.Topic.Find(id); db.Topic.Remove(mTopic); db.SaveChanges(); Thongbao.set_flash("Đã xóa hoàn toàn chủ đề!", "success"); return(RedirectToAction("Trash", "Topic")); }
private bool checkvali_null() { if (String.IsNullOrEmpty(txtTenLoai.Text)) { Thongbao.Canhbao("Bạn chưa nhập tên loại hàng. xin mời nhập !"); return(true); } return(false); }
public ActionResult DeleteConfirmed(int id) { MOrder mOrder = db.Order.Find(id); db.Order.Remove(mOrder); db.SaveChanges(); Thongbao.set_flash("Đã xóa đơn hàng!", "success"); return(RedirectToAction("Trash")); }
public ActionResult DeleteConfirmed(int id) { MContact mContact = db.Contact.Find(id); db.Contact.Remove(mContact); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn liên hệ!", "danger"); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { MPost mPost = db.Post.Find(id); db.Post.Remove(mPost); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn", "danger"); return(RedirectToAction("Trash")); }
public ActionResult DeleteConfirmed(int id) { MMenu mMenu = db.Menu.Find(id); db.Menu.Remove(mMenu); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn menu!", "success"); return(RedirectToAction("Trash")); }
public ActionResult DeleteConfirmed(int id) { MCategory MCategory = db.Category.Find(id); db.Category.Remove(MCategory); db.SaveChanges(); Thongbao.set_flash("Đã xóa hoàn toàn danh mục!", "success"); return(RedirectToAction("Trash", "Category")); }
public ActionResult DeleteConfirmed(int id) { MSlider mSlider = db.Slider.Find(id); db.Slider.Remove(mSlider); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn slider!", "success"); return(RedirectToAction("Trash")); }
public ActionResult Edit(int?id) { ViewBag.ListCat = new SelectList(db.Category.ToList(), "ID", "Name", 0); MProduct mProduct = db.Product.Find(id); if (mProduct == null) { Thongbao.set_flash("404!", "warning"); return(RedirectToAction("Index", "Product")); } return(View(mProduct)); }
public int Edit(Thongbao tb) { try { db.Entry(tb).State = EntityState.Modified; db.SaveChanges(); return(1); } catch { throw; } }
public Thongbao ct(int id) { Thongbao tb = db.Thongbao.Find(id); try { return(tb); } catch { throw; } }
public ActionResult DelTrash(int?id) { MPost mPost = db.Post.Find(id); mPost.Status = 0; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã chuyển vào thùng rác!" + " ID = " + id, "success"); return(RedirectToAction("Index")); }
public ActionResult Undo(int?id) { MPost mPost = db.Post.Find(id); mPost.Status = 2; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Khôi phục thành công!" + " ID = " + id, "success"); return(RedirectToAction("Trash")); }
public ActionResult Edit(int?id) { ViewBag.listCat = new SelectList(db.Category.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Category.Where(m => m.Status == 1), "Orders", "Name", 0); MCategory MCategory = db.Category.Find(id); if (MCategory == null) { Thongbao.set_flash("404!", "warning"); return(RedirectToAction("Index", "Category")); } return(View(MCategory)); }
public ActionResult Edit(int?id) { ViewBag.listTopic = new SelectList(db.Topic.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Topic.Where(m => m.Status == 1), "Orders", "Name", 0); MTopic mTopic = db.Topic.Find(id); if (mTopic == null) { Thongbao.set_flash("404!", "warning"); return(RedirectToAction("Index", "Topic")); } return(View(mTopic)); }