示例#1
0
        //载入窗体
        private void datereport_Load(object sender, EventArgs e)
        {
            string sComboData;

            try
            {
                if (loading.ibb_flag == "1")
                {
                    DbHelper = new MyDbHelper(MyDbHelper.connectstring_cardqs);
                    OleDbDataReader dbReader = DbHelper.ExecuteDataReader("select * from report where report_type!='0' order by proc_name ");
                    while (dbReader.Read())
                    {
                        sComboData = dbReader.GetString(0).ToString().Trim() + " - " + dbReader.GetString(1).ToString().Trim();
                        combo.Items.Add((object)sComboData);
                    }
                }
                else if (loading.ibb_flag == "2")
                {
                    DbHelper = new MyDbHelper(MyDbHelper.connectstring_cardqs);
                    OleDbDataReader dbReader = DbHelper.ExecuteDataReader("select * from report_xft where report_type!='0' order by report_num ");
                    while (dbReader.Read())
                    {
                        sComboData = dbReader.GetString(0).ToString().Trim() + " - " + dbReader.GetString(1).ToString().Trim();
                        combo.Items.Add((object)sComboData);
                    }
                }
                else if (loading.ibb_flag == "3")
                {
                    DbHelper = new MyDbHelper(MyDbHelper.connectstring_prec);
                    OleDbDataReader dbReader = DbHelper.ExecuteDataReader("select * from report_bf where report_type!='0' order by report_num ");
                    while (dbReader.Read())
                    {
                        sComboData = dbReader.GetString(0).ToString().Trim() + " - " + dbReader.GetString(1).ToString().Trim();
                        combo.Items.Add((object)sComboData);
                    }
                }
            }
            catch (Exception ex)
            {
                MyLog.Log("3", "向combox读取数据失败:" + ex.Message);
            }
            finally
            {
                if (DbHelper != null)
                {
                    DbHelper.Dispose();//新加的
                }
            }
        }
示例#2
0
 public void RunProcedure_one(string sProcName, string ddate)
 {
     try
     {
         MyDbHelper       DbHelper = new MyDbHelper(MyDbHelper.connectstring_cardqs);
         OleDbParameter[] sqlparam = new OleDbParameter[2];
         sqlparam[0] = MyDbHelper.MakeInParam("ddate", OleDbType.Char, 8, ddate);
         sqlparam[1] = MyDbHelper.MakeOutParam("ret", OleDbType.Char, 200, null);
         DbHelper.ExecuteNonQuery(sProcName.Trim(), sqlparam, true);
     }
     catch (Exception ex)
     {
         MyLog.Log("3", "执行单日期" + sProcName + "存储过程流程时发生异常:" + ex.Message);
     }
     finally
     {
         if (DbHelper != null)
         {
             DbHelper.Dispose();//新加的
         }
     }
 }
示例#3
0
 public void RunProcedure(string sProcName, string beginDate, string endDate, string constr)
 {
     try
     {
         MyDbHelper       DbHelper = new MyDbHelper(constr);
         OleDbParameter[] sqlparam = new OleDbParameter[3];
         sqlparam[0] = MyDbHelper.MakeInParam("date1", OleDbType.Char, 8, beginDate);
         sqlparam[1] = MyDbHelper.MakeInParam("date2", OleDbType.Char, 8, endDate);
         sqlparam[2] = MyDbHelper.MakeOutParam("ret", OleDbType.Char, 200, null);
         DbHelper.ExecuteNonQuery(sProcName.Trim(), sqlparam, true);
     }
     catch (Exception ex)
     {
         MyLog.Log("3", "执行双日期" + sProcName + "存储过程流程时发生异常:" + ex.Message);
     }
     finally
     {
         if (DbHelper != null)
         {
             DbHelper.Dispose();//新加的
         }
     }
 }
示例#4
0
        private DataTable CreateDataSet(string sTable, string constr)
        {
            DataTable table = null;

            try
            {
                DbHelper = new MyDbHelper(constr);
                string strsql = "select * from " + sTable + "";
                table = DbHelper.ExecuteDataTable(sTable, strsql);
            }
            catch (Exception ex)
            {
                MyLog.Log("3", "读取数据失败:" + ex.Message);
            }
            finally
            {
                if (DbHelper != null)
                {
                    DbHelper.Dispose();//新加的
                }
            }
            return(table);
        }
示例#5
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            reflow_control r_con = new reflow_control();
            string         reportNum, beginDate, endDate;

            //根据列表中报表编号找到对应的数据库表中数据表名,模板名,SHEET名
            string sTableName  = "";
            string sModelName  = "";
            string sSheetName  = "";
            string sReportName = "";
            string sProcName   = "";

            int iRowNum = listView.Items.Count;

            //进度条代码
            proBar.Value   = 0;
            proBar.Maximum = iRowNum * 10;
            proBar.Step    = 1;
            for (int i = 0; i < iRowNum; i++)
            {
                beginDate = listView.Items[i].SubItems[1].Text.Trim();
                endDate   = listView.Items[i].SubItems[2].Text.Trim();
                reportNum = listView.Items[i].SubItems[0].Text.Substring(0, 2);
                string strCmd = "";
                try
                {
                    string constr = "";
                    if (loading.ibb_flag == "1")
                    {
                        strCmd = "select * from report where REPORT_NUM = " + reportNum;
                        constr = MyDbHelper.connectstring_cardqs;
                    }
                    else if (loading.ibb_flag == "2")
                    {
                        strCmd = "select * from report_xft where REPORT_NUM = " + reportNum;
                        constr = MyDbHelper.connectstring_cardqs;
                    }
                    else if (loading.ibb_flag == "3")
                    {
                        strCmd = "select * from report_bf where REPORT_NUM = " + reportNum;
                        constr = MyDbHelper.connectstring_prec;
                    }

                    DbHelper = new MyDbHelper(constr);
                    OleDbDataReader dbReader = DbHelper.ExecuteDataReader(strCmd);
                    if (dbReader.Read())
                    {
                        sTableName  = dbReader.GetString(4).ToString();
                        sModelName  = dbReader.GetString(2).ToString();
                        sSheetName  = dbReader.GetString(3).ToString();
                        sReportName = dbReader.GetString(1).ToString();
                        sProcName   = dbReader.GetString(5).ToString();
                    }
                    try
                    {
                        r_con.RunProcedure(sProcName.Trim(), beginDate, endDate, constr);
                    }
                    catch (Exception errorRunPro)
                    {
                        MessageBox.Show(errorRunPro.ToString());
                    }
                    //写EXCEL文件
                    r_con.WriteExcelFile(sModelName, sTableName, sSheetName, beginDate, endDate, constr);//将表中内容放入EXCEL
                    listView.Items[i].SubItems[3].Text = "完成统计";
                    proBar.Value = (i + 1) * 10;
                }

                catch (Exception ex)
                {
                    MyLog.Log("3", "读取数据失败:" + ex.Message);
                }
                finally
                {
                    if (DbHelper != null)
                    {
                        DbHelper.Dispose();//新加的
                    }
                }
            }
        }