示例#1
0
        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" }));
            }
        }
示例#2
0
        public ActionResult QuanTriCauHinh()
        {
            //id cong ty default
            CauHinhWebViewModel model = new CauHinhWebViewModel();
            CongTy ct = (CongTy)Session["CongTy"];
            NhaMay nm = (NhaMay)Session["NhaMay"];

            model.ct = ct;
            model.nm = nm;
            return(View(model));
        }
        // 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());
        }