예제 #1
0
파일: Form1.cs 프로젝트: Derixen/ITTools
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FormModify frm = new FormModify();

            frm.ShowDialog();

            startScan();
        }
예제 #2
0
파일: Form1.cs 프로젝트: Derixen/ITTools
        private void btnModify_Click(object sender, EventArgs e)
        {
            int selectedRowNr = dataGridView1.CurrentCell.RowIndex + 1;

            using (StreamReader sr = new StreamReader("Data.dat"))
            {
                String   line     = sr.ReadToEnd();
                string[] lines    = line.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                int      newIndex = 0;

                for (int i = 1; i < lines.Length; i++)
                {
                    string[] tabs = lines[i].Split('\t');
                    if (tabs[0] == selectedRowNr.ToString())
                    {
                        if (!File.Exists("NewEntry.tmp"))
                        {
                            using (StreamWriter sw = File.CreateText("NewEntry.tmp"))
                            {
                                sw.WriteLine(selectedRowNr.ToString() + "\t" + tabs[1] + "\t" + tabs[2] + "\t" + tabs[3] + "\t" + tabs[4] + "\t" + tabs[5]);
                            }
                        }
                        else
                        {
                            TextWriter tw = new StreamWriter("NewEntry.tmp");
                            tw.WriteLine(newIndex.ToString() + "\t" + tabs[1] + "\t" + tabs[2] + "\t" + tabs[3] + "\t" + tabs[4] + "\t" + tabs[5]);
                            tw.Close();
                        }
                    }
                }
            }

            FormModify frm = new FormModify();

            frm.ShowDialog();
            btnModify.Enabled = false;
            btnRemove.Enabled = false;
            startScan();
        }