// Update Diagnosis List private void Add_new_Diagnose_Click(object sender, EventArgs e) { String newItem; DiagnosisList DiagListObject; newItem = Interaction.InputBox(" Add new Item to Diagnosis List\n NOTE THAT: Enter one Diagnose at a time", "Add new Diagnose"); if (Login_Form.DiagList.AsEnumerable().Any(row => newItem == row.Field <String>("Diagnose"))) { MessageBox.Show("This Item is already exist in your List"); Error.SetError(Add_new_Diagnose, "plzzz"); return; } DataTable Update = new DataTable(); Update = Login_Form.DiagList; if (!string.IsNullOrEmpty(newItem)) { Login_Form.DiagnosisList.Add(newItem); var newRow = Update.NewRow(); newRow[0] = newItem; Update.Rows.InsertAt(newRow, DiagnosisColumn.Items.Count); UpdateDiagDateSource(Update); Login_Form.DiagList = Update; ////////////////////////////////// if (!DataEntiry.DiagnosisLists.Any(i => i.Diagnose == newItem)) { DiagListObject = new DiagnosisList(); DiagListObject.Diagnose = newItem; DiagListObject.ID = Login_Form.DiagList.Rows.Count + 1; Login_Form.context.DiagnosisLists.Add(DiagListObject); Login_Form.context.SaveChanges(); } } if (string.IsNullOrEmpty(newItem)) { MessageBox.Show("You didn't enter new item"); return; } if (!string.IsNullOrEmpty(newItem)) { MessageBox.Show("The new Diagnose was added successfully"); } }
// Update diagnosis list private void Add_new_Diagnose_Click(object sender, EventArgs e) { String newItem; DiagnosisList DiagListObject; newItem = Interaction.InputBox(" Add new Item to Diagnosis List\n NOTE THAT: Enter one Diagnose at a time", "Add new Diagnose"); if (Login_Form.DiagList.AsEnumerable().Any(row => newItem == row.Field<String>("Diagnose"))) { MessageBox.Show("This Item is already exist in your List"); Error.SetError(Add_new_Diagnose, "plzzz"); return; } DataTable Update = new DataTable(); Update = Login_Form.DiagList; if (!string.IsNullOrEmpty(newItem)) { Login_Form.DiagnosisList.Add(newItem); var newRow = Update.NewRow(); newRow[0] = newItem; Update.Rows.InsertAt(newRow, DiagnosisColumn.Items.Count); UpdateDiagDateSource(Update); Login_Form.DiagList = Update; ////////////////////////////////// if (!DataUpdater.DiagnosisLists.Any(i => i.Diagnose == newItem)) { DiagListObject = new DiagnosisList(); DiagListObject.Diagnose = newItem; DiagListObject.ID = Login_Form.DiagList.Rows.Count + 1; Login_Form.context.DiagnosisLists.Add(DiagListObject); Login_Form.context.SaveChanges(); } } if (string.IsNullOrEmpty(newItem)) { MessageBox.Show("You didn't enter new item"); return; } if (!string.IsNullOrEmpty(newItem)) { MessageBox.Show("The new Diagnose was added successfully"); } }