예제 #1
0
        public PartialViewResult _ListDetail(int serviceId = 0)
        {
            int height = (int)(Request.Browser.ScreenPixelsHeight * 0.85);

            TB_SERVICES s = Services_Service.GetById(serviceId);

            ViewBag.Service = s;

            List <TB_TYPES> list = Types_Service.GetAll();

            ViewBag.TypeList = list;

            try
            {
                ViewBag.Images = Files_Service.GetByRefecense("" + s.ServiceId).Where(x => x.FileType == "SERVICE").ToList();
            }
            catch (Exception ex)
            {
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "Blogs/_List :", ex.Message, ex.ToString());
            }

            return(PartialView(height));
        }
예제 #2
0
        public JsonResult UploadFiles(List <HttpPostedFileBase> files)
        {
            string          folderPath = Server.MapPath("~/Files");
            string          filePath   = "";
            AjaxResultModel Result     = new AjaxResultModel();
            List <TB_FILES> data       = new List <TB_FILES>();

            try
            {
                if (!folderPath.EndsWith("/"))
                {
                    filePath += "/" + DateTime.Now.ToString("yyyy_MM_dd") + "/";
                }
                else
                {
                    filePath += DateTime.Now.ToString("yyyy_MM_dd") + "/";
                }
                IOHelper.CreateFolder(folderPath + filePath);
                int value = -1;
                if (files != null)
                {
                    foreach (var file in files)
                    {
                        var InputFileName = DateTime.Now.ToString("yyyyMMddHHmmss_") + Path.GetFileName(file.FileName);
                        //var ServerSavePath = Path.Combine(Server.MapPath("~/Files/") + InputFileName);
                        TB_FILES fTemp = new TB_FILES();
                        fTemp.FileName    = Path.GetFileName(file.FileName);
                        fTemp.FileUrl     = "/Files" + filePath + InputFileName;
                        fTemp.FileRef     = InputFileName;
                        fTemp.FileType    = file.ContentType;
                        fTemp.FileService = "USER";
                        file.SaveAs(folderPath + filePath + InputFileName);
                        value = Files_Service.AddFile(fTemp);
                        if (value != -1)
                        {
                            data.Add(fTemp);
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (value != -1)
                    {
                        Result.Code   = 0;
                        Result.Result = value;
                    }
                }
                else
                {
                    Result.Code   = 1;
                    Result.Result = "Thao tác không thành công";
                }
            }
            catch (Exception Ex)
            {
                Result.Code = 0;
                IOHelper.WriteLog(StartUpPath, IpAddress, "Product::_ChiTiet:GetAllProvider:", Ex.Message, Ex.ToString());
                throw;
            }
            return(Json(new JsonResult()
            {
                Data = Result
            }));
        }
예제 #3
0
        public JsonResult UpdateService(int service_id, string service_name, decimal service_price, string service_unit, string service_base, string service_content, string service_status, string service_type, List <TypeDetail> details)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                string xml = "<Root>";
                xml += "<Service>"
                       + "<ServiceId>" + service_id + "</ServiceId>"
                       + "<ServiceName>" + service_name + "</ServiceName>"
                       + "<ServicePrice>" + service_price + "</ServicePrice>"
                       + "<ServiceUnit>" + service_unit + "</ServiceUnit>"
                       + "<ServiceBase>" + service_base + "</ServiceBase>"
                       + "<ServiceContent>" + service_content + "</ServiceContent>"
                       + "<ServiceStatus>" + service_status + "</ServiceStatus>"
                       + "<ServiceTypeCode>" + service_type + "</ServiceTypeCode>"
                       + "</Service>";
                xml += "<Rows>";
                foreach (TypeDetail detail in details)
                {
                    xml += "<Detail>"
                           + "<DetailId>" + detail.DetailId + "</DetailId>"
                           + "<DetailName>" + (detail.DetailName ?? "") + "</DetailName>"
                           + "</Detail>";;
                }
                xml += "</Rows>";
                xml += "</Root>";

                string id = "";
                if (Services_Service.Insert(xml, out id))
                {
                    if (Request.Files.Count > 0)
                    {
                        HttpPostedFileBase file     = Request.Files[0];
                        string             fileName = Path.GetFileName(file.FileName);
                        string             filePath = SaveFile(file);
                        if (Files_Service.Insert(new TB_FILES
                        {
                            FileOrg = fileName,
                            FilePath = filePath,
                            FileData = "",
                            FileStatus = "A",
                            FileType = "SERVICE",
                            FileReferenceId = id
                        }))
                        {
                            Result.Code   = 00;
                            Result.Result = "Thành công";
                        }
                        else
                        {
                            Result.Code   = 1;
                            Result.Result = "Upload file Không thành công";
                        }
                    }
                    else
                    {
                        Result.Code   = 00;
                        Result.Result = "Thành công";
                    }
                }
                else
                {
                    Result.Code   = 001;
                    Result.Result = "Không thành công";
                }
            }
            catch (Exception Ex)
            {
                Result.Code   = 2000;
                Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị.";
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString());
            }

            return(Json(Result));
        }
예제 #4
0
        public JsonResult InsertSlider(string slider_name, string slider_content, bool slider_show)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                if (Request.Files.Count != 1)
                {
                    Result.Code   = 1;
                    Result.Result = "Dữ liệu không hợp lệ. Cần 1 ảnh chạy cho Slider";
                    return(Json(Result));
                }

                int id = Sliders_Service.Insert(new TB_SLIDERS
                {
                    SliderName       = slider_name,
                    SliderContent    = slider_content,
                    SliderDateCreate = DateTime.Now,
                    SliderIsShow     = slider_show,
                    SliderUserId     = UserId
                });

                if (id > 0)
                {
                    HttpPostedFileBase file     = Request.Files[0];
                    string             fileName = Path.GetFileName(file.FileName);
                    string             filePath = SaveFile(file);
                    if (Files_Service.Insert(new TB_FILES
                    {
                        FileOrg = fileName,
                        FilePath = filePath,
                        FileData = "",
                        FileStatus = "A",
                        FileType = "SLIDER",
                        FileReferenceId = "" + id
                    }))
                    {
                        Result.Code   = 00;
                        Result.Result = "Thành công";
                    }
                    else
                    {
                        Result.Code   = 1;
                        Result.Result = "Không thành công";
                    }
                }
                else
                {
                    Result.Code   = 1;
                    Result.Result = "Không thành công";
                }
            }
            catch (Exception Ex)
            {
                Result.Code   = 2000;
                Result.Result = "Có lỗi xảy ra. Vui lòng thử lại sau hoặc liên hệ với người quản trị.";
                CORE.Helpers.IOHelper.WriteLog(StartUpPath, IpAddress, "UpdatePassword :", Ex.Message, Ex.ToString());
            }

            return(Json(Result));
        }