// Update Procedures List private void Add_new_Procedure_Click_1(object sender, EventArgs e) { String newItem; ProcedureList ProceListObject; newItem = Interaction.InputBox(" Add new Item to Procedure List\n NOTE THAT: Enter one Procedure at a time", "Add new Procedure"); if (Login_Form.ProcList.AsEnumerable().Any(row => newItem == row.Field <String>("Procedures"))) { MessageBox.Show("This Item is already exist in your List"); Error.SetError(Add_new_Diagnose, "plzzz"); return; } DataTable Update = new DataTable(); Update = Login_Form.ProcList; if (!string.IsNullOrEmpty(newItem)) { var newRow = Update.NewRow(); newRow[0] = newItem; Update.Rows.InsertAt(newRow, Dates_Procedures.Items.Count); UpdateProcDateSource(Update); Login_Form.ProcList = Update; Login_Form.ProceduresList.Add(newItem); ////////// if (!DataEntiry.ProcedureLists.Any(i => i.Procedures == newItem)) { ProceListObject = new ProcedureList(); ProceListObject.Procedures = newItem; ProceListObject.ID = Login_Form.ProcList.Rows.Count + 1; Login_Form.context.ProcedureLists.Add(ProceListObject); 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 procedure was added successfully"); } }
// Update procedure list private void Add_new_Procedure_Click(object sender, EventArgs e) { String newItem; ProcedureList ProceListObject; newItem = Interaction.InputBox(" Add new Item to Procedure List\n NOTE THAT: Enter one Procedure at a time", "Add new Procedure"); if (Login_Form.ProcList.AsEnumerable().Any(row => newItem == row.Field<String>("Procedures"))) { MessageBox.Show("This Item is already exist in your List"); Error.SetError(Add_new_Diagnose, "plzzz"); return; } DataTable Update = new DataTable(); Update = Login_Form.ProcList; if (!string.IsNullOrEmpty(newItem)) { var newRow = Update.NewRow(); newRow[0] = newItem; Update.Rows.InsertAt(newRow, Dates_Procedures.Items.Count); UpdateProcDateSource(Update); Login_Form.ProcList = Update; Login_Form.ProceduresList.Add(newItem); ////////// if (!DataUpdater.ProcedureLists.Any(i => i.Procedures == newItem)) { ProceListObject = new ProcedureList(); ProceListObject.Procedures = newItem; ProceListObject.ID = Login_Form.ProcList.Rows.Count + 1; Login_Form.context.ProcedureLists.Add(ProceListObject); 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 procedure was added successfully"); } }