Esempio n. 1
0
        private void btnImportSelect_Click(object sender, EventArgs e)
        {
            string strPIDs = "";

            foreach (DataGridViewRow dr in dgvListData.Rows)
            {
                if (dr.Cells[0].Value != null && Convert.ToBoolean(dr.Cells[0].Value))
                {
                    strPIDs += ",'" + ((DataGridViewCell)dr.Cells["Idx"]).Value.ToString() + "'";
                }
            }

            strPIDs = strPIDs.TrimStart(',');

            if (strPIDs == "")
            {
                MessageBox.Show("请选择要导出的数据!", "温馨提示:");
                return;
            }

            By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType);
            frm.bIsSetExportFileds = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string excelname = System.Windows.Forms.Application.StartupPath + "\\Excel\\pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";

                DataTable dt = PtDataHelper.getPtData(string.Format("a1.ztid={0} and a1.sid in ({1})", ztid, strPIDs), "", 1, nPageSize, strDbType);
                NPOIHelper.Export(dt, excelname, "专利数据", "");

                if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("explorer", "/select," + excelname);
                }
            }
        }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType);
     if (frm.ShowDialog() == DialogResult.OK)
     {
         btnQuery_Click(sender, e);
     }
 }
Esempio n. 3
0
        private void btnOutput_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show(string.Format("请选择要导出的数据库!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DataGridViewRow datarow = dataGridView1.SelectedRows[0];
            string          name    = (datarow.Cells["name"].Value == null ? "" : datarow.Cells["name"].Value.ToString());
            string          des     = (datarow.Cells["des"].Value == null ? "" : datarow.Cells["des"].Value.ToString());
            string          type    = (datarow.Cells["type"].Value == null ? "CPRS" : datarow.Cells["type"].Value.ToString());
            int             id      = Convert.ToInt32(datarow.Cells["Id"].Value.ToString());
            int             nPtNum  = datarow.Cells["app_sum"].Value == null ? 0 : Convert.ToInt32(datarow.Cells["app_sum"].Value.ToString());

            if (nPtNum == 0)
            {
                MessageBox.Show(string.Format("您选择的专利库中没有数据可以导出!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            By.frmSetShowFiles frm = new By.frmSetShowFiles(type.ToUpper());
            frm.bIsSetExportFileds = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string excelname = "";

                SaveFileDialog saveDlg = new SaveFileDialog();
                saveDlg.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\Excel";
                saveDlg.Filter           = "Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx";
                saveDlg.FileName         = "pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
                if (saveDlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string strFileName  = saveDlg.FileName.Substring(0, saveDlg.FileName.LastIndexOf('.'));;
                string strExtension = saveDlg.FileName.Substring(saveDlg.FileName.LastIndexOf('.'));

                int nSplitFlag = 10000; //拆分文件,每x条数据导出一个excel文件;

                for (int nIdx = 1; (nIdx - 1) * nSplitFlag < nPtNum; nIdx++)
                {
                    excelname = nPtNum > nSplitFlag ? strFileName + "_" + nIdx.ToString() + strExtension : strFileName + "" + strExtension;

                    DataTable dt = PtDataHelper.getPtData(string.Format("a1.ztid={0}", id), "", nIdx, nSplitFlag, type.ToUpper());
                    if (dt != null)
                    {
                        dt.Columns.Remove("sid");
                    }
                    ExcelLib.NPOIHelper.Export(dt, excelname, "专利数据", "");
                }

                if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("explorer", "/select," + excelname);
                }
            }
        }
Esempio n. 4
0
        private void btnImportSelect_Click(object sender, EventArgs e)
        {
            string strPIDs = "";

            foreach (DataGridViewRow dr in dgvListData.Rows)
            {
                if (dr.Cells[0].Value != null && Convert.ToBoolean(dr.Cells[0].Value))
                {
                    strPIDs += ",'" + ((DataGridViewCell)dr.Cells["Idx"]).Value.ToString() + "'";
                }
            }

            strPIDs = strPIDs.TrimStart(',');

            if (strPIDs == "")
            {
                MessageBox.Show("请选择要导出的数据!", "温馨提示:");
                return;
            }

            By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType);
            frm.bIsSetExportFileds = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string excelname = "";

                saveFileDialog1.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\Excel";
                saveFileDialog1.Filter           = "Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx";
                saveFileDialog1.FileName         = "pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
                if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                excelname = saveFileDialog1.FileName;

                //DataTable dt = PtDataHelper.getPtData(string.Format(",fun_filter f1 where a1.ztid={0} and a1.sid in ({1}) and a1.sid=f1.sid ", strZtID, strPIDs), "", 1, nPageSize, strDbType);
                string strWhereTmp = string.IsNullOrEmpty(strfilterSql) ? string.Format(" where a1.ztid={0} and a1.sid in ({1}) ", strZtID, strPIDs) :
                                     string.Format(",({1}) f1 where a1.ztid={0} and a1.sid in ({2}) and a1.sid=f1.sid", strZtID, strfilterSql, strPIDs);
                DataTable dt = PtDataHelper.getPtData(strWhereTmp, "", 1, nPageSize, strDbType);
                if (dt != null)
                {
                    dt.Columns.Remove("sid");
                }
                NPOIHelper.Export(dt, excelname, "专利数据", "");

                if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("explorer", "/select," + excelname);
                }
            }
        }
Esempio n. 5
0
        private void btnOutput_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show(string.Format("请选择要导出的数据库!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DataGridViewRow datarow = dataGridView1.SelectedRows[0];
            string name = (datarow.Cells["name"].Value == null ? "" : datarow.Cells["name"].Value.ToString());
            string des = (datarow.Cells["des"].Value == null ? "" : datarow.Cells["des"].Value.ToString());
            string type = (datarow.Cells["type"].Value == null ? "CPRS" : datarow.Cells["type"].Value.ToString());
            int id = Convert.ToInt32(datarow.Cells["Id"].Value.ToString());
            int nPtNum = datarow.Cells["app_sum"].Value == null ? 0 : Convert.ToInt32(datarow.Cells["app_sum"].Value.ToString());

            if (nPtNum == 0)
            {
                MessageBox.Show(string.Format("您选择的专利库中没有数据可以导出!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            By.frmSetShowFiles frm = new By.frmSetShowFiles(type.ToUpper());
            frm.bIsSetExportFileds = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string excelname = "";

                SaveFileDialog saveDlg = new SaveFileDialog();
                saveDlg.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\Excel";
                saveDlg.Filter = "Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx";
                saveDlg.FileName = "pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
                if (saveDlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string strFileName = saveDlg.FileName.Substring(0, saveDlg.FileName.LastIndexOf('.')); ;
                string strExtension = saveDlg.FileName.Substring(saveDlg.FileName.LastIndexOf('.'));

                int nSplitFlag = 10000; //拆分文件,每x条数据导出一个excel文件;

                for (int nIdx = 1; (nIdx - 1) * nSplitFlag < nPtNum; nIdx++)
                {
                    excelname = nPtNum > nSplitFlag ? strFileName + "_"+nIdx.ToString() + strExtension : strFileName + "" + strExtension;

                    DataTable dt = PtDataHelper.getPtData(string.Format("a1.ztid={0}", id), "", nIdx, nSplitFlag, type.ToUpper());
                    if (dt != null)
                    {
                        dt.Columns.Remove("sid");
                    }
                    ExcelLib.NPOIHelper.Export(dt, excelname, "专利数据", "");
                }

                if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("explorer", "/select," + excelname);
                }
            }
        }
Esempio n. 6
0
        private void btnImportSelect_Click(object sender, EventArgs e)
        {
            string strPIDs = "";
            foreach (DataGridViewRow dr in dgvListData.Rows)
            {
                if (dr.Cells[0].Value != null && Convert.ToBoolean(dr.Cells[0].Value))
                {
                    strPIDs += ",'" + ((DataGridViewCell)dr.Cells["Idx"]).Value.ToString() + "'";

                }
            }

            strPIDs = strPIDs.TrimStart(',');

            if (strPIDs == "")
            {
                MessageBox.Show("请选择要导出的数据!", "温馨提示:");
                return;
            }

            By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType);
            frm.bIsSetExportFileds = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string excelname = "";

                saveFileDialog1.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\Excel";
                saveFileDialog1.Filter = "Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx";
                saveFileDialog1.FileName = "pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
                if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                excelname = saveFileDialog1.FileName;

                //DataTable dt = PtDataHelper.getPtData(string.Format(",fun_filter f1 where a1.ztid={0} and a1.sid in ({1}) and a1.sid=f1.sid ", strZtID, strPIDs), "", 1, nPageSize, strDbType);
                string strWhereTmp = string.IsNullOrEmpty(strfilterSql) ? string.Format(" where a1.ztid={0} and a1.sid in ({1}) ", strZtID, strPIDs) :
                            string.Format(",({1}) f1 where a1.ztid={0} and a1.sid in ({2}) and a1.sid=f1.sid", strZtID, strfilterSql, strPIDs);
                DataTable dt = PtDataHelper.getPtData(strWhereTmp, "", 1, nPageSize, strDbType);
                if (dt != null)
                {
                    dt.Columns.Remove("sid");
                }
                NPOIHelper.Export(dt, excelname, "专利数据", "");

                if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("explorer", "/select," + excelname);

                }
            }
        }
Esempio n. 7
0
 private void button1_Click(object sender, EventArgs e)
 {
     By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType);
     if (frm.ShowDialog() == DialogResult.OK)
     {
         btnQuery_Click(sender, e);
     }
 }
Esempio n. 8
0
        private void btnImportSelect_Click(object sender, EventArgs e)
        {
            string strPIDs = "";
            foreach (DataGridViewRow dr in dgvListData.Rows)
            {
                if (dr.Cells[0].Value != null && Convert.ToBoolean(dr.Cells[0].Value))
                {
                    strPIDs += ",'" + ((DataGridViewCell)dr.Cells["Idx"]).Value.ToString() + "'";

                }
            }

            strPIDs = strPIDs.TrimStart(',');

            if (strPIDs == "")
            {
                MessageBox.Show("请选择要导出的数据!", "温馨提示:");
                return;
            }

            By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType);
            frm.bIsSetExportFileds = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string excelname = System.Windows.Forms.Application.StartupPath + "\\Excel\\pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";

                DataTable dt = PtDataHelper.getPtData(string.Format("a1.ztid={0} and a1.sid in ({1})", ztid, strPIDs), "", 1, nPageSize, strDbType);
                NPOIHelper.Export(dt, excelname, "专利数据", "");

                if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("explorer", "/select," + excelname);

                }
            }
        }