private void WorkEditText_TextChanged(object sender, Android.Text.TextChangedEventArgs e) { if (!string.IsNullOrWhiteSpace(syllabelsTextView.Text)) { syllabelsTextView.Text = ""; //clearing textview content } List <string> list = String.Concat(e.Text).Split("\n").ToList(); //loading words in text if (string.IsNullOrEmpty(String.Concat(e.Text))) { syllabelsTextView.Visibility = ViewStates.Gone; //hide syllables edittext if text is empty } else { syllabelsTextView.Visibility = ViewStates.Visible; } foreach (var line in list) { if (!string.IsNullOrWhiteSpace(line)) { syllabelsTextView.Text += SQLiteDb.CountSyllables(line) + "\n"; // adding count of syllables in line } else { syllabelsTextView.Text += 0 + "\n"; } } }
public override void OnBackPressed() // BackPressed or Save button clicked { try { if (string.IsNullOrEmpty(workEditText.Text)) { throw new ArgumentNullException(); // not saving if text is empty } if (work == null) { work = new Work(); // if not loaded creating new work } if (string.IsNullOrEmpty(titleEditText.Text)) { titleEditText.Text = "Nowe dzieło (" + (SQLiteDb.GetWorks().Where(w => w.Title.Contains("Nowe dzieło")).Count() + 1) + ")"; // filling title if empty } if (work.Text != workEditText.Text || work.Title != titleEditText.Text) //saving work if changed or new { work.Text = workEditText.Text; work.Title = titleEditText.Text; work.Modified = DateTime.Now; SQLiteDb.SaveWork(work); } else { throw new ArgumentNullException(); } } catch { Toast.MakeText(this, "Nie zapisano", ToastLength.Short).Show(); } base.OnBackPressed(); }
/// <summary> /// CREATE BLANK SQLITE DATABASE /// </summary> /// <param name="path"></param> static public void CreateTemplatesTable(string path) { if (System.IO.File.Exists(path)) { #if NCORE Console.Clear(); Console.Error.Write("File Exists...\n\"{0}\"", path); #else System.Windows.Forms.MessageBox.Show( string.Format("File Exists...\n\"{0}\"", path), "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error ); #endif return; } using (System.IO.FileStream fs = System.IO.File.Create(path, 0)) { } using (SQLiteDb db = new SQLiteDb(path)) using (DataSet ds = db.Insert("templates", sql_create_templates, SelectTemplatesAdapter)) using (DataView v = ds.GetDataView("templates")) foreach (DataRowView rv in v) { // Templates.Add(TemplateElement.FromRowView(rv)); } }
private void CheckIfDataLoaded() // thread checking if WordLibraries are loaded { Thread dataLoaded = new Thread(dl => { var rhymesLoaded = false; var synonymsLoaded = false; do { if (SQLiteDb.RhymesLoaded()) { rhymesLoaded = true; this.RunOnUiThread(() => { findRhymesButton.SetTextColor(colors); }); } if (SQLiteDb.SynonymsLoaded()) { synonymsLoaded = true; this.RunOnUiThread(() => { findSynonymsButton.SetTextColor(colors); }); } }while (!(rhymesLoaded && synonymsLoaded)); }); dataLoaded.Start(); }
public virtual void Delete(T data) { using (var conn = SQLiteDb.GetConnection()) { conn.Delete <T>(data.Id); } }
public void Update(SQLiteDb.CBParams cb) { using (SQLiteSettingsContext C = SC.NewContext) using (SQLiteDb db = new SQLiteDb(SC.SettingsFile)) { // this.Act1(C,db,defaultaction,cb); } }
public setting GetValue(string name, string grp) { setting s = null; using (SQLiteDb db = new SQLiteDb(datafile)) s = GetValue(db, name, null, grp); return(s); }
public void TestMethod1() { //Produit p = new Produit("58", "aziz", "eeee"); //IDAoImpProduit daopr = new IDAoImpProduit(); //bool veri=daopr.ajout(p); //Assert.IsTrue(veri); //IFakeDAO fake = Substitute.For<ISQliteDB>(); // fake.ajout().Returns(true); // ConsoleProduit d = new ConsoleProduit(); // bool pp = d.ajoutt(fake); // Assert.IsTrue(pp); //Arrange var sqlite = new SQLiteDb(); var productStore = new SQLiteProductStore(sqlite); var pageService = Substitute.For <IPageService>(); var addService = Subtitute.For <IProductStore>(); var vm = new ProductsPageViewModel(productStore, pageService); //Act vm.LoadDataCommand.Execute(null); var x = vm.Products; vm.AddProductCommand.Execute(null); //Assert Assert.IsNotNull(x); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Settings); // Create your application here var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.settingsToolbar); SetSupportActionBar(toolbar); prefs = PreferenceManager.GetDefaultSharedPreferences(this); editor = prefs.Edit(); SupportActionBar.Title = "Ustawienia"; Switch gpsSwitch = FindViewById <Switch>(Resource.Id.gpsSwitch); gpsSwitch.Checked = prefs.GetBoolean("settingsNotifications", true); ChangeText(gpsSwitch); Button logout = FindViewById <Button>(Resource.Id.logOutButton); gpsSwitch.CheckedChange += (o, e) => { editor.PutBoolean("settingsNotifications", e.IsChecked); editor.Apply(); ChangeText(gpsSwitch); }; logout.Click += async(o, e) => { await SQLiteDb.LogOut(); FinishActivity(0); var intent = new Intent(this, typeof(SignInActivity)); StartActivity(intent); Finish(); }; }
public virtual IList <T> List() { using (var conn = SQLiteDb.GetConnection()) { return(conn.Table <T>().ToList()); } }
public virtual void Update(T data) { using (var conn = SQLiteDb.GetConnection()) { conn.Update(data); } }
public virtual T GetById(int id) { using (var conn = SQLiteDb.GetConnection()) { return(conn.Get <T>(id)); } }
public setting SetValue(setting value, bool force) { setting o = value; using (SQLiteDb db = new SQLiteDb(datafile)) o = SetValue(db, value, force); return(o); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.RoomsList); rooms = SQLiteDb.GetRooms(this).ToList(); expandableListView = FindViewById <ExpandableListView>(Resource.Id.roomsExpandableListView); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.roomsListToolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = "Zgłoś zagrożenie"; adapter = new RoomsListAdapter(this, rooms); expandableListView.SetAdapter(adapter); expandableListView.ChildClick += (o, e) => { var roomName = adapter.GetChild(e.GroupPosition, e.ChildPosition).ToString(); var floorName = adapter.GetGroup(e.GroupPosition).ToString(); var intent = new Intent(this, typeof(WriteReportDataActivity)); Bundle extras = new Bundle(); extras.PutString("choosenFloor", floorName); extras.PutString("choosenRoom", roomName); intent.PutExtras(extras); StartActivity(intent); Finish(); }; }
public override DataSet UpdateCategory(string q) { category.Tables.Clear(); using (SQLiteDb db = new SQLiteDb(datafile)) category = db.Delete(Context.CategoryName, q, UpdateCategoryAdapter, UpdateCategoryFillOperation); return(category); }
/// <summary> /// Get the db connection up and running. /// </summary> /// <returns></returns> private async Task CreateDBConnection() { if (_db == null) { _db = await SQLiteDb.DB(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; //DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); //ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); //drawer.AddDrawerListener(toggle); //toggle.SyncState(); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.SetNavigationItemSelectedListener(this); worksList = SQLiteDb.GetWorks(); mainListView = FindViewById <ListView>(Resource.Id.mainListView); mainListView.SetSelection(0); mainListView.ItemClick += MainListView_ItemClick; mainListView.ItemLongClick += MainListView_ItemLongClick; UpdateAdapter(); SQLiteDb.StartApp(this); // starting load words to library }
public virtual T Insert(T data) { using (var conn = SQLiteDb.GetConnection()) { conn.Insert(data); return(data); } }
/// <inheritdoc/> public override DataSet Select(string q) { if (data == null) { data = new DataSet(); } data.Tables.Clear(); using (SQLiteDb db = new SQLiteDb(datafile)) data = db.Select(Context.TableName, q, AdapterSelect, FillSelect); return(data); }
public override DataSet SelectCategory(string q) { category.Tables.Clear(); category.Tables.Add(Context.CategoryName); using (SQLiteDb db = new SQLiteDb(datafile)) category = db.Select(Context.CategoryName, q, SelectCategoryAdapter, SelectCategoryFillOperation); return(category); }
public IList <NFcItem> ListByNFc(int nfcId) { using (var conn = SQLiteDb.GetConnection()) { return(conn.Table <NFcItem>() .Where(item => item.NFcId == nfcId) .ToList()); } }
/// <summary> /// 删除所有数据 /// </summary> public void DeleteAll() { SqlDb db = new SQLiteDb(_connString); db.IsShowSqlToConsole = _isShowSqlToConsole; var dbFactory = db.DbBuilder.DbFactory; var dbOperator = dbFactory.GetDbParamOperator(); var result = db.Delete <UserInfo>("", null); }
public static List <Certificate> Query(string sSerialNo, string sCertData, string sPwd) { SqlDb db = new SQLiteDb(); var dbFactory = db.DbBuilder.DbFactory; var dbOperator = dbFactory.GetDbParamOperator(); var dblist = db.Query <Certificate>("SerialNo,CertData,CommonName", "1>0"); return(dblist); }
public void CreateTable(string dbPath) { if (File.Exists(dbPath)) { File.Delete(dbPath); } SqlDb db = new SQLiteDb(_connString); db.IsShowSqlToConsole = _isShowSqlToConsole; var sql = "create table UserInfo(UserId int not null,UserName varchar(50),Age int,Email varchar(50))"; var result = db.ExecuteNoneQuery(sql, null); }
void Event_ExecuteNonQuery(object sender, RoutedEventArgs args) { if (!database.IsLoaded) { return; } using (var db = new SQLiteDb(database.DataFile)) { try { data = db.Insert(edit.Text, DBInsert); } catch (Exception error) { ThrowException(error, queryError: true); } } }
/// <summary> /// 修改数据 /// </summary> public void Update() { SqlDb db = new SQLiteDb(_connString); db.IsShowSqlToConsole = _isShowSqlToConsole; var dbFactory = db.DbBuilder.DbFactory; var dbOperator = dbFactory.GetDbParamOperator(); //根据修改字段参数及值、过滤SQL、过滤参数修改数据 var result = db.Update <UserInfo>(new { UserName = "******" }, "UserId=4", null); result = db.Update <UserInfo>(new { UserName = "******" }, string.Format("UserId={0}UserId", dbOperator), new { UserId = 4 }); }
public EzServer(EzServerSettings settings) { Settings = settings; LogProvider <EzLogger> .Provider.Configure(Settings); _logger = LogProvider <EzLogger> .GetLogger(this); _handlers = new Dictionary <int, IHandler>(); _server = new AsyncEventServer(Settings.ListenIpAddress, Settings.Port, this, Settings.ServerSettings); Clients = new ClientLookup(); Database = new SQLiteDb(settings.DatabaseSettings.SQLitePath); SessionManager = new SessionManager(); }
public FormSincronizacao() { InitializeComponent(); db = new SQLiteDb(); sincronizacao = db.LeDados <Sincronizacao>(); if (sincronizacao != null) { url.Text = sincronizacao.url; endpoint.Text = sincronizacao.endpoint; acesso.Text = sincronizacao.acesso; } }
public FormLote() { InitializeComponent(); db = new SQLiteDb(); lote = db.LeDados <Lote>(); if (lote != null) { Nome.Text = lote.Nome; Inseminacao.Text = lote.Inseminacao; Dieta.Text = lote.Dieta; Infraestrutura.Text = lote.Infraestrutura; } }
public static object GetMaxId() { string sConn = PlavyConfig.GetConnectionString("db"); SqlDb db = new SQLiteDb(sConn); var dbFactory = db.DbBuilder.DbFactory; var dbOperator = dbFactory.GetDbParamOperator(); var dblist = db.ExecuteScalar("select max(id) from tb_certs"); if (dblist == null) { return(-1); } return(dblist); }