Пример #1
0
        public ActionResult Edit(PriceListSection priceListSection)
        {
            try
            {
                var files = Utilities.SaveFiles(Request.Files, Utilities.GetNormalFileName(priceListSection.Title), StaticPaths.PriceListSectionImages);

                if (files.Count > 0)
                {
                    priceListSection.Image = files[0].Title;
                }

                priceListSection.LastUpdate = DateTime.Now;

                ViewBag.Success = true;

                if (priceListSection.ID == -1)
                {
                    PriceListSections.Insert(priceListSection);

                    UserNotifications.Send(UserID, String.Format("جدید - برندهای لیست بنک داری '{0}'", priceListSection.Title), "/Admin/PriceListSections/Edit/" + priceListSection.ID, NotificationType.Success);
                    priceListSection = new PriceListSection();
                }
                else
                {
                    PriceListSections.Update(priceListSection);
                }
            }
            catch (Exception ex)
            {
                SetErrors(ex);
            }

            return(ClearView(priceListSection));
        }
Пример #2
0
        public ActionResult Edit(int?id)
        {
            PriceListSection priceListSection;

            if (id.HasValue)
            {
                priceListSection = PriceListSections.GetByID(id.Value);
            }
            else
            {
                priceListSection = new PriceListSection();
            }

            return(View(priceListSection));
        }
Пример #3
0
        public JsonResult Delete(int id)
        {
            var jsonSuccessResult = new JsonSuccessResult();

            try
            {
                PriceListSections.Delete(id);
                jsonSuccessResult.Success = true;
            }
            catch (Exception ex)
            {
                jsonSuccessResult.Errors  = new string[] { ex.Message };
                jsonSuccessResult.Success = false;
            }

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }
Пример #4
0
        public JsonResult Get(int pageIndex, int pageSize, string pageOrder, string title)
        {
            if (pageOrder.Trim() == "ID")
            {
                pageOrder = "OrderID";
            }

            var list = PriceListSections.Get(pageIndex, pageSize, pageOrder, title);

            int total     = PriceListSections.Count(title);
            int totalPage = (int)Math.Ceiling((decimal)total / pageSize);

            if (pageSize > total)
            {
                pageSize = total;
            }

            if (list.Count < pageSize)
            {
                pageSize = list.Count;
            }

            JsonResult result = new JsonResult()
            {
                Data = new
                {
                    TotalPages = totalPage,
                    PageIndex  = pageIndex,
                    PageSize   = pageSize,
                    Rows       = list
                },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            return(result);
        }
Пример #5
0
        public JsonResult SortSections(string[] Col1, string[] Col2, string[] Col3, string[] Col4, string[] Col5)
        {
            var jsonSuccessResult = new JsonSuccessResult();

            try
            {
                #region Column1

                int order = 0;

                if (Col1 != null)
                {
                    foreach (var item in Col1)
                    {
                        PriceListSections.SortSections(Int32.Parse(item), order, 1);
                        order++;
                    }
                }

                #endregion Column1

                #region Column2

                order = 0;

                if (Col2 != null)
                {
                    foreach (var item in Col2)
                    {
                        PriceListSections.SortSections(Int32.Parse(item), order, 2);
                        order++;
                    }
                }

                #endregion Column2

                #region Column3

                order = 0;

                if (Col3 != null)
                {
                    foreach (var item in Col3)
                    {
                        PriceListSections.SortSections(Int32.Parse(item), order, 3);
                        order++;
                    }
                }

                #endregion Column3

                #region Column4

                order = 0;

                if (Col4 != null)
                {
                    foreach (var item in Col4)
                    {
                        PriceListSections.SortSections(Int32.Parse(item), order, 4);
                        order++;
                    }
                }

                #endregion Column4

                #region Column5

                order = 0;

                if (Col5 != null)
                {
                    foreach (var item in Col5)
                    {
                        PriceListSections.SortSections(Int32.Parse(item), order, 5);
                        order++;
                    }
                }

                #endregion Column5

                jsonSuccessResult.Success = true;
            }
            catch (Exception ex)
            {
                jsonSuccessResult.Errors  = new string[] { ex.Message };
                jsonSuccessResult.Success = false;
            }

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }
Пример #6
0
        public ActionResult Print(byte id)
        {
            var list = PriceListSections.GetWithProducts((PriceListSectionType)id);

            return(View(list));
        }