private void ИзменитьToolStripMenuItem_Click(object sender, EventArgs e) { if (!dbm.isBusy) { Close(); return; } if (listView1.SelectedItems.Count == 1) { ListViewItem selItem = listView1.SelectedItems[0]; User[] users = dbm.GetDebtors(dbm.GetPriorities()); User selUser = users.FirstOrDefault(t => t.ID.ToString() == selItem.SubItems[0].Text); using (UserAdd ua = new UserAdd(dbm, users.Select(t => t.Name).ToArray()) { EType = UserAdd.EditType.Edit, UserName = selUser.Name, SelectedPriority = selUser.Priority }) { ua.Construct(); if (ua.ShowForm()) { UpdateConstructor uc = new UpdateConstructor(); uc.Wheres = "`id`='" + selUser.ID + "'"; uc.Values.Add(new DBKV("name", ua.UserName)); uc.Values.Add(new DBKV("priority", ua.SelectedPriority.Name.ToString())); dbm.EditUser(uc); PrintAllUsers(); sync_manager.Synchronization.Changes += 1; } } } }
private void ДобавитьНовогоToolStripMenuItem_Click(object sender, EventArgs e) { if (!dbm.isBusy) { Close(); return; } var f = dbm.GetPriorities(); UserAdd ua = new UserAdd(dbm, (from t in dbm.GetDebtors(f) select t.Name).ToArray()); ua.Construct(); if (ua.ShowForm()) { dbm.AddUser(new User(0, ua.UserName, ua.SelectedPriority, "")); PrintAllUsers(); sync_manager.Synchronization.Changes += 1; } }