public DataBaseHelp DataBaseConnection() { var conn = new DataBase().SQLiteConnection(); db = new DataBaseHelp(conn); return(db); }
private void Button_Click(object sender, EventArgs e) { var conn = new DataBase().SQLiteConnection(); var db = new DataBaseHelp(conn); var toast_mess = string.Empty; if (validate()) { var category = category_text.Text; var password = password_text.Text; if (information_category == null) { var list = db.GetItems <ModelCategory>(); for (int i = 0; i < list.Count; i++) { if (list[i].Category == category) { Toast.MakeText(this, "Категория с таким именем уже зарегистрирована", ToastLength.Short).Show(); return; } } information_category = new ModelCategory(); information_category.Category = category; information_category.Password = EncryptionDecryptionService.GetSHA(password, false); information_category.Count = 0; toast_mess = "Категория успешно создана"; db.SaveItem(information_category, false); } else { information_category.Category = category; information_category.Password = EncryptionDecryptionService.GetSHA(password, false); information_category.Count = information_category.Count; toast_mess = "Категория обновлена"; db.SaveItem(information_category, true); } Toast.MakeText(this, toast_mess, ToastLength.Short).Show(); StartActivity(typeof(CategoryActivity)); } else { Toast.MakeText(this, "Поля ввода не пройшли валидацию", ToastLength.Short).Show(); } }