private void Edit() { Note note = new Note(); note.CustomerName = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); var date = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); note.Date = Convert.ToDateTime(date); note.StartSchedule = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); note.FinalSchedule = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); FormNoteData frm = new FormNoteData() { Edit = true }; frm.FillForm(note.CustomerName, note.Date, note.StartSchedule, note.FinalSchedule); if (frm.ShowDialog() != DialogResult.None) { var id = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); Db db = new Db(); SqlCommand deleteCommand = new SqlCommand("delete from note where id = @id"); deleteCommand.Parameters.AddWithValue("@id", id); db.executeQuery(deleteCommand); } }
private void Fill() { Note note = new Note(); note.CustomerName = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); var date = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); note.Date = Convert.ToDateTime(date); note.StartSchedule = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); note.FinalSchedule = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); FormNoteData frm = new FormNoteData(); frm.FillForm(note.CustomerName, note.Date, note.StartSchedule, note.FinalSchedule); frm.Show(); }
private void btnNew_Click(object sender, EventArgs e) { FormNoteData frm = new FormNoteData(); frm.Show(); }