/// <summary> /// Добавление клиента /// </summary> public void AddClient() { if (W.accType.SelectedIndex == 0) { if (W.nameOrg.Text != "" && W.salaryOrg.Text != "" && W.typePayOrg.SelectedIndex != -1) { try { Organization newOrg = new Organization(W.nameOrg.Text, Convert.ToInt32(W.salaryOrg.Text), W.typePayOrg.SelectedIndex, Repository.correntMonth, Repository.db.Count); Repository.db.Add(newOrg); Repository.Refresh(); EntityDB.Add(newOrg); //BaseSQL.Add(newOrg); W.DialogResult = true; } catch (Exception m) { MessageBox.Show(m.Message); } } else { MessageBox.Show("All string must be fulled!"); } } else if (W.accType.SelectedIndex == 1) { if (W.firstnameW.Text != "" && W.lastnameW.Text != "" && W.ageW.Text != "" && W.salaryW.Text != "" && W.typePayW.SelectedIndex != -1) { try { Worker newW = new Worker(W.firstnameW.Text, W.lastnameW.Text, Convert.ToInt32(W.ageW.Text), Convert.ToInt32(W.salaryW.Text), W.typePayW.SelectedIndex, Repository.correntMonth, Repository.db.Count); Repository.db.Add(newW); Repository.Refresh(); EntityDB.Add(newW); //BaseSQL.Add(newW); W.DialogResult = true; } catch (Exception m) { MessageBox.Show(m.Message); } } else { MessageBox.Show("All string must be fulled!"); } } else { return; } }
/// <summary> /// Сделать клиента VIP клиентом /// </summary> public void SetVIPWorker() { if (W.tabLists.SelectedIndex == 0) { if (W.lsW.SelectedIndex != -1) { int Id = Repository.db.GetId((Worker)W.lsW.SelectedItem); VIPworker newvip = new VIPworker((Worker)Repository.db[Id]); Repository.db.ReWrite(newvip, Id); EntityDB.Delete(newvip.Id); EntityDB.Add(newvip); Repository.Refresh(); } else { MessageBox.Show("Select client"); } } else { MessageBox.Show("VIP can be seted only standart clients!"); } }