protected void btn_Search_Click(object sender, EventArgs e) { try { bool isVerify = false; var selectType = int.Parse(DDL_Type.SelectedValue); var shipDa = new POS_Library.ShopPos.ShipInDA(); var posTickets = shipDa.PosTickets(isVerify, selectType, _areaId); int si = 1; var temp = posTickets.OrderByDescending(x => x.TicketDate).Select(x => new { 序號 = si++, 傳票ID = x.TicketId, 箱號 = x.TicketBox, 出貨日期 = x.TicketDate.ToString("yyyy-MM-dd"), 收貨者 = x.Consignee, 驗貨者 = x.VerifyAccount, 類型 = x.TicketType == 0 ? "進貨" : x.TicketType == 2?"調入":"不知名", 功能 = "", TicketType = x.TicketType, }).ToList(); gv_List.DataSource = temp; gv_List.DataBind(); } catch (Exception ex) { Response.Write("系統發生錯誤 " + ex.Message); } }
public void Search() { try { var temp = new List <POS_Library.ShopPos.DataModel.ImportClass.TicketDetailModel>(); if (!string.IsNullOrEmpty(box)) { var shipDa = new POS_Library.ShopPos.ShipInDA(); temp = shipDa.GetPosBoxDetail(box, areaId); } else if (ticketId != 0) { var shipDa = new POS_Library.ShopPos.ShipOutDA(); temp = shipDa.GetTicketDetail(ticketId, areaId, false, true); } int x = 1; var temp2 = (from i in temp select new { 序號 = x++, 傳票ID = i.TicketId, 產品編號 = i.ProductId, 數量 = i.Quantity }).ToList(); gv_List.DataSource = temp2; gv_List.DataBind(); var 總筆數 = temp2.Count; var 傳票數 = temp2.Select(y => y.傳票ID).Distinct().Count(); var 總件數 = temp2.Sum(y => y.數量); lbl_Count.Text = "總筆數: " + 總筆數 + ", 傳票數: " + 傳票數 + ", 總件數: " + 總件數; } catch (Exception ex) { lbl_Count.Text = ex.Message; } }