예제 #1
0
        private DataTable GetResultByQuery(string query, SqlConnection conn)
        {
            DataTable      dataTable = new DataTable();
            SqlDataAdapter da        = null;

            try
            {
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.CommandTimeout = 0;
                conn.Open();
                LogGenerator.AppendLog(query, LogType.SQLQuery, this);
                da = new SqlDataAdapter(cmd);

                da.Fill(dataTable);
                da.Dispose();
            }
            catch (Exception ex)
            {
                LogGenerator.AppendLog(ex.StackTrace, LogType.Exception, this);
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(dataTable);
        }
예제 #2
0
        public void CreateExcel(string templateFileName, string savePath, SheetItems items)
        {
            Excel.Application excel    = null;
            Excel.Workbook    workbook = null;

            try
            {
                excel    = new Excel.Application();
                workbook = excel.Workbooks.Open(System.Windows.Forms.Application.StartupPath + "\\ReportTemplate\\" + templateFileName);

                LogGenerator.AppendLog("Excel Generate " + items.Name, LogType.Common, this);
                GenerateReport(workbook, items);
                workbook.SaveAs(savePath);
            }
            catch (Exception ex)
            {
                LogGenerator.AppendLog(ex.StackTrace, LogType.Exception, this);
                MessageBox.Show(ex.Message);
            }
            finally
            {
                workbook.Close(false);
                ReleaseObject(ref workbook);
                excel.Quit();
                ReleaseObject(ref excel);
            }
        }