void oPControl_Store(object sender, NewOperationStoreEventArgs e) { if (!Directory.Exists(textBoxExportPath.Text)) { MessageBox.Show("The Export directory does not exist!"); e.StoredOk = false; return; } long pId; try { pId = Int64.Parse(textBoxPatientId.Text); } catch (FormatException) { MessageBox.Show("PatientId is not valid!"); e.StoredOk = false; return; } OperationData op = e.Operation; op.PatientId = Int64.Parse(textBoxPatientId.Text); JsonContainer jsonContainer = new JsonContainer(); jsonContainer.addOperation(op); string jsonString = SpdJsonTools.GenerateJson(jsonContainer); try { TextFileHelper.WriteFile( textBoxExportPath.Text + Path.DirectorySeparatorChar + "SPD.Operation." + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second + ".json", jsonString); } catch (Exception ex) { MessageBox.Show("Storing not possible:\n" + ex.Message); e.StoredOk = false; return; } PatientData pd = null; try { pd = this.patComp.FindPatientById(op.PatientId); } catch (Exception) {} if (pd == null) { pd = new PatientData(); pd.Id = op.PatientId; pd.Address = string.Empty; pd.FirstName = string.Empty; pd.Phone = string.Empty; pd.SurName = string.Empty; } this.oPControl.CurrentPatient = pd; e.TakeFromDB = false; this.oPControl.Clear(); this.textBoxPatientId.Clear(); SPD.GUI.OPWriter.Properties.Settings.Default.exportPath = textBoxExportPath.Text; SPD.GUI.OPWriter.Properties.Settings.Default.Save(); }
/// <summary> /// Saves this instance. /// </summary> /// <returns></returns> private NewOperationStoreEventArgs save() { NewOperationStoreEventArgs ret = new NewOperationStoreEventArgs(); ret.StoredOk = false; ret.TakeFromDB = false; long intdiagnoses = 0; try { intdiagnoses = Int64.Parse(this.textBoxIntdiagnoses.Text); }catch(Exception){ MessageBox.Show("Format of the Intdiagnoses is not correct"); return ret; } if(!new List<String>(Enum.GetNames(new PPPS().GetType())).Contains(this.comboBoxPPPS.Text)) { MessageBox.Show("PP PS has an incorrect Value"); return ret; } if(!new List<String>(Enum.GetNames(new Result().GetType())).Contains(this.comboBoxResult.Text)) { MessageBox.Show("Result has an incorrect Value"); return ret; } if (!new List<String>(Enum.GetNames(new Organ().GetType())).Contains(this.comboBoxOrgan.Text)) { MessageBox.Show("Organ has an incorrect Value"); return ret; } long operationID = 0; if (operation != null) { operationID = operation.OperationId; } DateTime date; try { date = DateTime.Parse(textBoxOPDate.Text); } catch (Exception) { MessageBox.Show("Format of the Date is not correct!"); return ret; } long kathDays = 0; try { kathDays = Convert.ToInt64(comboBoxKathDays.Text.Trim()); } catch (Exception) {} NewOperationStoreEventArgs e2; long currentPatientId; if (currentPatient == null) { currentPatientId = -1; } else { currentPatientId = currentPatient.Id; } PPPS ppps = (PPPS)Enum.Parse(new PPPS().GetType(), this.comboBoxPPPS.Text); Result result = (Result)Enum.Parse(new Result().GetType(), this.comboBoxResult.Text); Organ organ = (Organ)Enum.Parse(new Organ().GetType(), this.comboBoxOrgan.Text); e2 = new NewOperationStoreEventArgs( new OperationData(operationID, date, textBoxOPTeam.Text, textBoxOPProcess.Text, textBoxOPDiagnoses.Text, textBoxPerformedOP.Text, currentPatientId, textBoxAdditionalInformation.Text, textBoxMedication.Text, intdiagnoses, ppps, result, kathDays, organ, textBoxOpResult.Text)); e2.StoredOk = true; e2.TakeFromDB = false; Store(this, e2); return e2; }
/////////// Find Patient Sub Events END void newOperation_Store(object sender, NewOperationStoreEventArgs e) { OperationData odata = e.Operation; if (odata.OperationId == 0) { // new Operation odata.PatientId = currentPatient.Id; patComp.InsertOperation(e.Operation); } else { // change Visit patComp.UpdateOperation(e.Operation); } this.Controls.Remove(newOperation); putPatientSearchControl(currentPatient); this.patientSearchControl.ListViewPatients.Focus(); }