private void SubmitCaseChangesButton_Click(object sender, EventArgs e) { /* Takes the information from the text boxes of the form and updates * the database entry for that case with that information. * It then runs the FillTheList function again to update its information. */ string CaseID = CaseListBox.SelectedItem.ToString(); //get Case_ID from selected item of ListBox int index = CaseID.IndexOf(' '); //trim the selected item string to fit in the query if (index > 0) { CaseID = CaseID.Substring(0, index); } int ID = Int32.Parse(CaseID); string CaseName = CaseNameTextbox.Text; string CaseNumber = CaseNumberTextbox.Text; string StartDate = StartDateCal.Value.ToString(); string EndDate = null; if (EndDateCal.Checked == true) { EndDate = EndDateCal.Value.ToString(); } CaseNameTextbox.Clear(); CaseNumberTextbox.Clear(); using (var db = new LiteDatabase(MainMenu.line)) { var collection = db.GetCollection <Cases>("cases"); var update = collection .FindById(ID); update.Case_Name = CaseName; update.Case_Number = CaseNumber; update.Start_Date = StartDate; update.End_Date = EndDate; collection.Update(update); } FillTheList(CaseListBox); }
private void SubmitCaseChangesButton_Click_1(object sender, EventArgs e) { /* Gets the information from the text fields */ string CaseName = CaseNameTextbox.Text; string CaseNumber = CaseNumberTextbox.Text; string StartDate = StartDateCal.Value.ToString(); string EndDate = null; if (EndDateCal.Checked == true) { EndDate = EndDateCal.Value.ToString(); } CaseNameTextbox.Clear(); CaseNumberTextbox.Clear(); /* Inserts that information into the database and creates * new file directories for screenshots and attachments */ using (var db = new LiteDatabase(MainMenu.line)) { var col = db.GetCollection <Cases>("cases"); var newcase = new Cases { Case_Number = CaseNumber, Case_Name = CaseName, Start_Date = StartDate, End_Date = EndDate }; int id = col.Insert(newcase); var fileattachmentspath = @".\FileAttachments\" + id.ToString(); var screenshotspath = @".\Screenshots\" + id.ToString(); Directory.CreateDirectory(fileattachmentspath); Directory.CreateDirectory(screenshotspath); } this.Close(); }