Beispiel #1
0
        /*******************************************************************************************************************\
        *                                                                                                                 *
        \*******************************************************************************************************************/

        private void export_csv(bool crew_)
        {
            string filename = "payDirtStaff";

            if (crew_)
            {
                filename = "payDirtCrew";
            }

            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + filename + ".csv";


            try
            {
                if (System.Windows.Forms.SystemInformation.TerminalServerSession)
                {
                    if (Gap.Path.Equals("<none>"))
                    {
                        Gap.SetPath(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                    }


                    fbdCSV.SelectedPath = Gap.Path;
                    DialogResult ok = fbdCSV.ShowDialog();

                    if (ok == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }

                    //string folder = fbdCSV.SelectedPath;
                    //string path = folder + @"\myFile.csv";
                    string path = fbdCSV.SelectedPath;

                    string fname = filename + "-" + DateTime.Now.ToString("yyMMdd") + ".csv";

                    if (crew_)
                    {
                        filePath = make_csv_crew(path, fname);
                    }
                    else
                    {
                        filePath = make_csv_staff(path, fname);
                    }


                    Gap.SetPath(path);

                    MessageBox.Show("File Saved to \n" + filePath);
                }
                else
                {
                    MessageBox.Show("Local file save not available !");
                }
            }
            catch (Exception ex)
            {
                errDash.Message(ex.Message);
            }


            try
            {
                Process.Start(filePath);
                //Process.Start("excel.exe", filePath);
            }
            catch
            {
                Process.Start("notepad.exe", filePath);
            }
        }
Beispiel #2
0
        private void cmdExportDetail_Click(object sender, EventArgs e)
        {
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "payDirt.csv";

            try
            {
                if (System.Windows.Forms.SystemInformation.TerminalServerSession)
                {
                    if (Gap.Path.Equals("<none>"))
                    {
                        Gap.SetPath(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                    }


                    fbdCSV.SelectedPath = Gap.Path;
                    DialogResult ok = fbdCSV.ShowDialog();

                    if (ok == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }

                    //string folder = fbdCSV.SelectedPath;
                    //string path = folder + @"\myFile.csv";
                    string path = fbdCSV.SelectedPath;

                    string fname = "paydirt-" + DateTime.Now.ToString("yyMMdd") + ".csv";

                    filePath = make_detail_csv_file(path, fname);

                    Gap.SetPath(path);

                    MessageBox.Show("File Saved to \n" + filePath);
                }
                else
                {
                    MessageBox.Show("Local file save not available !");
                }
            }
            catch (Exception ex)
            {
                errDash.Message(ex.Message);
            }



            try
            {
                Process.Start(filePath);
                //Process.Start("excel.exe", filePath);
            }
            catch (Exception ex)
            {
                Process.Start("notepad.exe", filePath);
            }


            //// ref : http://csharp.net-informations.com/excel/csharp-create-excel.htm
            //Excel.Application xlApp;
            //Excel.Workbook xlWorkBook;
            //Excel.Worksheet xlWorkSheet;
            //object misValue = System.Reflection.Missing.Value;

            //xlApp = new Excel.ApplicationClass();
            //xlWorkBook = xlApp.Workbooks.Add(misValue);

            //xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            //xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com";

            //xlWorkBook.SaveAs("csharp-Excel.xls",
            //    Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
            //    Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            //xlWorkBook.Close(true, misValue, misValue);
            //xlApp.Quit();
        }