private void 옵션ToolStripMenuItem_Click(object sender, EventArgs e) { FormOption dlgForOption = new FormOption(); dlgForOption.SetDBINI(diManager); diManager.SetFormOption(dlgForOption); dlgForOption.ShowDialog(); }
public void WriteIni(FormOption dlg) { StreamWriter sw = new StreamWriter(new FileStream(DbIni, FileMode.OpenOrCreate)); sw.WriteLine(dlg.GetTextBoxIpAddress() + "|" + dlg.GetTextBoxDBName() + "|" + dlg.GetTextBoxCollectionName() + "|" + dlg.GetTextBoxId() + "|" + dlg.GetTextBoxPw()); sw.Close(); }
public void Initialize() { StreamReader sr = new StreamReader(new FileStream(DbIni, FileMode.OpenOrCreate)); long fileSize = sr.BaseStream.Length; sr.Close(); if (0 == fileSize) { FormOption dlgForOption = new FormOption(); dlgForOption.SetDBINI(this); DialogResult dr = new DialogResult(); dr = dlgForOption.ShowDialog(); if (dr == DialogResult.OK) { // MessageBox.Show("User clicked OK button"); StreamWriter sw = new StreamWriter(new FileStream(DbIni, FileMode.OpenOrCreate)); IpAddress = dlgForOption.GetTextBoxIpAddress(); DbName = dlgForOption.GetTextBoxDBName(); CollectionName = dlgForOption.GetTextBoxCollectionName(); Id = dlgForOption.GetTextBoxId(); Pw = dlgForOption.GetTextBoxPw(); sw.WriteLine(IpAddress + "|" + DbName + "|" + CollectionName + "|" + Id + "|" + Pw); sw.Close(); } else if (dr == DialogResult.Cancel) { // MessageBox.Show("User clicked Cancel button"); } } else { } }
public void SetFormOption(FormOption dlg) { StreamReader sr = new StreamReader(new FileStream(DbIni, FileMode.OpenOrCreate)); long fileSize = sr.BaseStream.Length; if (0 == fileSize) { MessageBox.Show("DB 접속 정보가 없습니다"); } else { string readLine = sr.ReadLine(); string[] dbInfo = readLine.Split('|'); dlg.SetTextBoxIpAddress(dbInfo[0]); dlg.SetTextBoxDBName(dbInfo[1]); dlg.SetTextBoxCollectionName(dbInfo[2]); dlg.SetTextBoxId(dbInfo[3]); dlg.SetTextBoxPw(dbInfo[4]); } sr.Close(); }