async Task AddMagneticCardNormalGroup() { db = slSecure.DB.GetDB(); //非同步模擬成同步 var q = await db.LoadAsync<tblMagneticCardNormalGroup>(from b in db.GetTblMagneticCardNormalGroupQuery() select b); tblMagneticCardNormalGroup bc = q.Last(); db.tblMagneticCardNormalGroups.Add( new tblMagneticCardNormalGroup() { //NormalID = bc.NormalID + 1, NormalName = txt_NormalName.Text, UpdateDate = DateTime.Now, Memo = tb_Memo.Text } ); try { bool res = await db.SubmitChangesAsync(); MessageBox.Show("新增定期卡群組成功!"); } catch (Exception ex) { MessageBox.Show("Adding Data failed due to " + ex.Message); } }
async void QueryMagneticCardNormalGroup() { db = slSecure.DB.GetDB(); //非同步模擬成同步 var q = await db.LoadAsync<tblMagneticCardNormalGroup>(db.GetTblMagneticCardNormalGroupQuery()); dataGrid.ItemsSource = q; NewMagneticCardNormalGroup(); }
async Task ModifyMagneticCardNormalGroup() { db = slSecure.DB.GetDB(); var normalID = int.Parse(txt_NormalID.Text); //非同步模擬成同步 var q = await db.LoadAsync<tblMagneticCardNormalGroup>(from b in db.GetTblMagneticCardNormalGroupQuery() where b.NormalID == normalID select b); tblMagneticCardNormalGroup bc = q.First(); bc.NormalName = txt_NormalName.Text; bc.UpdateDate = DateTime.Now; bc.Memo = tb_Memo.Text; try { bool res = await db.SubmitChangesAsync(); MessageBox.Show("修改定期卡群組成功!"); } catch (Exception ex) { MessageBox.Show("Data updation failed due to " + ex.Message); } }
async Task DeleteMagneticCardNormalGroup() { db = slSecure.DB.GetDB(); var normalID = int.Parse(txt_NormalID.Text); //非同步模擬成同步 var q = await db.LoadAsync<tblMagneticCardNormalGroup>(from b in db.GetTblMagneticCardNormalGroupQuery() where b.NormalID == normalID select b); tblMagneticCardNormalGroup bc = q.First(); db.tblMagneticCardNormalGroups.Remove(bc); try { bool res = await db.SubmitChangesAsync(); MessageBox.Show("刪除定期卡群組成功!"); } catch (Exception ex) { MessageBox.Show("Data deletion failed due to " + ex.Message); } }