public ActionResult StockItemTech(int Num)
        {
            TechData  TechList = new TechData();
            ForPaging page     = new ForPaging(1);

            TechList.Search       = Num;
            TechList.StockList    = financeService.getStockList(page, Num.ToString());
            TechList.VoucherList  = financeService.getVoucher(Num.ToString());
            TechList.CYQList      = financeService.getCYQ(Num.ToString());
            TechList.MonetaryList = CurrencyService.getMonetaryList();
            TechList.LiborList    = CurrencyService.getLiborList();
            TechList.CRB_BDIList  = financeService.getCRB_BDI();

            return(View(TechList));
        }
        public List <Message> GetDataList(ForPaging paging, string search)
        {
            //設定要接受全部搜尋資料的物件
            IQueryable <Message> searchData;

            if (String.IsNullOrEmpty(search))
            {
                searchData = GetAllDataList(paging);
            }
            else
            {
                searchData = GetAllDataList(paging, search);
            }
            return(searchData.OrderByDescending(p => p.MId)
                   .Skip((paging.NowPage - 1) * paging.ItemNum)
                   .Take(paging.ItemNum).ToList());
        }
Exemple #3
0
        public List <Guestbooks> GetDataList(ForPaging Paging, string Search)
        {
            List <Guestbooks> DataList = new List <Guestbooks>();

            if (!string.IsNullOrWhiteSpace(Search))
            {
                //有搜尋條件時
                SetMaxPaging(Paging, Search);
                DataList = GetAllDataList(Paging, Search);
            }
            else
            {
                //無搜尋條件時
                SetMaxPaging(Paging);
                DataList = GetAllDataList(Paging);
            }

            return(DataList);
        }
Exemple #4
0
        //無搜尋值的設定最大頁數方法
        public void SetMaxPaging(ForPaging Paging)
        {
            //計算列數
            int Row = 0;
            //Sql語法
            string sql = $@" select * from Guestbooks ";

            try
            {
                //開啟資料庫連線
                conn.Open();
                //執行Sql指令
                SqlCommand cmd = new SqlCommand(sql, conn);
                //取得Sql資料
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read()) //獲得下一筆資料直到沒有資料
                {
                    Row++;
                }
            }
            catch (Exception e)
            {
                //丟出錯誤
                throw new Exception(e.Message.ToString());
            }
            finally
            {
                //關閉資料庫連線
                conn.Close();
            }

            //計算所需的總頁數
            Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Row) / Paging.ItemNum));
            //重新設定正確的頁數,避免有不正確值傳入
            Paging.SetRightPage();
        }
Exemple #5
0
        public List <Reply> GetDataList(ForPaging paging, int mId)
        {
            IQueryable <Reply> SearchData = GetAllDataList(paging, mId);

            return(SearchData.OrderByDescending(p => p.MId).Skip((paging.NowPage - 1) * paging.ItemNum).Take(paging.ItemNum).ToList());
        }
Exemple #6
0
 //包含搜尋值的搜尋資料方法
 public IQueryable <Invoices> GetAllDataList(ForPaging Paging, string Search, string DateSearch, string sortOrder)
 {
     //三個搜尋值都不為空
     if (!String.IsNullOrEmpty(DateSearch) && !String.IsNullOrEmpty(Search) && !String.IsNullOrEmpty(sortOrder))
     {
         IQueryable <Invoices> Data = db.Invoices
                                      .Where((p => p.InvoicesNum.Equals(Search) && p.InvoicesDate.Contains(DateSearch) && p.Status == true));
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }
     //datesearch=nuull
     else if (!String.IsNullOrEmpty(Search) && String.IsNullOrEmpty(DateSearch) && !String.IsNullOrEmpty(sortOrder))
     {
         //根據搜尋值來搜尋資料
         IQueryable <Invoices> Data = db.Invoices
                                      .Where(p => p.InvoicesNum.Equals(Search) && p.Status == true);
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }//sortOrder=null
     else if (!String.IsNullOrEmpty(Search) && !String.IsNullOrEmpty(DateSearch) && String.IsNullOrEmpty(sortOrder))
     {
         IQueryable <Invoices> Data = db.Invoices
                                      .Where(p => p.InvoicesNum.Equals(Search) && p.InvoicesDate.Contains(DateSearch) && p.Status == false);
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }//date&project=null
     else if (!String.IsNullOrEmpty(Search) && String.IsNullOrEmpty(DateSearch) && String.IsNullOrEmpty(sortOrder))
     {
         IQueryable <Invoices> Data = db.Invoices
                                      .Where(p => p.InvoicesNum.Equals(Search) && p.Status == false);
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }//search&project=null
     else if (String.IsNullOrEmpty(Search) && !String.IsNullOrEmpty(DateSearch) && String.IsNullOrEmpty(sortOrder))
     {
         IQueryable <Invoices> Data = db.Invoices
                                      .Where(p => p.InvoicesDate.Contains(DateSearch) && p.Status == false);
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }//sreach&datesearch=null
     else if (String.IsNullOrEmpty(Search) && String.IsNullOrEmpty(DateSearch) && !String.IsNullOrEmpty(sortOrder))
     {
         IQueryable <Invoices> Data = db.Invoices
                                      .Where(p => p.Status == true);
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }//search=null
     else if (String.IsNullOrEmpty(Search) && !String.IsNullOrEmpty(DateSearch) && !String.IsNullOrEmpty(sortOrder))
     {
         IQueryable <Invoices> Data = db.Invoices
                                      .Where(p => p.InvoicesDate.Contains(DateSearch) && p.Status == true);
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }
     //無其他搜尋值,且未開立發票
     else
     {
         //宣告要回傳的搜尋資料為資料庫中的Guestbooks資料表
         IQueryable <Invoices> Data = db.Invoices
                                      .Where(p => p.Status == false);
         //計算所需的總頁數
         Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Data.Count()) / Paging.ItemNum));
         //重新設定正確的頁數,避免有不正確值傳入
         Paging.SetRightPage();
         //回傳搜尋資料
         return(Data);
     }
 }