public override void ProcessRequest(HttpContext context)
        {
            this.c = context;
            vmJsonResult  r_json_data = null;
            a_ProductKind LBase       = new a_ProductKind();

            try
            {
                LBase.Connection = getSQLConnection();
                r_json_data      = new vmJsonResult()
                {
                    result = true, data = LBase.SearchMaster(new q_ProductKind()
                    {
                    }, 0)
                };
                context.Response.Write(JsonConvert.SerializeObject(r_json_data, new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
            catch (Exception ex)
            {
                r_json_data = new vmJsonResult()
                {
                    result = false, message = ex.Message + ":" + ex.StackTrace
                };
                context.Response.Write(JsonConvert.SerializeObject(r_json_data));
            }
        }
示例#2
0
 public ActionResult Index()
 {
     ViewBag.IsFirstPage = true;
     ViewBag.BodyClass   = "index";
     ViewBag.Cur         = new string[] { "", "", "", "", "", "", "", "", "", "", "" };
     #region getSid Int
     a_ProductKind c = new a_ProductKind()
     {
         Connection = getSQLConnection(), logPlamInfo = plamInfo
     };
     RunQueryPackage <m_ProductKind> hResult = c.SearchMaster(new q_ProductKind()
     {
         s_Series = 12
     }, 1);                                                                                            //get 新進商品
     int[] s_kinds = hResult.SearchData.Select(x => x.ID).ToArray();
     #endregion
     a_ProductData t = new a_ProductData()
     {
         Connection = getSQLConnection(), logPlamInfo = plamInfo
     };
     RunQueryPackage <m_ProductData> r = t.SearchMaster(new q_ProductData()
     {
         s_IsSecond = true, s_IsOpen = true, s_Kinds = s_kinds
     }, 1);
     return(View(r.SearchData.AsEnumerable()));
 }
        public ActionResult Products_new3(int id, int?sid)
        {
            a_ProductData b = new a_ProductData()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };                                                                                                //資料庫連線,取得登入者資訊
            var a = b.GetDataMaster(id, 0);
            //取得kind的值
            a_ProductKind t = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> r = t.SearchMaster(new q_ProductKind()
            {
                s_ID = a.SearchData.Kind
            }, 1);
            var tmp = r.SearchData.FirstOrDefault().Name;

            ViewBag.kind = tmp;//放進viewbag裡

            ViewBag.BodyClass = "Products new";
            ViewBag.Cur       = new string[] { "", "", "", "", "", "", "", "", "", "", "", "" };
            String[] Series = { "", "屏風系列", "辦公桌系列", "會議桌系列", "檔案櫃系列", "主管辦公桌系列", "辦公椅系列", "沙發系列", "", "", "其他商品", "造型椅 / 吧檯椅" };
            if (sid == null)
            {
                sid = 1;
            }

            ViewBag.Cur[Convert.ToInt32(sid)] = "current";
            ViewBag.Nur    = Convert.ToInt32(sid);
            ViewBag.Series = Series[Convert.ToInt32(sid)];

            return(View(a.SearchData));
        }
        public override ActionResult EditMasterDataByID(int id)
        {
            #region GetKinds
            //gg
            a_ProductKind c = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> hResult = c.SearchMaster(new q_ProductKind(), LoginUserId);
            HandleResultCheck(hResult);
            List <SelectListItem> New_Kinds    = new List <SelectListItem>();
            List <SelectListItem> Second_Kinds = new List <SelectListItem>();
            #endregion

            operationMode = OperationMode.EditModify;
            ac            = new a_ProductData()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };

            RunOneDataEnd <m_ProductData> HResult = ac.GetDataMaster(id, LoginUserId);
            md = HResult.SearchData;

            int sid = hResult.SearchData.Where(m_ProductData => m_ProductData.ID == md.Kind).First().Series;
            foreach (var item in hResult.SearchData.Where(x => x.Series == sid))
            {
                if (item.IsSecond == true)
                {
                    Second_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
                else
                {
                    New_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
            }
            ViewBag.NewKind_Option    = New_Kinds;
            ViewBag.SecondKind_Option = Second_Kinds;

            md.Series   = sid;
            md.EditType = EditModeType.Modify;
            HandleResultCheck(HResult);
            HandleCollectDataToOptions();

            ViewBag.Caption = GetSystemInfo().prog_name;

            HandleRequest HRq = new HandleRequest(); //記錄QueryString
            HRq.Remove("id");                        //不需記ID
            ViewBag.QueryString = HRq.ToQueryString();
            ViewBag.id          = id;
            HRq = null;

            return(View("EditData", md));
        }
        public ActionResult Products_second(int?sid, int?page)
        {
            if (sid == null)
            {
                sid = 1;
            }
            //if (Convert.ToInt32(sid) == 0 || Convert.ToInt32(sid) == 8 || Convert.ToInt32(sid) == 9) { return RedirectToAction("Products_second2", "Products", new { sid = sid }); }
            if (Convert.ToInt32(sid) == 9)
            {
                return(RedirectToAction("Products_second2", "Products", new { sid = sid }));
            }

            ViewBag.BodyClass = "Products second";
            ViewBag.Cur       = new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
            String[] Series = { "新進商品", "屏風系列", "辦公桌系列", "會議桌系列", "檔案櫃系列", "主管辦公桌系列", "辦公椅系列", "沙發系列", "特價系列", "規劃樣品展示", "其他商品", "造型椅 / 吧檯椅", "新進商品", "特價商品" };


            ViewBag.Cur[Convert.ToInt32(sid)] = "current";
            ViewBag.Nur    = Convert.ToInt32(sid);
            ViewBag.Series = Series[Convert.ToInt32(sid)];
            a_ProductKind t = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> r = t.SearchMaster(new q_ProductKind()
            {
                s_IsOpen = true, s_Series = sid, s_IsSecond = true
            }, 1);


            page = page == null ? 1 : page;

            int totalpage = r.SearchData.Count() / 9;
            int mod       = r.SearchData.Count() % 9;

            if (mod != 0)
            {
                totalpage++;
            }
            int getTotalPage = totalpage;
            var getProduct   = r.SearchData.Skip(9 * ((int)page - 1)).Take(9);

            ViewBag.nextPage = getTotalPage > page ? page + 1 : page;
            ViewBag.prvePage = page <= 1 ? 1 : page - 1;

            if (r.SearchData.Count() >= 1 && r.SearchData.Count() <= 9)
            {
                ViewBag.totalPage = 1;
            }
            else
            {
                ViewBag.totalPage = getTotalPage;
            }
            ViewBag.page = page;
            ViewBag.sid  = sid;

            return(View(getProduct));
        }
        public override ActionResult EditMasterNewData()
        {
            #region GetKinds
            //gg
            a_ProductKind c = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> hResult = c.SearchMaster(new q_ProductKind(), LoginUserId);
            HandleResultCheck(hResult);
            List <SelectListItem> All_Kinds    = new List <SelectListItem>();
            List <SelectListItem> New_Kinds    = new List <SelectListItem>();
            List <SelectListItem> Second_Kinds = new List <SelectListItem>();
            foreach (var item in hResult.SearchData.Where(x => x.Series == 12))//預設為 新進商品 SID=12
            {
                All_Kinds.Add(new SelectListItem()
                {
                    Text = item.Name, Value = item.ID.ToString()
                });
                if (item.IsSecond == true)
                {
                    Second_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
                else
                {
                    New_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
            }
            ViewBag.NewKind_Option    = New_Kinds;
            ViewBag.SecondKind_Option = Second_Kinds;
            ViewBag.AllKind_Option    = All_Kinds;
            #endregion

            operationMode = OperationMode.EditInsert;
            HandleCollectDataToOptions();
            ViewBag.Caption = GetSystemInfo().prog_name;
            HandleRequest HRq = new HandleRequest(); //記錄QueryString
            HRq.Remove("Id");                        //不需記ID
            ViewBag.QueryString = HRq.ToQueryString();
            HRq = null;
            ac  = new a_ProductData()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            return(View("EditData", new m_ProductData()
            {
                ID = ac.GetIDX(),
                IsSecond = true,
                EditType = EditModeType.Insert,
                IsOpen = true
            }));
        }
        public override ActionResult ListGrid(q_ProductData sh)
        {
            #region GetKinds
            //gg
            a_ProductKind c = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> hResult = c.SearchMaster(new q_ProductKind(), LoginUserId);
            HandleResultCheck(hResult);
            List <SelectListItem> All_Kinds    = new List <SelectListItem>();
            List <SelectListItem> New_Kinds    = new List <SelectListItem>();
            List <SelectListItem> Second_Kinds = new List <SelectListItem>();
            Second_Kinds.Add(new SelectListItem()
            {
                Text = "不分類", Value = null
            });
            New_Kinds.Add(new SelectListItem()
            {
                Text = "不分類", Value = null
            });
            foreach (var item in hResult.SearchData)
            {
                All_Kinds.Add(new SelectListItem()
                {
                    Text = item.Name, Value = item.ID.ToString()
                });
                if (item.IsSecond == true)
                {
                    Second_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
                else
                {
                    New_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
            }
            ViewBag.NewKind_Option    = New_Kinds;
            ViewBag.SecondKind_Option = Second_Kinds;
            #endregion

            operationMode = OperationMode.EnterList;
            HandleRequest HRq = new HandleRequest(); //記錄QueryString
            HRq.encodeURIComponent = true;
            HRq.Remove("page");

            ViewBag.Page              = QueryGridPage();
            ViewBag.Caption           = GetSystemInfo().prog_name;
            ViewBag.AppendQuertString = HRq.ToQueryString();
            HRq = null;

            return(View("ListData", sh));
        }
        public string getOption(int sid, bool is_second)
        {
            #region GetKinds
            //gg
            a_ProductKind c = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> hResult = c.SearchMaster(new q_ProductKind(), LoginUserId);
            HandleResultCheck(hResult);
            List <SelectListItem> New_Kinds    = new List <SelectListItem>();
            List <SelectListItem> Second_Kinds = new List <SelectListItem>();
            #endregion

            foreach (var item in hResult.SearchData.Where(x => x.Series == sid))
            {
                if (item.IsSecond == true)
                {
                    Second_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
                else
                {
                    New_Kinds.Add(new SelectListItem()
                    {
                        Text = item.Name, Value = item.ID.ToString()
                    });
                }
            }

            string getjson = string.Empty;
            if (is_second)
            {
                getjson = JsonConvert.SerializeObject(Second_Kinds);
            }
            else
            {
                getjson = JsonConvert.SerializeObject(New_Kinds);
            }


            return(getjson);
        }
        public ActionResult Products_new2(int?sid, int?kid, int?page)
        {
            ViewBag.BodyClass = "Products new";
            ViewBag.Cur       = new string[] { "", "", "", "", "", "", "", "", "", "", "", "" };
            String[] Series = { "", "屏風系列", "辦公桌系列", "會議桌系列", "檔案櫃系列", "主管辦公桌系列", "辦公椅系列", "沙發系列", "", "", "其他商品", "造型椅 / 吧檯椅" };
            if (sid == null)
            {
                sid = 1;
            }

            ViewBag.Cur[Convert.ToInt32(sid)] = "current";
            ViewBag.Nur    = Convert.ToInt32(sid);
            ViewBag.Series = Series[Convert.ToInt32(sid)];
            a_ProductKind t = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> r = t.SearchMaster(new q_ProductKind()
            {
                s_ID = kid
            }, 1);

            ViewBag.kind = r.SearchData.First().Name;

            a_ProductData p = new a_ProductData()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductData> pr = p.SearchMaster(new q_ProductData()
            {
                s_IsOpen = true, s_IsSecond = false, s_Kind = kid
            }, 1);



            if (pr.SearchData.Any())
            {
                int?kind_id = r.SearchData.First().ID;
                var getid   = p.SearchMaster(new q_ProductData()
                {
                    s_Kind = kind_id
                }, 0);
                if (pr.SearchData.Count() == 1 && getid.SearchData.Any())
                { //如果此種類(kid)只有一項就直接跳到product_second3去顯示
                    int id = getid.SearchData.First().ID;
                    Response.Redirect("~/Products/Products_new3/" + id + "?sid=" + sid);
                }
            }

            page = page == null ? 1 : page;

            int totalpage = pr.SearchData.Count() / 9;
            int mod       = pr.SearchData.Count() % 9;

            if (mod != 0)
            {
                totalpage++;
            }
            int getTotalPage = totalpage;
            var getProduct   = pr.SearchData.Skip(9 * ((int)page - 1)).Take(9);

            ViewBag.nextPage = getTotalPage > page ? page + 1 : page;
            ViewBag.prvePage = page <= 1 ? 1 : page - 1;
            if (r.SearchData.Count() >= 1 && r.SearchData.Count() <= 9)
            {
                ViewBag.totalPage = 1;
            }
            else
            {
                ViewBag.totalPage = getTotalPage;
            }
            ViewBag.page = page;
            ViewBag.sid  = sid;


            return(View(getProduct.AsEnumerable()));
        }
        public override String ajax_MasterGridData(q_ProductData queryObj)
        {
            #region 連接BusinessLogicLibary資料庫並取得資料
            ac = new a_ProductData()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };;

            RunQueryPackage <m_ProductData> HResult = ac.SearchMaster(queryObj, LoginUserId);
            HandleResultCheck(HResult);
            #endregion
            #region 設定 Page物件 頁數 總筆數 每頁筆數
            int page        = (queryObj.page == null ? 1 : queryObj.page.CInt());
            int startRecord = PageCount.PageInfo(page, this.DefPageSize, HResult.Count);
            #endregion
            #region 每行及每個欄位資料組成
            List <RowElement> setRowElement = new List <RowElement>();
            var Modules = HResult.SearchData.Skip(startRecord).Take(this.DefPageSize);

            a_ProductKind c = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };
            RunQueryPackage <m_ProductKind> hResult = c.SearchMaster(new q_ProductKind(), LoginUserId);
            var Series = new String[] { "", "屏風系列", "辦公桌系列", "會議桌系列", "檔案櫃系列", "主管辦公桌系列", "辦公椅系列", "沙發系列", "", "", "其他商品", "造型椅 / 吧檯椅", "新進商品", "特價商品" };
            foreach (m_ProductData md in Modules)
            {
                List <String> setFields = new List <String>(10);
                //JQGrid Col
                int sid = 0;
                if (hResult.SearchData.AsQueryable().Where(m_ProductData => m_ProductData.ID == md.Kind).Any())
                {
                    sid = hResult.SearchData.AsQueryable().Where(m_ProductData => m_ProductData.ID == md.Kind).First().Series;
                }

                setFields.Add(md.ID.ToString());
                setFields.Add(md.Name);
                setFields.Add(md.Price);
                setFields.Add(md.IsOpen.BooleanValue(BooleanSheet.yn));
                setFields.Add(Series[sid]);
                setFields.Add(hResult.SearchData.AsQueryable().Where(m_ProductData => m_ProductData.ID == md.Kind).First().Name);
                setFields.Add(md.IsSecond.BooleanValue("二手", "全新"));
                //setFields.Add(md.IsOnSell.BooleanValue(BooleanSheet.yn));
                setFields.Add(md.IsDisp.BooleanValue(BooleanSheet.yn));
                //setFields.Add(md.IsNew.BooleanValue(BooleanSheet.yn));
                setFields.Add(md.Sort.ToString());


                setRowElement.Add(new RowElement()
                {
                    id = md.ID.ToString(), cell = setFields.ToArray()
                });
            }
            #endregion
            #region 回傳JSON資料

            return(JsonConvert.SerializeObject(new JQGridDataObject()
            {
                rows = setRowElement.ToArray(),
                total = PageCount.TotalPage,
                page = PageCount.Page,
                records = PageCount.RecordCount
            }, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));

            #endregion
        }