/// <summary> /// Метод получения базы данных из файла /// </summary> /// <param name="fileName"></param> /// <returns></returns> static Accaunt[] GetArrAcc(string fileName) { int len = 0; if (File.Exists(fileName)) { string[] str = File.ReadAllLines(fileName); if (str.Length % 2 == 0) { len = str.Length / 2; int j = 0; Accaunt[] tempAcc = new Accaunt[len]; for (int i = 0; i < str.Length; i++) { tempAcc[j].log = str[i]; tempAcc[j].pas = str[i + 1]; j++; i++; } Console.WriteLine("База данных успешно взята из файла."); return(tempAcc); } else { throw new Exception("Файл иммет не корректное количество строк"); } } else { throw new FileNotFoundException(); } }
/// <summary> /// Проверка пароля и логина, введённых пользователем с конкретным элементом базы данных /// </summary> /// <param name="login"></param> /// <param name="passward"></param> /// <param name="count"></param> /// <param name="accaunt"></param> /// <returns></returns> static bool CheckAnswer(string login, string passward, int count, Accaunt accaunt) { bool flag = false; if (accaunt.log == login) { if (accaunt.pas == passward) { Console.WriteLine("Вы успешно ввели правильную пару логин|пароль! Молодцом!)"); flag = false; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Был введён не корректный пароль к логину=> {login}"); Console.ForegroundColor = ConsoleColor.Yellow; flag = true; } } if (flag) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Не валидная пара логин/пароль\nОсталось {count} попыток"); Console.ForegroundColor = ConsoleColor.Yellow; } return(flag); }
static Accaunt GetAccauntID(LibraryEntities1 context, int accauntID) { Accaunt accaunt = context.Accaunts.FirstOrDefault( p => p.AccauntID == accauntID); return(accaunt); }
public static void SendMoneyTo(this Accaunt accaunt, Accaunt targetAccaunt, float moneyValue) { if ((accaunt.Balans >= moneyValue) && (moneyValue > 0)) { targetAccaunt.PushMoney(moneyValue); accaunt.PopMoney(moneyValue); } }
static void DeleteAccaunt(int accauntID) { LibraryEntities1 context = new LibraryEntities1(); Accaunt accaunt = GetAccauntID(context, accauntID); context.Accaunts.DeleteObject(accaunt); context.SaveChanges(); }
private void buttonAdd_Click(object sender, EventArgs e) { LibraryEntities1 context = new LibraryEntities1(); Accaunt newAccaunt = new Accaunt() { Login = textBoxLogin.Text.Trim(), PasswordSHA1 = CalculateSHA1(textBoxLogin.Text).Trim(), FirstName = textBoxFName.Text.Trim(), LastName = textBoxLName.Text.Trim() }; context.Accaunts.AddObject(newAccaunt); context.SaveChanges(); MessageBox.Show("Добавянето е успешно."); Clear(); }
public BotAction(string message) { var splitList = message.Split(new[] { "\n" }, StringSplitOptions.None); foreach (var accStr in splitList) { var accaunt = accStr.Split(new[] { ":", ";" }, StringSplitOptions.None); if (accaunt.Count() != 2) { continue; } if (Accaunt == null) { Accaunt = new List <AccauntModels>(); } Accaunt.Add(new AccauntModels(accaunt[0], accaunt[1])); } foreach (var s in splitList) { try { ulong number = Convert.ToUInt64(s); if (ApplicationUniqId == null) { ApplicationUniqId = new List <ulong>(); } ApplicationUniqId.Add(number); } catch (Exception e) { Console.WriteLine(e); } } }
public ViewModelEditUser(NavigationController controller) : base(controller) { MessageBus.Default.Subscribe("SomethingChangedUserForEditUser", Changed); MessageBus.Default.Subscribe("UpdateAccsEmptyForNewUserForAddNewMedpersonal", UpdateAccsEmptyAddMeds); MessageBus.Default.Subscribe("UpdateAccsEmptyForNewUserForAddNewMed", UpdateAccsEmptyAddDocs); MessageBus.Default.Subscribe("UpdateAccsEmptyForNewUser", UpdateAccsEmpty); MessageBus.Default.Subscribe("GetUserForEditUser", GetUserForEditUser); ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/Hide.PNG")); base.HasNavigation = true; Vis = Visibility.Visible; DocVis = Visibility.Visible; MedVis = Visibility.Collapsed; PasswordBoxVisiblity = Visibility.Visible; PasswordTextBoxVisiblity = Visibility.Hidden; TextHeader = "Добавление пользователя"; accType = new List <string>(); accType.Add("Врач"); accType.Add("Админ"); accType.Add("Медперсонал"); accType.Add("Секретарь"); nameOfButton = "К списку пользователей"; SetAllFieldsDefault(); PasswordChabged = new DelegateCommand( () => { nameOfButton = "Сохранить"; } ); HidePassword = new DelegateCommand( () => { ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/Hide.PNG")); Password = ""; PasswordBoxVisiblity = Visibility.Visible; PasswordTextBoxVisiblity = Visibility.Hidden; } ); ShowPassword = new DelegateCommand <object>( (sender) => { ImageSource = new BitmapImage(new Uri("pack://application:,,,/Images/Show.PNG")); // Password = CalculateMD5Hash(((PasswordBox)sender).Password); Password = ((PasswordBox)sender).Password; sender = null; PasswordBoxVisiblity = Visibility.Hidden; PasswordTextBoxVisiblity = Visibility.Visible; } ); ToDashboardCommand = new DelegateCommand <object>( (sender) => { Name = currentUser.Name; ((PasswordBox)sender).Password = ""; MessageBus.Default.Call("GetUserForEditUser", this, currentUser.Id); nameOfButton = "К списку пользователей"; } ); SaveAndGoDoctorListCommand = new DelegateCommand <object>( (sender) => { Password = ((PasswordBox)sender).Password; sender = null; if (TestRequiredFields()) { currentUser = Data.Accaunt.Get(currentUser.Id); currentUser.Name = Name; if (!String.IsNullOrEmpty(Password)) { currentUser.Password = CalculateMD5Hash(Password); } currentUser.isDoctor = false; currentUser.isAdmin = false; currentUser.isMedPersonal = false; currentUser.isSecretar = false; //currentUser.isEnabled = true; if (accType[SelectedIndexOfAccauntType] == "Врач") { currentUser.isDoctor = true; currentUser.idмедперсонал = null; foreach (var doc in DocsDataSource) { if (doc.IsChecked == true) { currentUser.idврач = doc.id; } } } else if (accType[SelectedIndexOfAccauntType] == "Админ") { currentUser.idмедперсонал = null; currentUser.idврач = null; currentUser.isAdmin = true; } else if (accType[SelectedIndexOfAccauntType] == "Медперсонал") { currentUser.isMedPersonal = true; currentUser.idврач = null; foreach (var doc in MedsDataSource) { if (doc.IsChecked == true) { currentUser.idмедперсонал = doc.id; } } } else if (accType[SelectedIndexOfAccauntType] == "Секретарь") { currentUser.idмедперсонал = null; currentUser.idврач = null; currentUser.isSecretar = true; } Data.Complete(); MessageBus.Default.Call("OpenUsers", this, ""); Controller.NavigateTo <ViewModelViewUsers>(); } else { MessageBox.Show("Не все поля заполнены"); } } ); GoToDoctorListCommand = new DelegateCommand( () => { MessageBus.Default.Call("OpenUsers", this, ""); Controller.NavigateTo <ViewModelViewUsers>(); } ); }
private void GetUserForEditUser(object sender, object data) { MedsDataSource = new ObservableCollection <DocDataSoursForNewUser>(); DocsDataSource = new ObservableCollection <DocDataSoursForNewUser>(); WidthOfBtn = 300; VisibilityOfGoBAck = Visibility.Collapsed; currentUser = Data.Accaunt.Get((int)data); Name = currentUser.Name; if (currentUser.isAdmin == true) { SelectedIndexOfAccauntType = accType.IndexOf("Админ"); } else if (currentUser.isDoctor == true) { SelectedIndexOfAccauntType = accType.IndexOf("Врач"); var doc = Data.Doctor.Get(currentUser.idврач.Value); string initials = " " + doc.Name.ToCharArray()[0].ToString() + ". " + doc.Patronimic.ToCharArray()[0].ToString() + ". "; MedVis = Visibility.Collapsed; DocVis = Visibility.Visible; DocsDataSource.Add(new DocDataSoursForNewUser(doc.Sirname + initials, doc.Id)); DocsDataSource[0].IsChecked = true; } else if (currentUser.isSecretar == true) { SelectedIndexOfAccauntType = accType.IndexOf("Секретарь"); } else if (currentUser.isMedPersonal == true) { SelectedIndexOfAccauntType = accType.IndexOf("Медперсонал"); var doc = Data.MedPersonal.Get(currentUser.idмедперсонал.Value); string initials = " " + doc.Name.ToCharArray()[0].ToString() + ". " + doc.Patronimic.ToCharArray()[0].ToString() + ". "; MedVis = Visibility.Visible; DocVis = Visibility.Collapsed; MedsDataSource.Add(new DocDataSoursForNewUser(doc.Surname + initials, doc.Id)); MedsDataSource[0].IsChecked = true; } bool test = true; foreach (var doc in Data.Doctor.GetAll) { test = true; foreach (var acc in Data.Accaunt.GetAll) { if (acc.isDoctor != null && acc.isDoctor.Value && doc.isEnabled != null && doc.isEnabled.Value == true) { if (doc.Id == acc.idврач) { test = false; } } } if (test) { string initials = " " + doc.Name.ToCharArray()[0].ToString() + ". " + doc.Patronimic.ToCharArray()[0].ToString() + ". "; DocsDataSource.Add(new DocDataSoursForNewUser(doc.Sirname + initials, doc.Id)); } } foreach (var doc in Data.MedPersonal.GetAll) { test = true; foreach (var acc in Data.Accaunt.GetAll) { if (acc.isMedPersonal != null && acc.isMedPersonal.Value && doc.isEnabled != null && doc.isEnabled.Value == true) { if (doc.Id == acc.idмедперсонал) { test = false; } } } if (test) { string initials = " " + doc.Name.ToCharArray()[0].ToString() + ". " + doc.Patronimic.ToCharArray()[0].ToString() + ". "; MedsDataSource.Add(new DocDataSoursForNewUser(doc.Surname + initials, doc.Id)); } } nameOfButton = "К списку пользователей"; }
public ChangeHistoryClass(ChangeHistory Ch, IUnitOfWork UnitOfWork) { this.Ch = Ch; AccName = ""; AccPost = ""; ChangeType = ""; TableChanged = ""; PropertyChanged = ""; OldValue = ""; NewValue = ""; IsVisibleTotal = true; IsFilteredDate = false; IsFilteredAccName = false; IsFilteredAccPost = false; IsFilteredChangeType = false; IsFilteredTableChanged = false; IsFilteredPropertyChanged = false; IsFilteredOldValue = false; IsFilteredNewValue = false; // TEST if (Ch.SomeBlobFileNew != null) { NewValue = "Новое фото анализа"; } if (Ch.SomeBlobFileOld != null) { OldValue = "Старое фото анализа"; } else { OldValue = Ch.старое_значение; NewValue = Ch.новое_значение; } TableChanged = Ch.название_таблицы; PropertyChanged = Ch.название_столбца; // Date = Op.Date.Day.ToString() + "." + Op.Date.Month.ToString() + "." + Op.Date.Year.ToString(); // Time = buf1.Hour.ToString() + ":" + buf1.Minute.ToString(); Date = Ch.дата_изменения; Accaunt CurAcc = UnitOfWork.Accaunt.Get(Ch.id_аккаунта); AccName = CurAcc.Name; if (CurAcc.isAdmin != null && CurAcc.isAdmin.Value) { AccPost = "Администратор"; } else if (CurAcc.isDoctor != null && CurAcc.isDoctor.Value) { AccPost = "Врач"; } else if (CurAcc.isMedPersonal != null && CurAcc.isMedPersonal.Value) { AccPost = "Медперсонал"; } ChangeType = UnitOfWork.ChangesInDBType.Get(Ch.тип_изменения).Str; //var CurrentPatient = PtRep.Get(Ex.PatientId.Value); //Patient = CurrentPatient.Sirname + " " + CurrentPatient.Name.ToCharArray()[0].ToString() + ". " + CurrentPatient.Patronimic.ToCharArray()[0].ToString() + "."; }
public MyPrincipial(string username) { this.Identity = new GenericIdentity(username); this.Accaunt = AccauntModel.find(username); }