private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var driver = listBox.SelectedItem; selectedQueTxtBx.Text = driver.ToString(); DriverName = selectedQueTxtBx.Text; var query1 = conn.Table <TransactionsTable>().Where(t => t.UserName == usr); int k = 0; foreach (var item1 in query1) { k = item1.ID; } // var query3 = conn.Table<CarTable>().Where(t => t.Availability == "A" && t.RegistrationNumber == j); var query2 = conn.Table <DriverTable>().Where(t => t.DUserName == DriverName); string j = ""; foreach (var item4 in query2) { j = item4.DFirstName; } // Debug.WriteLine("tRANSACTIONStABLEcOUNT = " + k); conn.Execute("UPDATE TransactionsTable SET DriverID = ? Where ID = ?", DriverName.ToString(), k); conn.Execute("UPDATE TransactionsTable SET DriverName = ? Where ID = ?", j, k); // conn.Execute("UPDATE TransactionsTable SET CabID = ? Where ID = ?", j, k); //edit2 conn.Execute("UPDATE DriverTable SET DAvailabilityFlag= ? Where DUserName = ?", "Bb", DriverName.ToString()); this.Frame.Navigate(typeof(PaymentPage), k); }
private void SaveButtonExecute() { update(); Database.Execute(string.Format("UPDATE WorkerScheduleTable SET BeginHour='{0}' WHERE Id = {1};", SelectedWorkerSchedule.Start_hour, SelectedWorkerSchedule.Id)); Database.Execute(string.Format("UPDATE WorkerScheduleTable SET EndHour='{0}' WHERE Id = {1};", SelectedWorkerSchedule.End_hour, SelectedWorkerSchedule.Id)); Database.Execute(string.Format("UPDATE WorkerScheduleTable SET Color='{0}' WHERE Id = {1};", SelectedWorkerSchedule.Color, SelectedWorkerSchedule.Id)); Database.Execute(string.Format("UPDATE WorkerScheduleTable SET Output='{0}' WHERE Id = {1};", SelectedWorkerSchedule.Output, SelectedWorkerSchedule.Id)); }
private async void buttonAvailable_Click(object sender, RoutedEventArgs e) { //var query2 = conn.Table<DriverTable>().Where(t => t.DUserName == dristr); var query3 = conn.Table <TransactionsTable>().Where(t => t.DriverId == dristr); foreach (var ite in query3) { cab = ite.CabID; conn.Execute("UPDATE CarTable SET Availability= ? Where RegistrationNumber = ?", "A", cab); } conn.Execute("UPDATE DriverTable SET DAvailabilityFlag= ? Where DUserName = ?", "Aa", dristr); MessageDialog md1 = new MessageDialog("Made Available!"); await md1.ShowAsync(); }
private void SubmitButton_Click(object sender, RoutedEventArgs e) { /* * IDS will contain category id, item id and 1/0. IDS[0] = category Id. IDS[1] = item id. IDS[2] = 1/0. */ conn.Execute("UPDATE Item SET Available = 0"); string[] IDS; foreach (var item in AvailableItem) { IDS = item.Split('_'); conn.Execute("UPDATE Item SET Available = 1 WHERE CategoryId = " + IDS[0] + " AND Id = " + IDS[1]); Debug.WriteLine(IDS[0] + " " + IDS[1]); } }
public void Salvar() { using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(), _caminhoBanco, storeDateTimeAsTicks: false)) { db.Execute("DELETE FROM Estabelecimento"); db.InsertAll(Estabelecimentos); db.Execute("DELETE FROM Gasto"); foreach (var gasto in Gastos) { gasto.EstabelecimentoId = gasto.Estabelecimento.Id; } db.InsertAll(Gastos); } }
//hien thi dialog ve nhan xet luon kalo da an private async void XongBtn_Click(object sender, RoutedEventArgs e) { if (kaloSum == 0) { var ms = new MessageDialog("Bạn nên chọn lượng Kcal nhập vào \nđể thống kê chính xác nhất"); await ms.ShowAsync(); return; } var msKalo = new MessageDialog("Tổng lượng Kcal bạn đã ăn là: " + kaloSum); await msKalo.ShowAsync(); if (muctieu != null && thongkengay != null) { connection.Execute("DELETE FROM ThucDon WHERE IdThongKeNgay =?", thongkengay.IdThongKeNgay); //add cac thuc an da chon vao database foreach (var item in monanChonList) { connection.Insert(item); } thongkengay.LuongKaloDuaVao = connection.ExecuteScalar <double>("SELECT SUM(LuongKalo) FROM THUCDON WHERE IdThongKeNgay =?", thongkengay.IdThongKeNgay); connection.Update(thongkengay); } Frame.Navigate(typeof(TrangChu), nguoidung); }
private async void deleteDriverAdminBtn_Click(object sender, RoutedEventArgs e) { if (dristr == "") { MessageDialog showDialog = new MessageDialog(""); showDialog.Content = "Please Select the User to Delete."; await showDialog.ShowAsync(); } var query = conn.Execute("DELETE From UserTable Where UserName = ?", dristr); if (query != 0) { //Debug.WriteLine(query.ToString()); MessageDialog showDialog1 = new MessageDialog(""); showDialog1.Content = "User Details Deleted"; await showDialog1.ShowAsync(); } if (query == 0 && dristr != "") { MessageDialog showDialog2 = new MessageDialog(""); showDialog2.Content = "User Not Existed"; await showDialog2.ShowAsync(); } }
public void Migrate() { var database = DependencyService.Get <ISQLite> (); SQLite.Net.SQLiteConnection connection = null; if (!database.Exists()) { connection = database.GetConnection(); connection.BeginTransaction(); connection.Execute(@"CREATE TABLE DBVersion (Version INT NOT NULL, ExecutionTime TEXT NOT NULL)" ); connection.Execute("INSERT INTO DBVersion (Version, ExecutionTime) VALUES (?,?)", new object[] { 0, DateTime.Now }); connection.Commit(); } if (connection == null) { connection = database.GetConnection(); } foreach (var migration in Migrations) { int currentVersion = connection.ExecuteScalar <int> ("SELECT Version FROM DBVersion ORDER BY Version DESC LIMIT 1"); if (migration.Key == (currentVersion + 1)) { connection.BeginTransaction(); foreach (var step in migration.Value) { connection.Execute(step); } connection.Execute("INSERT INTO DBVersion (Version, ExecutionTime) VALUES (?,?)", new object[] { migration.Key, DateTime.Now }); connection.Commit(); } } }
private async void CropperDialogPrimaryButton_Click(object sender, RoutedEventArgs e) { var imageSource = EditPicture.ProfilePicture; byte[] imageBuffer; var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; var file = await localFolder.CreateFileAsync("temp.jpg", CreationCollisionOption.ReplaceExisting); try { using (var ras = await file.OpenAsync(FileAccessMode.ReadWrite, StorageOpenOptions.None)) { WriteableBitmap bitmap = imageSource as WriteableBitmap; var stream = bitmap.PixelBuffer.AsStream(); byte[] buffer = new byte[stream.Length]; await stream.ReadAsync(buffer, 0, buffer.Length); BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, ras); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)bitmap.PixelWidth, (uint)bitmap.PixelHeight, 96.0, 96.0, buffer); await encoder.FlushAsync(); var imageStream = ras.AsStream(); imageStream.Seek(0, SeekOrigin.Begin); imageBuffer = new byte[imageStream.Length]; var re = await imageStream.ReadAsync(imageBuffer, 0, imageBuffer.Length); } await file.DeleteAsync(StorageDeleteOption.Default); List <PersonPictures> datalist = conn.Query <PersonPictures>("select * from PersonPictures where pictureName = ?", "picture"); if (datalist != null) { conn.Execute("delete from PersonPictures where pictureName = ?", "picture"); } conn.Insert(new PersonPictures() { pictureName = "picture", picture = imageBuffer }); SetPersonPicture(); PopupNotice popupNotice = new PopupNotice("头像已更新"); popupNotice.ShowAPopup(); } catch { TempPicture.Visibility = Visibility.Visible; EditPicture.Visibility = Visibility.Collapsed; }; CropperDialog.Hide(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.GetType().ToString() == "int") { var query2 = conn.Table <TransactionsTable>().Where(t => ((t.ID == Convert.ToInt16(usrnm.ToString())))); foreach (var item in query2) { usrnm = item.UserName; } Debug.WriteLine(usrnm); Debug.WriteLine(query2); conn.Execute("UPDATE TransactionsTable SET UserName = ? Where ID= ?", usrnm, Convert.ToInt32(e.Parameter.ToString())); } else { usrnm = e.Parameter.ToString(); } }
private static void ExcluirDeputadoFrenquencia(string IdParlamentar) { using (SQLite.Net.SQLiteConnection conexao = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { for (int i = 0; i <= 10; i++) { try { conexao.Execute("delete from DeputadoFrenquencia where IdParlamentar =" + "\"" + IdParlamentar + "\""); break; } catch { Task.Delay(5000); continue; } } } }
private static void ExcluirDeputadoPorEstado(string uf) { using (SQLite.Net.SQLiteConnection conexao = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { for (int i = 0; i <= 10; i++) { try { conexao.Execute("delete from Deputado where Uf =" + "\"" + uf + "\""); break; } catch { Task.Delay(10000); break; } } } }
private static void ExcluirGastoTipoPorDeputado(string idDeputado) { using (SQLite.Net.SQLiteConnection conexao = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { for (int i = 0; i <= 10; i++) { try { conexao.Execute("delete from GastoTipo where idDeputado =" + "\"" + idDeputado + "\""); break; } catch { Task.Delay(5000); continue; } } } }
private static void ExcluirGastoAnoPorDeputado(string idDeputado, string ano) { using (SQLite.Net.SQLiteConnection conexao = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { for (int i = 0; i <= 10; i++) { try { conexao.Execute( String.Format("delete from GastosAno where idDeputado = {0} and Ano = {1}", "\"" + idDeputado + "\"", "\"" + ano + "\"")); break; } catch { Task.Delay(15000); continue; } } } }
private void AddTaskButton_Click(object sender, RoutedEventArgs e) { if (TaskNameTextBox.Text.Equals("")) { PopupNotice popupNotice = new PopupNotice("计划名称不能为空~"); popupNotice.ShowAPopup(); } else { List <ToDoTasks> tempList = conn.Query <ToDoTasks>("select * from ToDoTasks where Name = ?", TaskNameTextBox.Text); if (tempList.Count != 0) { if (tempList[0].IsDelete.Equals("1")) { conn.Execute("update ToDoTasks set Name = ?, Date = ?, Star = ?, Remark = ?, Done = ?, UpdateTime = ?, IsDelete = ? where TaskId = ?", TaskNameTextBox.Text, "", "0", "", "0", DateTime.Now.ToString(), "0", tempList[0].TaskId); ToDoTaskViewModel1.ToDoDatas.Add(new ToDoTasks() { TaskId = tempList[0].TaskId, Name = TaskNameTextBox.Text, Date = "", Remark = "", UpdateTime = DateTime.Now.ToString(), StarVisibility = Visibility.Collapsed, DateVisibility = Visibility.Collapsed, RemarkVisibility = Visibility.Collapsed }); } else { PopupNotice popupNotice0 = new PopupNotice("请勿重复添加计划"); popupNotice0.ShowAPopup(); } } else { string uuid = Guid.NewGuid().ToString(); conn.Insert(new ToDoTasks() { TaskId = uuid, Name = TaskNameTextBox.Text, Date = "", Star = "0", Remark = "", Done = "0", UpdateTime = DateTime.Now.ToString(), IsDelete = "0" }); ToDoTaskViewModel1.ToDoDatas.Add(new ToDoTasks() { TaskId = uuid, Name = TaskNameTextBox.Text, Date = "", Remark = "", UpdateTime = DateTime.Now.ToString(), StarVisibility = Visibility.Collapsed, DateVisibility = Visibility.Collapsed, RemarkVisibility = Visibility.Collapsed }); } PopupNotice popupNotice = new PopupNotice("添加成功"); popupNotice.ShowAPopup(); TaskNameTextBox.Text = ""; } }
private void DeleteContact(object sender, RoutedEventArgs e) { connect.Execute("DELETE FROM Contact"); }
private async void radioButton_Checked(object sender, RoutedEventArgs e) { int rating = 1; if (radioButton.IsChecked == true) { rating = 1; } var query1 = conn.Table <TransactionsTable>().Where(t => t.ID == k1); int k = 0; string st = ""; string st2 = ""; foreach (var item1 in query1) { k = item1.ID; st = item1.DriverId; st2 = item1.CabID; } conn.Execute("UPDATE TransactionsTable SET DriverRating = ? Where ID = ?", rating, k); conn.Execute("UPDATE DriverTable SET DRating = ? Where DUserName = ?", 1, st); conn.Execute("UPDATE DriverTable SET DAvailabilityFlag = ? Where DUserName = ?", "Aa", st); conn.Execute("UPDATE CarTable SET Availability = ? Where RegistrationNumber = ?", "A", st2); var message = new MessageDialog("Driver Rated!"); await message.ShowAsync(); this.Frame.Navigate(typeof(MainPage1), k); }
//private void element_PointerExited(object sender, PointerRoutedEventArgs e) //{ // // Scale back down to 1.0 // CreateOrUpdateSpringAnimation(1.0f); // (sender as UIElement).StartAnimation(_springAnimation); //} private async void MyPersonPicture_Tapped(object sender, TappedRoutedEventArgs e) { var srcImage = new BitmapImage(); FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpeg"); openPicker.FileTypeFilter.Add(".png"); StorageFile file = await openPicker.PickSingleFileAsync(); Picture_file = file; if (file != null) { using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read)) { await srcImage.SetSourceAsync(stream); await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream); } } if (file != null) { var inputFile = SharedStorageAccessManager.AddFile(file); var destination = await ApplicationData.Current.LocalFolder.CreateFileAsync("Cropped.jpg", CreationCollisionOption.ReplaceExisting); var destinationFile = SharedStorageAccessManager.AddFile(destination); var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "Microsoft.Windows.Photos_8wekyb3d8bbwe"; var parameters = new ValueSet(); parameters.Add("InputToken", inputFile); parameters.Add("DestinationToken", destinationFile); parameters.Add("ShowCamera", false); parameters.Add("EllipticalCrop", true); parameters.Add("CropWidthPixals", 300); parameters.Add("CropHeightPixals", 300); var result = await Launcher.LaunchUriForResultsAsync(new Uri("microsoft.windows.photos.crop:"), options, parameters); if (result.Status.Equals(LaunchUriStatus.Success) && result.Result != null) { try { var stream = await destination.OpenReadAsync(); var bitmap = new BitmapImage(); using (var dataRender = new DataReader(stream)) { if (stream.Size == 0) { return; } var imgBytes = new byte[stream.Size]; await dataRender.LoadAsync((uint)stream.Size); dataRender.ReadBytes(imgBytes); List <PersonPictures> datalist = conn.Query <PersonPictures>("select * from PersonPictures where pictureName = ?", "picture"); if (datalist != null) { conn.Execute("delete from PersonPictures where pictureName = ?", "picture"); } conn.Insert(new PersonPictures() { pictureName = "picture", picture = imgBytes }); SetPersonPicture(); } await localFolder.CreateFileAsync("PersonPicture", CreationCollisionOption.ReplaceExisting); } catch (Exception ex) { Debug.WriteLine(ex.Message + ex.StackTrace); } } } }
private void SaveButtonExecute() { update(); Database.Execute(string.Format("UPDATE ShiftTable SET Start_hour='{0}' WHERE ID = {1};", SelectedShift.Start_hour.ToString("c"), SelectedShift.Id)); Database.Execute(string.Format("UPDATE ShiftTable SET End_hour='{0}' WHERE ID = {1};", SelectedShift.End_hour.ToString("c"), SelectedShift.Id)); Database.Execute(string.Format("UPDATE ShiftTable SET Minwo='{0}' WHERE ID = {1};", SelectedShift.Min_workers, SelectedShift.Id)); Database.Execute(string.Format("UPDATE ShiftTable SET Optwo='{0}' WHERE ID = {1};", SelectedShift.Opt_workers, SelectedShift.Id)); if (SelectedShift.Opening_Day[0].IsOpen == true) { Database.Execute(string.Format("UPDATE ShiftTable SET mon = 1 WHERE ID = {0};", SelectedShift.Id)); } else { Database.Execute(string.Format("UPDATE ShiftTable SET mon = 0 WHERE ID = {0};", SelectedShift.Id)); } if (SelectedShift.Opening_Day[1].IsOpen == true) { Database.Execute(string.Format("UPDATE ShiftTable SET tue = 1 WHERE ID = {0};", SelectedShift.Id)); } else { Database.Execute(string.Format("UPDATE ShiftTable SET tue = 0 WHERE ID = {0};", SelectedShift.Id)); } if (SelectedShift.Opening_Day[2].IsOpen == true) { Database.Execute(string.Format("UPDATE ShiftTable SET wed = 1 WHERE ID = {0};", SelectedShift.Id)); } else { Database.Execute(string.Format("UPDATE ShiftTable SET wed = 0 WHERE ID = {0};", SelectedShift.Id)); } if (SelectedShift.Opening_Day[3].IsOpen == true) { Database.Execute(string.Format("UPDATE ShiftTable SET thu = 1 WHERE ID = {0};", SelectedShift.Id)); } else { Database.Execute(string.Format("UPDATE ShiftTable SET thu = 0 WHERE ID = {0};", SelectedShift.Id)); } if (SelectedShift.Opening_Day[4].IsOpen == true) { Database.Execute(string.Format("UPDATE ShiftTable SET fri = 1 WHERE ID = {0};", SelectedShift.Id)); } else { Database.Execute(string.Format("UPDATE ShiftTable SET fri = 0 WHERE ID = {0};", SelectedShift.Id)); } if (SelectedShift.Opening_Day[5].IsOpen == true) { Database.Execute(string.Format("UPDATE ShiftTable SET sat = 1 WHERE ID = {0};", SelectedShift.Id)); } else { Database.Execute(string.Format("UPDATE ShiftTable SET sat = 0 WHERE ID = {0};", SelectedShift.Id)); } if (SelectedShift.Opening_Day[6].IsOpen == true) { Database.Execute(string.Format("UPDATE ShiftTable SET sun = 1 WHERE ID = {0};", SelectedShift.Id)); } else { Database.Execute(string.Format("UPDATE ShiftTable SET sun = 0 WHERE ID = {0};", SelectedShift.Id)); } }
private void SaveButtonExecute() { update(); Database.Execute(string.Format("UPDATE WorkerTable SET Firstname='{0}' WHERE ID = {1};", SelectedWorker.First_name, SelectedWorker.Id)); Database.Execute(string.Format("UPDATE WorkerTable SET Lastname='{0}' WHERE ID = {1};", SelectedWorker.Last_name, SelectedWorker.Id)); }
private void DeleteContact(object sender, RoutedEventArgs e) { connect.Execute("DELETE FROM Contact"); Comment.Text = "Đã xóa tất cả contact"; }