예제 #1
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()));
 }
예제 #2
0
        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));
        }
예제 #4
0
        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));
        }
예제 #7
0
        public override String ajax_MasterGridData(q_Users queryObj)
        {
            #region 連接BusinessLogicLibary資料庫並取得資料
            ac = new a_Users()
            {
                Connection = getSQLConnection()
            };
            RunQueryPackage <m_Users> 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);

            UnitData unit = new UnitData();
            var      dic  = unit.CollectIdNameFields(x => x.id, x => x.name, getSQLConnection());

            foreach (m_Users md in Modules)
            {
                List <String> setFields = new List <String>(5);

                setFields.Add(md.id.ToString());
                setFields.Add(md.account);
                setFields.Add(md.unit.TableCodeValue(dic));
                setFields.Add(md.state.CodeValue(CodeSheet.使用者狀態.MakeCodes()));
                setFields.Add(md.isadmin.BooleanValue(BooleanSheet.ynv));
                setRowElement.Add(new RowElement()
                {
                    id = md.id.ToString(), cell = setFields.ToArray()
                });
            }
            #endregion
            #region 回傳JSON資料
            JQGridDataObject dataObj = new JQGridDataObject()
            {
                rows    = setRowElement.ToArray(),
                total   = PageCount.TotalPage,
                page    = PageCount.Page,
                records = PageCount.RecordCount
            };

            return(JsonConvert.SerializeObject(dataObj, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));

            #endregion
        }
        public override String ajax_MasterGridData(q_ProductKind queryObj)
        {
            #region 連接BusinessLogicLibary資料庫並取得資料
            ac = new a_ProductKind()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };;

            RunQueryPackage <m_ProductKind> 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);
            var Series  = new String[] { "", "屏風系列", "辦公桌系列", "會議桌系列", "檔案櫃系列", "主管辦公桌系列", "辦公椅系列", "沙發系列", "", "", "其他商品", "造型椅 / 吧檯椅", "新進商品", "特價商品" };
            foreach (m_ProductKind md in Modules)
            {
                List <String> setFields = new List <String>(6);

                setFields.Add(md.ID.ToString());
                setFields.Add(Series[md.Series]);
                setFields.Add(md.Name);
                setFields.Add(md.IsOpen.BooleanValue(BooleanSheet.yn));
                setFields.Add(md.IsSecond.BooleanValue("二手", "全新"));
                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
        }
예제 #9
0
        public override String ajax_MasterSubGridData(q__CodeSheet queryObj)
        {
            #region 連接BusinessLogicLibary資料庫並取得資料
            acd = new a__CodeSheet()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };;

            RunQueryPackage <m__CodeSheet> HResult = acd.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);
            foreach (m__CodeSheet md in Modules)
            {
                List <String> setFields = new List <String>();
                setFields.Add(md.id.ToString());
                setFields.Add(md.Code);
                setFields.Add(md.Value);
                setFields.Add(md.Memo);
                setFields.Add(md.Sort.ToString());
                setFields.Add(md.IsUse.BooleanValue(BooleanSheet.ynv));
                setFields.Add(md.CodeHeadId.ToString());
                setRowElement.Add(new RowElement()
                {
                    id = md.id.ToString(), cell = setFields.ToArray()
                });
            }
            #endregion
            #region 回傳JSON資料
            JQGridDataObject dataObj = new JQGridDataObject()
            {
                rows    = setRowElement.ToArray(),
                total   = PageCount.TotalPage,
                page    = PageCount.Page,
                records = PageCount.RecordCount
            };

            JavaScriptSerializer js = new JavaScriptSerializer()
            {
                MaxJsonLength = 65536
            };                                                                              //64K
            return(js.Serialize(dataObj));

            #endregion
        }
예제 #10
0
        public override String ajax_MasterGridData(q_ProgData queryObj)
        {
            #region 連接BusinessLogicLibary資料庫並取得資料
            ac            = new a_ProgData();
            ac.Connection = this.getSQLConnection();
            RunQueryPackage <m_ProgData> HResult = ac.SearchMasterLVL1(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>();
            m_ProgData[]      drDataCollect = HResult.SearchData;

            foreach (m_ProgData dr in drDataCollect)
            {
                List <String> setFields = new List <String>();

                setFields.Add(dr.id.ToString());
                setFields.Add(dr.prog_name);
                setFields.Add(dr.area);
                setFields.Add(dr.controller);
                setFields.Add(dr.action);
                setFields.Add(dr.sort);
                setFields.Add(dr.isfolder.BooleanValue(BooleanSheet.ynvx));
                setRowElement.Add(new RowElement()
                {
                    id = dr.id.ToString(), cell = setFields.ToArray()
                });
            }
            #endregion
            #region 回傳JSON資料
            JQGridDataObject dataObj = new JQGridDataObject()
            {
                rows    = setRowElement.ToArray(),
                total   = 1,
                page    = 1,
                records = PageCount.RecordCount
            };

            JavaScriptSerializer js = new JavaScriptSerializer()
            {
                MaxJsonLength = 65536
            };                                                                              //64K
            return(js.Serialize(dataObj));

            #endregion
        }
예제 #11
0
        public override String ajax_MasterGridData(q_Document queryObj)
        {
            #region 連接BusinessLogicLibary資料庫並取得資料
            ac = new a_Document()
            {
                Connection = getSQLConnection(), logPlamInfo = plamInfo
            };;

            RunQueryPackage <m_Document> 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);
            foreach (m_Document md in Modules)
            {
                List <String> setFields = new List <String>();

                setFields.Add(md.id.ToString());
                setFields.Add(md.title);
                setFields.Add(md.set_date.ToStandardDate());
                setFields.Add(md.isopen.BooleanValue(BooleanSheet.ynvx));
                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
        }
예제 #12
0
        public override string ajax_MasterGridData(q_Unit queryObj)
        {
            #region 連接BusinessLogicLibary資料庫並取得資料
            ac            = new a_Unit();
            ac.Connection = this.getSQLConnection();
            RunQueryPackage <m_Unit> 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 drDataCollect = HResult.SearchData.Skip(startRecord).Take(this.DefPageSize);
            this.Tab = new UnitData();
            foreach (var dr in drDataCollect)
            {
                RowElement GridRow = new RowElement()
                {
                    id = dr.id.ToString(), cell = new String[3]
                };

                GridRow.cell[0] = dr.id.ToString();
                GridRow.cell[1] = dr.name;
                GridRow.cell[2] = dr.sort.ToString();

                setRowElement.Add(GridRow);
            }
            #endregion
            #region 回傳JSON資料
            JQGridDataObject dataObj = new JQGridDataObject()
            {
                rows    = setRowElement.ToArray(),
                total   = PageCount.TotalPage,
                page    = PageCount.Page,
                records = PageCount.RecordCount
            };

            return(JsonConvert.SerializeObject(dataObj, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));

            #endregion
        }
예제 #13
0
        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);
        }
예제 #14
0
        public ActionResult Index()
        {
            Session["MenuHtmlString"] = null;

            a__Lang ac = new a__Lang()
            {
                Connection  = getSQLConnection(),
                logPlamInfo = new ProcCore.Log.LogPlamInfo()
                {
                    UserId      = 0,
                    AllowWrite  = true,
                    BroswerInfo = System.Web.HttpContext.Current.Request.Browser.Browser + "." + System.Web.HttpContext.Current.Request.Browser.Version,
                    IP          = System.Web.HttpContext.Current.Request.UserHostAddress
                }
            };

            RunQueryPackage <m__Lang> r = ac.SearchMaster(new q__Lang()
            {
                s_isuse = true
            }, 0);

            List <SelectListItem> p = new List <SelectListItem>();

            foreach (var opt in r.SearchData)
            {
                p.Add(new SelectListItem()
                {
                    Value = opt.lang, Text = opt.area
                });
            }

            ViewBag.Lang_Option = p;

            ViewData["username"] = "";
            ViewData["password"] = "";

#if DEBUG
            ViewData["username"] = CommWebSetup.AutoLoginUser;
            ViewData["password"] = CommWebSetup.AutoLoginPassword;
#endif
            return(View());
        }
예제 #15
0
        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()));
        }