private void butAdd_Click(object sender, System.EventArgs e) { Operatory opCur = new Operatory(); if (gridMain.SelectedIndices.Length > 0) //a row is selected { opCur.ItemOrder = gridMain.SelectedIndices[0]; } else { opCur.ItemOrder = Operatories.List.Length; //goes at end of list } FormOperatoryEdit FormE = new FormOperatoryEdit(opCur); FormE.IsNew = true; FormE.ShowDialog(); if (FormE.DialogResult == DialogResult.Cancel) { return; } if (gridMain.SelectedIndices.Length > 0) { //fix the itemOrder of every Operatory following this one for (int i = gridMain.SelectedIndices[0]; i < Operatories.List.Length; i++) { Operatories.List[i].ItemOrder++; Operatories.InsertOrUpdate(Operatories.List[i], false); } } FillGrid(); changed = true; }
private void butOK_Click(object sender, System.EventArgs e) { if (textOpName.Text == "") { MessageBox.Show(Lan.g(this, "Op Name cannot be blank.")); return; } OpCur.OpName = textOpName.Text; OpCur.Abbrev = textAbbrev.Text; OpCur.IsHidden = checkIsHidden.Checked; if (comboClinic.SelectedIndex == 0) //none { OpCur.ClinicNum = 0; } else { OpCur.ClinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum; } if (comboProvDentist.SelectedIndex == 0) //none { OpCur.ProvDentist = 0; } else { OpCur.ProvDentist = Providers.List[comboProvDentist.SelectedIndex - 1].ProvNum; } if (comboProvHygienist.SelectedIndex == 0) //none { OpCur.ProvHygienist = 0; } else { OpCur.ProvHygienist = Providers.List[comboProvHygienist.SelectedIndex - 1].ProvNum; } OpCur.IsHygiene = checkIsHygiene.Checked; try{ Operatories.InsertOrUpdate(OpCur, IsNew); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
private void butDown_Click(object sender, System.EventArgs e) { if (gridMain.SelectedIndices.Length == 0) { MsgBox.Show(this, "You must first select a row."); return; } int selected = gridMain.SelectedIndices[0]; if (selected == Operatories.List.Length - 1) { return; //already at the bottom } //move selected item down Operatories.List[selected].ItemOrder++; Operatories.InsertOrUpdate(Operatories.List[selected], false); //move the one below it up Operatories.List[selected + 1].ItemOrder--; Operatories.InsertOrUpdate(Operatories.List[selected + 1], false); FillGrid(); gridMain.SetSelected(selected + 1, true); changed = true; }