Пример #1
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     DataTable dt = (DataTable)dgvbtdj.DataSource;
     Common.DataProces toexcel = new Common.DataProces();
     toexcel.DataTableToExcel(dt, true);
 }
Пример #2
0
 private void btnToEx_Click(object sender, EventArgs e)
 {
     string Cycle = string.Empty;
     string town = string.Empty;
     string townn = string.Empty;
     string group = " group by a.ACCOUNTNUM,a.SSSSOBJECTNAME,d.GH,a.SSSSIDCARDNUM order by a.ACCOUNTNUM DESC,d.GH";
     string batch = "null";
     string bank = cmbBank.SelectedValue.ToString();
     if (cmbbatch.Text != null && cmbbatch.Text != "")
     {
         batch = cmbbatch.SelectedValue.ToString();
     }
     if (checkBox1.Checked)
     {
         town = "  AND INSTR(c.OBJECTCODE,'" + cmbTown.SelectedValue.ToString() + "')>0";
         townn = "乡镇:" + cmbTown.Text.ToString();
     }
     if (cmbCycle.SelectedValue.ToString() == "3")
     {
         Cycle = " and c.OFFSET='" + cmbbatch.SelectedValue.ToString() + "'";
     }
     if (cmbCycle.SelectedValue.ToString() == "4")
     {
         Cycle = " and c.batchcode='" + cmbbatch.SelectedValue.ToString() + "'";
     }
     if (lbselect.Items.Count > 0)
     {
         string sqlstr = string.Empty;
         for (int i = 0; i < this.lbselect.Items.Count; i++)
         {
             lbselect.SelectedIndex = i;
             sqlstr = sqlstr + "," + lbselect.SelectedValue.ToString();
         }
         sqlstr = sqlstr.Substring(1);
         DataTable dv = Common.DataProces.OutPutTable(B_sjdc.ExpToEx(" and c.TYPECODE in (" + sqlstr + ")" + Cycle.ToString() + " and c.FSYEAR=" + DateTime.Now.Year + town.ToString() + " and bankcode='" + bank.ToString() + "'" + group.ToString()).Tables[0]);
         Common.DataProces toexcel = new Common.DataProces();
             toexcel.DataTableToExcel(dv, true);
             label4.Text = "共导出" + dv.Rows.Count.ToString() + "条记录!";
     }
     else
     {
         MessageBox.Show("请选择补贴类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }