예제 #1
0
    }//ButtonQuery_Click			

    protected void btnExport_Click(object sender, EventArgs e)
    {
        try
        {
            STMModel.MaintainStoreChain BCO = new STMModel.MaintainStoreChain(ConntionDB);
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "ENABLE", "1", "=", "and");
            DataTable Dt = BCO.QueryStoreChainByFind_1(ParameterList);
            if (Dt.Columns["ID"] != null) Dt.Columns.Remove("ID");
            if (Dt.Columns["ENABLE"] != null) Dt.Columns.Remove("ENABLE");
            foreach (DataRow dr in Dt.Rows)
            {
                for (int i = 0; i < Dt.Columns.Count; i++)
                {
                    if (Dt.Columns[i].DataType == Type.GetType("System.String"))
                    {
                        dr[i] = string.Format("&nbsp;{0}", dr[i].ToString());
                    }
                }
            }
            Export(System.Text.Encoding.UTF8, "通路基本檔_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls", "application/ms-excel", Dt);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { }
    }
예제 #2
0
    /// <summary>
    /// 查詢資料庫取得資料
    /// </summary>
    private void databind()
    {
        //抓取本頁初次登記的時間
        string SessionIDName = "STM101_" + PageTimeStamp.Value;

        STMModel.MaintainStoreChain BCO = new STMModel.MaintainStoreChain(ConntionDB);

        DataTable Dt = BCO.QueryStoreChainByFind_1(ParameterList);

        if (Dt.Rows.Count == 0)
        {
            ErrorMsgLabel.Text = "查無資料";
        }

        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;
        Session["STM10"] = Dt;
        //設定分頁大小
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();
    }