Esempio n. 1
0
        public JsonResult InsertBlog(string blog_name, string blog_content, string blog_type, bool blog_show)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                int id = Blogs_Service.Insert(new TB_BLOGS
                {
                    BlogName       = blog_name,
                    BlogContent    = blog_content,
                    BlogType       = blog_type,
                    BlogDateCreate = DateTime.Now,
                    BlogIsShow     = blog_show,
                    BlogUserId     = UserId
                });

                if (id > 0)
                {
                    if (Request.Files.Count > 0)
                    {
                        for (int i = 0; i < Request.Files.Count; i++)
                        {
                            HttpPostedFileBase file     = Request.Files[i];
                            string             fileName = Path.GetFileName(file.FileName);
                            string             filePath = SaveFile(file);
                            Files_Service.Insert(new TB_FILES
                            {
                                FileOrg         = fileName,
                                FilePath        = filePath,
                                FileData        = "",
                                FileStatus      = "A",
                                FileType        = "BLOG",
                                FileReferenceId = "" + id
                            });
                        }
                    }

                    Result.Code   = 00;
                    Result.Result = "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));
        }
Esempio n. 2
0
        public JsonResult InsertProduct(string product_code, string product_name, decimal product_price, string product_state, string product_supplierCode, string product_categoryCode)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                if (Products_Service.Insert(new TB_PRODUCTS
                {
                    ProductCode = product_code,
                    ProductName = product_name,
                    ProductPrice = product_price,
                    ProductState = product_state,
                    ProductSupplierCode = product_supplierCode,
                    ProductCategoryCode = product_categoryCode
                }))
                {
                    if (Request.Files.Count > 0)
                    {
                        for (int i = 0; i < Request.Files.Count; i++)
                        {
                            HttpPostedFileBase file     = Request.Files[i];
                            string             fileName = Path.GetFileName(file.FileName);
                            string             filePath = SaveFile(file);
                            Files_Service.Insert(new TB_FILES
                            {
                                FileOrg         = fileName,
                                FilePath        = filePath,
                                FileData        = "",
                                FileStatus      = "A",
                                FileType        = "PRODUCT",
                                FileReferenceId = product_code
                            });
                        }
                    }

                    Result.Code   = 000;
                    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));
        }
Esempio n. 3
0
        public JsonResult UpdateSlider(int slider_id, string slider_name, string slider_content, bool slider_show)
        {
            AjaxResultModel Result = new AjaxResultModel();

            try
            {
                TB_SLIDERS slider = Sliders_Service.GetById(slider_id);
                slider.SliderName    = slider_name;
                slider.SliderContent = slider_content;
                slider.SliderIsShow  = slider_show;
                slider.SliderUserId  = UserId;

                if (Sliders_Service.Update(slider))
                {
                    if (Request.Files.Count > 0)
                    {
                        for (int i = 0; i < Request.Files.Count; i++)
                        {
                            HttpPostedFileBase file     = Request.Files[i];
                            string             fileName = Path.GetFileName(file.FileName);
                            string             filePath = SaveFile(file);
                            Files_Service.Insert(new TB_FILES
                            {
                                FileOrg         = fileName,
                                FilePath        = filePath,
                                FileData        = "",
                                FileStatus      = "A",
                                FileType        = "SLIDER",
                                FileReferenceId = "" + slider_id
                            });
                        }
                    }

                    Result.Code   = 000;
                    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));
        }
Esempio n. 4
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));
        }
Esempio n. 5
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));
        }