コード例 #1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            DialogResult        result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    BLL.DeviceDataBLL bll       = new BLL.DeviceDataBLL();
                    DataTable         table     = bll.Query(this.comboBox1.SelectedValue.ToString(), this.comboBox2.SelectedValue.ToString(), this.comboBox3.SelectedValue.ToString(), this.comboBox4.SelectedValue.ToString(), this.dateTimePicker1.Value.ToString("yyyy-MM-dd"), this.dateTimePicker2.Value.ToString("yyyy-MM-dd"), txtDeviceValue.Text, this.comboBox5.SelectedIndex);
                    byte[]            byteArray = Office.ExcelExport.StreamExport(table, null);
                    string            name      = dialog.SelectedPath + "\\导出数据.xls";
                    FileStream        fs        = File.Open(name, FileMode.Create);
                    fs.Write(byteArray, 0, byteArray.Length);
                    fs.Flush();
                    fs.Close();
                    MessageBox.Show("导出完成");
                    System.Diagnostics.Process.Start("Explorer.exe", dialog.SelectedPath);
                }
                catch (Exception ex)
                {
                }
            }
        }
コード例 #2
0
        void bindData()
        {
            BLL.DeviceDataBLL bll   = new BLL.DeviceDataBLL();
            DataTable         table = bll.Query(this.comboBox1.SelectedValue.ToString(), this.comboBox2.SelectedValue.ToString(), this.comboBox3.SelectedValue.ToString(), this.comboBox4.SelectedValue.ToString(), this.dateTimePicker1.Value.ToString("yyyy-MM-dd"), this.dateTimePicker2.Value.ToString("yyyy-MM-dd"), txtDeviceValue.Text, this.comboBox5.SelectedIndex);

            this.dataGridView1.DataSource = table;
        }