public ActionResult ChangeCauHinhWeb(HttpPostedFileBase cauhinh_logo, string ten_congty, int id, string ten_viet_tat, string ten_viet_tat_nm, string ten_nha_may, int id_nm, string dia_chi_nm) { string fileName = "default_logo.png"; try { if (cauhinh_logo != null) { //fileName = System.IO.Path.GetFileName(cauhinh_logo.FileName)+"/"+ id; fileName = "logoFactory_" + id + ".png"; string path_avatar = System.IO.Path.Combine(Server.MapPath("~/images/logoFactory"), fileName); // file is uploaded cauhinh_logo.SaveAs(path_avatar); } CongTy ct = CongTyDAO.getCongTyById(id); if (ct == null) { return(Json(new { success = false, message = "Không tìm thấy thông tin công ty" })); } ct.Logo = fileName; ct.TenCongTy = ten_congty; ct.TenVietTat = ten_viet_tat; var rs = CongTyDAO.updateCongTyInformation(ct); NhaMay nm = NhaMayDAO.GetNhaMayById(id_nm); if (nm == null) { return(Json(new { success = false, message = "Không tìm thấy thông tin nhà máy" })); } nm.TenNhaMay = ten_nha_may; nm.TenVietTat = ten_viet_tat_nm; nm.DiaChi = dia_chi_nm; var rs_nm = NhaMayDAO.updateNhaMayInformation(nm); if (rs != "success") { return(Json(new { success = false, message = rs })); } if (rs_nm != "success") { return(Json(new { success = false, message = rs_nm })); } Session["CongTy"] = ct; Session["NhaMay"] = nm; return(Json(new { success = true, message = string.Empty })); } catch { return(Json(new { success = false, message = "Không thể truy cập cơ sở dữ liệu" })); } }
// GET: Account public ActionResult Login() { CongTy ct = CongTyDAO.getCongTyByDefault(); Session["CongTy"] = ct; NhaMay nm = NhaMayDAO.GetNhaMayByDefault(); Session["NhaMay"] = nm; if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } return(View()); }
public ActionResult CapNhatDiemDoManageModal(int id) { ViewBag.ListNhaMay = NhaMayDAO.GetAllNhaMay(); ViewBag.ListTCDD = TinhChatDiemDoDAO.GetAllTCDD(); DiemDo dd = new DiemDo(); if (id == 0) { //return Json(new { success = true, data = View() }); return(PartialView()); } var rs = DiemDoDAO.GetDiemDoById(id, out dd); //return Json(new { success = rs, data = View(sldk) }); return(PartialView(dd)); }
// call hàm này để check xem có được phép truy cập protected override bool AuthorizeCore(HttpContextBase httpContext) { if (HttpContext.Current.User.Identity.IsAuthenticated || HttpContext.Current.Session["User"] != null) { if (HttpContext.Current.Session["User"] == null) { HttpCookie authCookie = HttpContext.Current.Request.Cookies["login_form_cre"]; FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); var serializeModel = JsonConvert.DeserializeObject <CustomSerializeModel>(authTicket.UserData); Account acc = AccountDAO.GetAccountByID(serializeModel.UserId); HttpContext.Current.Session["User"] = acc; } HttpContext.Current.Session["CongTy"] = CongTyDAO.getCongTyByDefault(); HttpContext.Current.Session["NhaMay"] = NhaMayDAO.GetNhaMayByDefault(); return(true); } return(false); }
public ActionResult CapNhatDiemDoView() { ViewBag.ListNhaMay = NhaMayDAO.GetAllNhaMay(); ViewBag.ListTCDD = TinhChatDiemDoDAO.GetAllTCDD(); return(View()); }