Exemplo n.º 1
0
        /// <summary>
        /// XLS
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Xls_Click(object sender, EventArgs e)
        {
            paging = false;
            //先查詢
            btn_查詢_Click(sender, e);

            #region 設定

            var xls_filename = string.Format("{0}_庫存報表_【{1}筆】", DateTime.Now.ToString("yyyy-MMdd"), gv_List.Rows.Count);

            CreateXLS    CX       = new CreateXLS();
            HSSFWorkbook workbook = new HSSFWorkbook();
            MemoryStream ms       = new MemoryStream();

            //要輸出的欄位
            int[] list = { };

            #endregion

            //呼叫產生XLS
            CX.DoCreateXLS(workbook, ms, list.ToList(), gv_List, false, "");

            //輸出
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename=" + HttpUtility.UrlEncode(xls_filename, System.Text.Encoding.UTF8) + ".xls"));
            Response.BinaryWrite(ms.ToArray());
            workbook = null;
            ms.Close();
            ms.Dispose();
        }
Exemplo n.º 2
0
        /// <summary>
        /// CreateXLS
        /// </summary>
        protected void CreateXLS(string SearchFileName)
        {
            #region 設定

            //檔名
            string xls_filename;
            xls_filename = SearchFileName;

            CreateXLS    CX       = new CreateXLS();
            HSSFWorkbook workbook = new HSSFWorkbook();
            MemoryStream ms       = new MemoryStream();

            //要輸出的欄位
            int[] list = { };

            #endregion

            //呼叫產生XLS
            CX.DoCreateXLS(workbook, ms, list.ToList(), gv_logistics, false, "");

            //輸出
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename=" + HttpUtility.UrlEncode(xls_filename, System.Text.Encoding.UTF8) + ".xls"));
            Response.BinaryWrite(ms.ToArray());
            workbook = null;
            ms.Close();
            ms.Dispose();
        }
Exemplo n.º 3
0
        /// <summary>
        /// CreateXLS
        /// </summary>
        protected void CreateXLS()
        {
            #region 設定

            //檔名
            string xls_typeName, xls_date, xls_filename;

            xls_date = DateTime.Today.ToString("yyyy-MMdd");

            xls_typeName = "TW差異處理";
            xls_filename = xls_date + "_" + xls_typeName;

            CreateXLS    CX       = new CreateXLS();
            HSSFWorkbook workbook = new HSSFWorkbook();
            MemoryStream ms       = new MemoryStream();

            //要輸出的欄位
            int[] list = { };

            #endregion 設定

            if (gv_List.Rows.Count > 0)
            {
                foreach (GridViewRow i in gv_List.Rows)
                {
                    var tempCell = GetCellByName(i, "傳票");
                    System.Web.UI.WebControls.HyperLink HL = tempCell.FindControl("TicketId") as System.Web.UI.WebControls.HyperLink;
                    tempCell.Text = HL.Text;
                }

                //呼叫產生XLS
                CX.DoCreateXLS(workbook, ms, list.ToList(), gv_List, false, "");

                //輸出
                Response.AddHeader("Content-Disposition", string.Format("attachment; filename=" + HttpUtility.UrlEncode(xls_filename, System.Text.Encoding.UTF8) + ".xls"));
                Response.BinaryWrite(ms.ToArray());
                workbook = null;
                ms.Close();
                ms.Dispose();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 產生報表SKU明細XLS
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Xls2_Click(object sender, EventArgs e)
        {
            //清空gv
            gv_Report.DataSource = "";
            gv_Report.DataBind();

            //先查詢系列(為了過濾銷售總數)
            SearchFirst();

            var temp系列 = sp.GetSaleReportBySerial(ShelfId, SerialId, ProductId, SDay, EDay, int.Parse(SearchType), WithoutDate).ToList();

            var temp2系列 = (from i in temp系列
                           where ((DDL_SaleRange.SelectedValue == "0") ? i.銷售 == 0 :
                                  (DDL_SaleRange.SelectedValue == "1") ? i.銷售 >= 1 && i.銷售 <= 10 :
                                  (DDL_SaleRange.SelectedValue == "2") ? i.銷售 >= 10 && i.銷售 <= 20 :
                                  (DDL_SaleRange.SelectedValue == "3") ? i.銷售 >= 20 && i.銷售 <= 30 :
                                  (DDL_SaleRange.SelectedValue == "4") ? i.銷售 >= 30 && i.銷售 <= 50 :
                                  (DDL_SaleRange.SelectedValue == "5") ? i.銷售 >= 50 : true)
                           &&
                           (!CB_過濾在途回途.Checked || (i.回途庫存 == 0 && i.在途庫存 == 0))
                           select new
            {
                系列編號 = i.系列編號,
            }).ToList();

            //再查詢產品並join出所需系列
            var tempSKU = sp.GetSaleReportByProduct(ShelfId, SerialId, ProductId, SDay, EDay, int.Parse(SearchType), WithoutDate).ToList();

            int x        = 1;
            var temp2SKU = (from i in temp2系列
                            join ii in tempSKU on i.系列編號 equals ii.系列編號
                            where (!CB_過濾在途回途.Checked || (ii.回途庫存 == 0 && ii.在途庫存 == 0))
                            select new
            {
                序號 = x++,
                系列編號 = ii.系列編號,
                型號 = ii.型號,
                品名 = ii.品名,
                顏色 = ii.顏色,
                尺寸 = ii.尺寸,
                展售庫存 = ii.展售庫存,
                補貨庫存 = ii.補貨庫存,
                一般庫存 = ii.一般庫存,
                暫存庫存 = ii.暫存庫存,
                在途庫存 = ii.在途庫存,
                回途庫存 = ii.回途庫存,
                瑕疵庫存 = ii.瑕疵庫存,
                銷售 = ii.銷售,
                售價 = ii.售價,
                架日 = ii.架日 ?? "無",
            }).ToList();

            gv_Report.DataSource = temp2SKU;
            gv_Report.DataBind();

            #region 設定

            var xls_filename = string.Format("{0}_{1}_【{2}筆】", DateTime.Now.ToString("yyyy-MMdd") + "-【" + HandleStartDate + "~" + HandleEndDate + "】"
                                             , DDL_SearchType.SelectedItem.Text, gv_Report.Rows.Count);

            CreateXLS    CX       = new CreateXLS();
            HSSFWorkbook workbook = new HSSFWorkbook();
            MemoryStream ms       = new MemoryStream();

            //要輸出的欄位
            int[] list = { };

            #endregion

            //呼叫產生XLS
            CX.DoCreateXLS(workbook, ms, list.ToList(), gv_Report, false, "");

            //輸出
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename=" + HttpUtility.UrlEncode(xls_filename, System.Text.Encoding.UTF8) + ".xls"));
            Response.BinaryWrite(ms.ToArray());
            workbook = null;
            ms.Close();
            ms.Dispose();
        }