예제 #1
0
        private void save_report(string name)
        {
            MyFile mf = new MyFile(name);

            mf.addstr_to_file(tabControl_management.TabPages[tabControl_management.SelectedIndex].Text);
            mf.addstr_to_file("Report time: " + get_report_date());
            mf.addstr_to_file("Time: " + DateTime.Now.ToString("dd ") + inc.Month_Display[DateTime.Now.Month] + DateTime.Now.ToString(" yyyy"));
            string str           = "";
            string _datagridname = get_report_dataviewname();

            for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; i++)
            {
                if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].Visible)
                {
                    str += ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].HeaderText + ",";
                }
            }
            mf.addstr_to_file(str);
            for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows.Count; i++)
            {
                str = "";
                for (int j = 0; j < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; j++)
                {
                    if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[j].Visible)
                    {
                        str += Tools.get_value(((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows[i].Cells[j].Value) + ",";
                    }
                }
                mf.addstr_to_file(str);
                Application.DoEvents();
            }
            mf.close();
        }
예제 #2
0
        private void save_report(string name)
        {
            MyFile mf = new MyFile(name);

            mf.addstr_to_file("Alarm");
            mf.addstr_to_file("Time: " + DateTime.Now.ToString("dd ") + inc.Month_Display[DateTime.Now.Month] + DateTime.Now.ToString(" yyyy"));
            string str = "";

            for (int i = 0; i < dataGridView7.Columns.Count; i++)
            {
                if (dataGridView7.Columns[i].Visible)
                {
                    str += dataGridView7.Columns[i].HeaderText + ",";
                }
            }
            mf.addstr_to_file(str);
            for (int i = 0; i < dataGridView7.Rows.Count; i++)
            {
                str = "";
                for (int j = 0; j < dataGridView7.Columns.Count; j++)
                {
                    if (dataGridView7.Columns[j].Visible)
                    {
                        str += Tools.get_value(dataGridView7.Rows[i].Cells[j].Value) + ",";
                    }
                }
                mf.addstr_to_file(str);
                Application.DoEvents();
            }
            mf.close();
        }
예제 #3
0
        private void button15_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog sfdSaveOnlineText = new SaveFileDialog();
                sfdSaveOnlineText.Filter           = "CSV files (*.csv)|*.csv";
                sfdSaveOnlineText.FilterIndex      = 0;
                sfdSaveOnlineText.RestoreDirectory = true;
                sfdSaveOnlineText.CreatePrompt     = true;
                sfdSaveOnlineText.Title            = "Save File To";

                if (sfdSaveOnlineText.ShowDialog() == DialogResult.OK)
                {
                    string name = sfdSaveOnlineText.FileName;

                    MyFile mf = new MyFile(name);
                    mf.addstr_to_file(tabControl_management.TabPages[tabControl_management.SelectedIndex].Text);
                    mf.addstr_to_file("Report time: " + get_report_date());
                    mf.addstr_to_file("Time: " + DateTime.Now.ToString("dd ") + inc.Month_Display[DateTime.Now.Month] + DateTime.Now.ToString(" yyyy"));
                    string str           = "";
                    string _datagridname = get_report_dataviewname();

                    mf.addstr_to_file("\r\n");
                    str           = "";
                    _datagridname = dataGridView6.Name;
                    for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; i++)
                    {
                        if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].Visible)
                        {
                            str += ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].HeaderText + ",";
                        }
                    }
                    mf.addstr_to_file(str);
                    for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows.Count; i++)
                    {
                        str = "";
                        for (int j = 0; j < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; j++)
                        {
                            if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[j].Visible)
                            {
                                str += Tools.get_value(((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows[i].Cells[j].Value) + ",";
                            }
                        }
                        mf.addstr_to_file(str);
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Save File Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
            }
        }