private void SaveJob(DataGridView dgv, int rowIndex) { if (dgv.Rows.Count < rowIndex - 1) { return; } DataGridViewRow row = dgv.Rows[rowIndex]; if (row.Cells[0].Value != null && row.Cells[1].Value != null && row.Cells[2].Value != null && //row.Cells[3].Value != null && row.Cells[0].Value.ToString().CompareTo("") != 0 && row.Cells[1].Value.ToString().CompareTo("") != 0 && row.Cells[2].Value.ToString().CompareTo("") != 0 /*&& * row.Cells[3].Value.ToString().CompareTo("") != 0*/) { //ok to save JobsBO bo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); JobContainer container = bo.FindByName(row.Cells[0].Value.ToString()); if (container == null) { JobContainer container2 = new JobContainer(); container2.Name = row.Cells[0].Value.ToString(); bo.Add(container2); container = bo.FindByName(row.Cells[0].Value.ToString()); } container.SourceDirectory = row.Cells[1].Value.ToString(); container.DestinationDirectory = row.Cells[2].Value.ToString(); container.WatchSubDirectories = (bool)row.Cells[3].EditedFormattedValue; bo.Save(); } }
private void Delete() { QuestionForm frm = new QuestionForm(); frm.Msg = "Delete this job?"; if (frm.ShowDialog() == DialogResult.OK) { DataGridViewRow row = GetSelectedRowFromCell(gridJobs); if (row == null) { return; } gridJobs.Rows.Remove(row); if (row.Cells[0].Value == null) { //RefreshFiles(); ClearFiles(); return; } string name = row.Cells[0].Value.ToString(); JobsBO bo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); JobContainer container = bo.FindByName(name); if (container != null) { bo.Delete(container); bo.Save(); //RefreshFiles(); } } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; this.WindowState = FormWindowState.Minimized; } else { JobsBO jbo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); jbo.Save(); } }
private void btnMMExit_Click(object sender, EventArgs e) { ListenerBO bo = (ListenerBO)SingletonManager.GetSingleton(typeof(ListenerBO)); bo.StopListeners(); JobsBO jbo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); jbo.Save(); ConfigurationBO cbo = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); cbo.Save(); //this.Close(); Application.Exit(); }