public ActionResult Edit(DichVuModel model) { if (!ModelState.IsValid) { TempData["Message"] = "Có lỗi xảy ra! Vui lòng kiểm tra lại thông tin."; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(View("Edit", model)); } var item = db.DICHVUs.Where(c => c.ID == model.ID).FirstOrDefault(); if (item == null) { TempData["Message"] = "Có lỗi xảy ra"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("List")); } //map from model to database object //item = Mapper.Map(model, item); //db.SaveChanges(); //have to use stored proc instead of 2 beautiful short lines var id = 0; db.Database.ExecuteSqlCommand("exec SP_CreateOrUpdate_DICHVU @Type, @ID, @Ten, @DonGia, @Ma, @UpdateID", new SqlParameter("@Type", int.Parse("1")), new SqlParameter("@ID", id), new SqlParameter("@Ten", model.Ten), new SqlParameter("@DonGia", model.DonGia), new SqlParameter("@Ma", model.Ma), new SqlParameter("@UpdateID", model.ID)); db.SaveChanges(); _lichSuServices.LuuLichSu((int)Session["ID"], (int)EnumLoaiHanhDong.SUA, item.GetType().ToString()); TempData["Message"] = "Cập nhật thành công"; TempData["NotiType"] = "success"; //success là class trong bootstrap return(RedirectToAction("List")); }
public JsonResult ThemDichVu(DichVu std) { std.NgayTao = DateTime.Now; DichVu dv = new DichVu(); string a = new DichVuModel().ThemDichVu(std); return(Json(new { Message = std, JsonRequestBehavior.AllowGet })); }
public ActionResult XemDichVu() { List <DichVu> listdv = new DichVuModel().GetDataByTrangThai(1); ViewBag.listdv = listdv; return(View(listdv)); }
public JsonResult Save(DichVuModel model) { CultureInfo provider = CultureInfo.InvariantCulture; var newDate = DateTime.ParseExact("01/01/2018 " + model.strTGXL + ":00", "dd/MM/yyyy HH:mm:ss", provider); model.TGXL = newDate; model.GiaBan = model.GiaMua; var rs = BLLDichVu.Instance.InsertOrUpdate(App_Global.AppGlobal.Connectionstring, model); return(Json(rs)); }
public ResponseModel InsertOrUpdate(string connectString, DichVuModel model) { var result = new ResponseModel(); result.IsSuccess = true; using (var db = new HMSEntities(connectString)) { if (!CheckExists(model, db)) { H_DichVu DichVu = null; if (model.Id == 0) { DichVu = new H_DichVu() { WorkId = model.CVId, WorkTypeId = model.LoaiCVId, TimeProcess = model.TGXL, Price_Out = model.GiaBan, Price_In = model.GiaMua, Note = model.Note }; db.H_DichVu.Add(DichVu); } else { var found = db.H_DichVu.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id); if (found != null) { found.WorkId = model.CVId; found.WorkTypeId = model.LoaiCVId; found.TimeProcess = model.TGXL; found.Price_In = model.GiaMua; found.Price_Out = model.GiaBan; found.Note = model.Note; } else { result.IsSuccess = false; result.sms = "Công việc đã bị xóa hoặc không tồn tại trong hệ thống.!"; } } if (result.IsSuccess) { db.SaveChanges(); } } else { result.IsSuccess = false; result.sms = "Mã này đã tồn tại trong hệ thống. Vui lòng chọn lại mã khác."; } return(result); } }
public JsonResult UpdateTrangThaiDichVu(string MaDV, string TrangThaiDichVu) { if (MaDV != null && TrangThaiDichVu != null) { string a = new DichVuModel().CapNhatDichVu(MaDV, Convert.ToInt32(TrangThaiDichVu), DateTime.Now); } return(Json(new { status = true })); }
public ActionResult ThemDichVu(string MaDV) { if (MaDV != null) { DichVuModel dichVuModel = new DichVuModel(); DichVu dichVu = dichVuModel.GetDichVuByMa(Convert.ToInt32(MaDV)); return(Json(dichVu, JsonRequestBehavior.AllowGet)); } var Message = "Thêm dịch vụ thất bại"; return(Json(Message, JsonRequestBehavior.AllowGet)); }
public ActionResult ThemChiTietDichVu(string MaDV) { if (CheckQuyen() == 1) { DichVu dv = new DichVuModel().GetDichVuByMa(Convert.ToInt32(MaDV)); ViewBag.DichVu = dv; return(View()); } else { return(Redirect("/NhanVien/DangNhap")); } }
//Dich Vu public ActionResult DichVu(int page = 1, int pagesize = 9) { if (CheckQuyen() == 1) { List <DichVu> lsdv = new DichVuModel().GetDataByTrangThai(2);//get all return(View(lsdv.ToPagedList(page, pagesize))); } else { return(Redirect("/NhanVien/DangNhap")); } }
public DichVuModel UpdateDV([FromBody] DichVuModel model) { if (model.image != null) { var arrData = model.image.Split(';'); if (arrData.Length == 3) { var savePath = $@"assets/Upload/DichVu/{arrData[0]}"; var savePathh = $@"assets/Upload/DichVu/{arrData[0]}"; model.image = $"{savePath}"; SaveFileFromBase64String(savePath, arrData[2]); SaveFileFromBase64(savePathh, arrData[2]); } } dichvu.Update(model); return(model); }
public ActionResult ChiTiet(int Id) { DichVu dv = db.DichVus.Find(Id); if (dv != null) { DichVuModel model = new DichVuModel(); model.Id = dv.Id; model.TenDichVu = dv.TenDichVu; model.MaLoaiDV = dv.MaLoaiDV; model.Gia = dv.Gia; model.MoTa = dv.MoTa; return(View(model)); } return(RedirectToAction("Index")); }
public DichVuModel Createdichvu([FromBody] DichVuModel model) { if (model.image != null) { var arrData = model.image.Split(';'); if (arrData.Length == 3) { var savePath = $@"assets/Upload/DichVu/{arrData[0]}"; var savePathh = $@"assets/Upload/DichVu/{arrData[0]}"; model.image = $"{savePath}"; SaveFileFromBase64String(savePath, arrData[2]); SaveFileFromBase64(savePathh, arrData[2]); } } model.id = Guid.NewGuid().ToString(); dichvu.Create(model); return(model); }
public JsonResult ThemDonDatDichVuP(string Prefix) { if (Prefix != null) { DichVuModel dichVuModel = new DichVuModel(); List <DichVu> lsDichVu = dichVuModel.GetData(); var ProductList = (from N in lsDichVu where N.TenDichVu.StartsWith(Prefix) select new { N.TenDichVu, N.MaDV }); return(Json(ProductList, JsonRequestBehavior.AllowGet)); } var Message = "Thêm sản phẩm thất bại"; return(Json(Message, JsonRequestBehavior.AllowGet)); }
public ActionResult Create() { if (!_nguoiDungServices.isLoggedIn()) { TempData["Message"] = "Bạn chưa đăng nhập, vui lòng đăng nhập"; TempData["NotiType"] = "danger"; //success là class trong bootstrap return(RedirectToAction("Login", "NguoiDung")); } if (!_quyenServices.Authorize((int)EnumQuyen.DICHVU_THEM)) { return(RedirectToAction("ViewDenied", "QLKS")); } var dichVuModel = new DichVuModel(); var maxId = db.DICHVUs.Select(c => c.ID).DefaultIfEmpty(0).Max(); var newId = (maxId + 1).ToString().PadLeft(7, '0'); dichVuModel.Ma = "DV" + "-" + newId; return(View(dichVuModel)); }
public ActionResult Create(DichVuModel model) { if (!ModelState.IsValid) { TempData["Message"] = "Có lỗi xảy ra! Vui lòng kiểm tra lại thông tin."; TempData["NotiType"] = "success"; //success là class trong bootstrap return(View("Create", model)); } var item = AutoMapper.Mapper.Map <DICHVU>(model); //db.DICHVUs.Add(item); var id = 0; db.Database.ExecuteSqlCommand("exec SP_CreateOrUpdate_DICHVU @Type, @ID, @Ten, @DonGia, @Ma, @UpdateID", new SqlParameter("@Type", int.Parse("0")), new SqlParameter("@ID", id), new SqlParameter("@Ten", item.Ten), new SqlParameter("@DonGia", item.DonGia), new SqlParameter("@Ma", item.Ma), new SqlParameter("@UpdateID", int.Parse("0"))); db.SaveChanges(); _lichSuServices.LuuLichSu((int)Session["ID"], (int)EnumLoaiHanhDong.THEM, item.GetType().ToString()); TempData["Message"] = "Thêm mới thành công"; TempData["NotiType"] = "success"; return(RedirectToAction("List")); }
public bool Update(DichVuModel model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_dichvu_update", "@id", model.id, "@tendichvu", model.tendichvu, "@image", model.image); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public ActionResult SuaDichVu(DichVuModel model, HttpPostedFileBase file) { DichVu dv = db.DichVus.Find(model.Id); if (dv != null) { dv.TenDichVu = model.TenDichVu; dv.Gia = model.Gia; dv.MoTa = model.MoTa; dv.MaLoaiDV = model.MaLoaiDV; db.SaveChanges(); } string subPath = "~/Content/UserUpload/img/dichvu/"; // your code goes here bool exists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } try { if (file != null && file.ContentLength > 0) { var path = Path.Combine(Server.MapPath(subPath), dv.Id.ToString() + ".png"); file.SaveAs(path); } } catch (Exception ex) { //return Json(new { Success = "false", Error = ex.Message }); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
private bool CheckExists(DichVuModel DichVu, HMSEntities db) { H_DichVu obj = db.H_DichVu.FirstOrDefault(x => !x.IsDeleted && x.Id != DichVu.Id && x.WorkId == DichVu.CVId && x.WorkTypeId == DichVu.LoaiCVId); return(obj != null ? true : false); }
public bool Update(DichVuModel model) { return(_res.Update(model)); }
public bool Create(DichVuModel model) { return(_res.Create(model)); }
public void Delete(DichVuModel dichVu) { _dichVu.MyDeleteData(dichVu); }
public void Put(DichVuModel dichVu) { _dichVu.UpdateData(dichVu); }
public void Post(DichVuModel dichVu) { _dichVu.InsertData(dichVu); }