/// <summary>Returns false if not able to save.</summary> private bool SaveToDb() { if (listLab.SelectedIndex == -1) { MsgBox.Show(this, "Please select a lab first."); return(false); } if (comboProv.SelectedIndex == -1) { MsgBox.Show(this, "Please select a provider first."); return(false); } if (textDateCreated.Text != "") { try{ DateTime.Parse(textDateCreated.Text); } catch { MsgBox.Show(this, "Date Time Created is invalid."); return(false); } } if (textDateSent.Text != "") { try { DateTime.Parse(textDateSent.Text); } catch { MsgBox.Show(this, "Date Time Sent is invalid."); return(false); } } if (textDateRecd.Text != "") { try { DateTime.Parse(textDateRecd.Text); } catch { MsgBox.Show(this, "Date Time Received is invalid."); return(false); } } if (textDateChecked.Text != "") { try { DateTime.Parse(textDateChecked.Text); } catch { MsgBox.Show(this, "Date Time Checked is invalid."); return(false); } } if (textDateDue.Text != "") { try { DateTime.Parse(textDateDue.Text); } catch { MsgBox.Show(this, "Date Time Due is invalid."); return(false); } } CaseCur.LaboratoryNum = ListLabs[listLab.SelectedIndex].LaboratoryNum; //AptNum //PlannedAptNum CaseCur.ProvNum = ProviderC.ListShort[comboProv.SelectedIndex].ProvNum; if (textDateCreated.Text == "") { CaseCur.DateTimeCreated = DateTime.MinValue; } else { CaseCur.DateTimeCreated = DateTime.Parse(textDateCreated.Text); } if (textDateSent.Text == "") { CaseCur.DateTimeSent = DateTime.MinValue; } else { CaseCur.DateTimeSent = DateTime.Parse(textDateSent.Text); } if (textDateRecd.Text == "") { CaseCur.DateTimeRecd = DateTime.MinValue; } else { CaseCur.DateTimeRecd = DateTime.Parse(textDateRecd.Text); } if (textDateChecked.Text == "") { CaseCur.DateTimeChecked = DateTime.MinValue; } else { CaseCur.DateTimeChecked = DateTime.Parse(textDateChecked.Text); } if (textDateDue.Text == "") { CaseCur.DateTimeDue = DateTime.MinValue; } else { CaseCur.DateTimeDue = DateTime.Parse(textDateDue.Text); } CaseCur.Instructions = textInstructions.Text; try{ //if(IsNew){//No. Always created ahead of time LabCases.Update(CaseCur); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return(false); } return(true); }
private void butOK_Click(object sender, System.EventArgs e) { if (listLab.SelectedIndex == -1) { MsgBox.Show(this, "Please select a lab first."); return; } if (comboProv.SelectedIndex == -1) { MsgBox.Show(this, "Please select a provider first."); return; } if (textDateCreated.Text != "") { try{ DateTime.Parse(textDateCreated.Text); } catch { MsgBox.Show(this, "Date Time Created is invalid."); return; } } if (textDateSent.Text != "") { try { DateTime.Parse(textDateSent.Text); } catch { MsgBox.Show(this, "Date Time Sent is invalid."); return; } } if (textDateRecd.Text != "") { try { DateTime.Parse(textDateRecd.Text); } catch { MsgBox.Show(this, "Date Time Received is invalid."); return; } } if (textDateChecked.Text != "") { try { DateTime.Parse(textDateChecked.Text); } catch { MsgBox.Show(this, "Date Time Checked is invalid."); return; } } if (textDateDue.Text != "") { try { DateTime.Parse(textDateDue.Text); } catch { MsgBox.Show(this, "Date Time Due is invalid."); return; } } CaseCur.LaboratoryNum = ListLabs[listLab.SelectedIndex].LaboratoryNum; //AptNum //PlannedAptNum CaseCur.ProvNum = Providers.List[comboProv.SelectedIndex].ProvNum; if (textDateCreated.Text == "") { CaseCur.DateTimeCreated = DateTime.MinValue; } else { CaseCur.DateTimeCreated = DateTime.Parse(textDateCreated.Text); } if (textDateSent.Text == "") { CaseCur.DateTimeSent = DateTime.MinValue; } else { CaseCur.DateTimeSent = DateTime.Parse(textDateSent.Text); } if (textDateRecd.Text == "") { CaseCur.DateTimeRecd = DateTime.MinValue; } else { CaseCur.DateTimeRecd = DateTime.Parse(textDateRecd.Text); } if (textDateChecked.Text == "") { CaseCur.DateTimeChecked = DateTime.MinValue; } else { CaseCur.DateTimeChecked = DateTime.Parse(textDateChecked.Text); } if (textDateDue.Text == "") { CaseCur.DateTimeDue = DateTime.MinValue; } else { CaseCur.DateTimeDue = DateTime.Parse(textDateDue.Text); } CaseCur.Instructions = textInstructions.Text; try{ if (IsNew) { LabCases.Insert(CaseCur); } else { LabCases.Update(CaseCur); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
/// <summary>Returns false if not able to save.</summary> private bool SaveToDb() { if (listLab.SelectedIndex == -1) { MsgBox.Show(this, "Please select a lab first."); return(false); } if (comboProv.SelectedIndex == -1) { MsgBox.Show(this, "Please select a provider first."); return(false); } if (textDateCreated.Text != "") { try{ DateTime.Parse(textDateCreated.Text); } catch { MsgBox.Show(this, "Date Time Created is invalid."); return(false); } } if (textDateSent.Text != "") { try { DateTime.Parse(textDateSent.Text); } catch { MsgBox.Show(this, "Date Time Sent is invalid."); return(false); } } if (textDateRecd.Text != "") { try { DateTime.Parse(textDateRecd.Text); } catch { MsgBox.Show(this, "Date Time Received is invalid."); return(false); } } if (textDateChecked.Text != "") { try { DateTime.Parse(textDateChecked.Text); } catch { MsgBox.Show(this, "Date Time Checked is invalid."); return(false); } } if (textDateDue.Text != "") { try { DateTime.Parse(textDateDue.Text); } catch { MsgBox.Show(this, "Date Time Due is invalid."); return(false); } } if (textLabFee.errorProvider1.GetError(textLabFee) != "") { MsgBox.Show(this, "Lab fee amount is invalid."); return(false); } CaseCur.LaboratoryNum = ListLabs[listLab.SelectedIndex].LaboratoryNum; //AptNum //PlannedAptNum CaseCur.ProvNum = _listProviders[comboProv.SelectedIndex].ProvNum; if (textDateCreated.Text == "") { CaseCur.DateTimeCreated = DateTime.MinValue; } else { CaseCur.DateTimeCreated = DateTime.Parse(textDateCreated.Text); } if (textDateSent.Text == "") { CaseCur.DateTimeSent = DateTime.MinValue; } else { CaseCur.DateTimeSent = DateTime.Parse(textDateSent.Text); } if (textDateRecd.Text == "") { CaseCur.DateTimeRecd = DateTime.MinValue; } else { CaseCur.DateTimeRecd = DateTime.Parse(textDateRecd.Text); } if (textDateChecked.Text == "") { CaseCur.DateTimeChecked = DateTime.MinValue; } else { CaseCur.DateTimeChecked = DateTime.Parse(textDateChecked.Text); } if (textDateDue.Text == "") { CaseCur.DateTimeDue = DateTime.MinValue; } else { CaseCur.DateTimeDue = DateTime.Parse(textDateDue.Text); } CaseCur.Instructions = textInstructions.Text; CaseCur.LabFee = PIn.Double(textLabFee.Text); object[] parameters = { true }; Plugins.HookAddCode(this, "FormLabCaseEdit.SaveToDb_update", parameters); if (!(bool)parameters[0]) { return(false); } try{ //if(IsNew){//No. Always created ahead of time LabCases.Update(CaseCur); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return(false); } return(true); }