private void btnUpdateInfo_Click(object sender, RoutedEventArgs e) { poi = new WebService.POI(); poi.Poi_ID = Convert.ToInt32(lblHiddenPOIID.Content); poi.Poi_Name = lblUName.Content.ToString(); poi.Poi_Address = tbxUpdateAddress.Text; poi.Poi_Latitude = Convert.ToDouble(tbxUpdateLatitude.Text); poi.Poi_Longitude = Convert.ToDouble(tbxUpdateLongitude.Text); poi.Poi_Descript = tbxUpdateDescription.Text; if (rbStandard.IsChecked == true) { checkPrice = "Standard"; poi.Poi_Price = Convert.ToDouble(tbxUpdateStandard.Text); tbxUpdateChildPrice.Text = ""; tbxUpdateAdultPrice.Text = ""; tbxUpdateElderlyPrice.Text = ""; tbxUpdateStudPrice.Text = ""; Child = Convert.ToDouble(tbxUpdateChildPrice.Text); Adult = Convert.ToDouble(tbxUpdateAdultPrice.Text); Elderly = Convert.ToDouble(tbxUpdateElderlyPrice.Text); Student = Convert.ToDouble(tbxUpdateStudPrice.Text); poi.Poi_Child_Price = Child; poi.Poi_Adult_Price = Adult; poi.Poi_Elderly_Price = Elderly; poi.Poi_Student_Price = Student; } else if (rbPriceCat.IsChecked == true) { checkPrice = "Price Categories"; poi.Poi_Child_Price = Convert.ToDouble(tbxUpdateChildPrice.Text); poi.Poi_Adult_Price = Convert.ToDouble(tbxUpdateAdultPrice.Text); poi.Poi_Elderly_Price = Convert.ToDouble(tbxUpdateElderlyPrice.Text); poi.Poi_Student_Price = Convert.ToDouble(tbxUpdateStudPrice.Text); tbxUpdateStandard.Text = ""; poiPrice = Convert.ToDouble(tbxUpdateStandard.Text); poi.Poi_Price = poiPrice; } poi.Price_Cat = checkPrice; if (bytes != null) { poi.Poi_Img = bytes; } else { poi.Poi_Img = prevBytes; } selected = false; WCF = new WebService.Service1Client(); WCF.UpdatePOIAsync(poi); WCF.UpdatePOICompleted += new EventHandler <UpdatePOICompletedEventArgs>(WCF_UpdatePOICompleted); }
void WCF_checkPOICompleted(object sender, WebService.checkPOICompletedEventArgs e) { if (e.Result == true) { MessageBox.Show("Identical Data found!", "Insert", MessageBoxButton.OK); } else { poiAdd = tbxPOIAddress.Text; poiLat = Convert.ToDouble(tbxPOILatitude.Text); poiLong = Convert.ToDouble(tbxPOILongitude.Text); poiDes = tbxPOIDescription.Text; if (rbStandard.IsChecked == true) { checkPrice = "Standard"; poiPrice = Convert.ToDouble(tbxPOIPrice.Text); } else if (rbPriceCat.IsChecked == true) { checkPrice = "Price Categories"; Child = Convert.ToDouble(tbxPOIChildPrice.Text); Adult = Convert.ToDouble(tbxPOIAdultPrice.Text); Student = Convert.ToDouble(tbxPOIStudentPrice.Text); Elderly = Convert.ToDouble(tbxPOIElderlyPrice.Text); } else if (rbStandard.IsChecked == false && rbPriceCat.IsChecked == false) { MessageBox.Show("Please choose price type and key in the following information!", "Select Price Type", MessageBoxButton.OK); } poiImg = bytes; poi = new WebService.POI(); poi.Poi_Name = poiName; poi.Poi_Address = poiAdd; poi.Poi_Price = poiPrice; poi.Poi_Latitude = poiLat; poi.Poi_Longitude = poiLong; poi.Poi_Descript = poiDes; poi.Poi_Child_Price = Child; poi.Poi_Adult_Price = Adult; poi.Poi_Student_Price = Student; poi.Poi_Elderly_Price = Elderly; poi.Poi_Img = poiImg; poi.Price_Cat = checkPrice; WCF = new WebService.Service1Client(); WCF.InsertPOIAsync(poi); WCF.InsertPOICompleted += new EventHandler <InsertPOICompletedEventArgs>(WCF_InsertPOICompleted); } }
void WCF_retrievePOICompleted(object sender, WebService.retrievePOICompletedEventArgs e) { if (selected == false) { poi = new WebService.POI(); poi = e.Result; if (poi != null) { gridUpdate.Visibility = Visibility.Visible; lblHiddenPOIID.Content = poi.Poi_ID; lblUName.Content = poi.Poi_Name; tbxUpdateAddress.Text = poi.Poi_Address; tbxUpdateLatitude.Text = poi.Poi_Latitude.ToString(); tbxUpdateLongitude.Text = poi.Poi_Longitude.ToString(); tbxUpdateDescription.Text = poi.Poi_Descript; checkPrice = poi.Price_Cat; if (checkPrice.Equals("Standard")) { rBStan.IsChecked = true; tbxUpdateStandard.Text = poi.Poi_Price.ToString(); } else if (checkPrice.Equals("Price Categories")) { rBPriceC.IsChecked = true; tbxUpdateChildPrice.Text = poi.Poi_Child_Price.ToString(); tbxUpdateStudPrice.Text = poi.Poi_Student_Price.ToString(); tbxUpdateAdultPrice.Text = poi.Poi_Adult_Price.ToString(); tbxUpdateElderlyPrice.Text = poi.Poi_Elderly_Price.ToString(); } prevBytes = poi.Poi_Img; tbxSearch.Text = ""; BitmapImage bmpImage = new BitmapImage(); MemoryStream mystream = new MemoryStream(prevBytes); bmpImage.SetSource(mystream); ImgUpdated.Source = bmpImage; btnUpdateInfo.IsEnabled = true; btnBDelete.IsEnabled = true; } else { MessageBox.Show("No Information Found!", "Display Info", MessageBoxButton.OK); } selected = true; } }