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 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_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()));
        }