private void SaveFileToDatabase() { try { string filename = File_image; // получаем короткое имя файла для сохранения в бд string shortFileName = filename.Substring(filename.LastIndexOf('\\') + 1); byte[] imageData; using (System.IO.FileStream fs = new System.IO.FileStream(filename, FileMode.Open)) { imageData = new byte[fs.Length]; fs.Read(imageData, 0, imageData.Length); } Dickript.SelectAll(); string diskript = Dickript.Selection.Text; Restoran restoran = new Restoran(filename, imageData, Name.Text, SelectItems, Work_time.Text, Sity.Text, Street.Text, StartPrice.Text, diskript, Cord.Text); RepositoryClass repository = new RepositoryClass(); repository.PushRest(restoran); Get_image.Background = new SolidColorBrush(Color.FromRgb(33, 150, 243)); Get_image.BorderBrush = new SolidColorBrush(Color.FromRgb(33, 150, 243)); Get_image.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)); } catch { MessageBox.Show("Error"); } }
private void DeleteGrid_MouseDown(object sender, MouseButtonEventArgs e) { RepositoryClass repositoryClass = new RepositoryClass(); NotificationWindow notificationWindow = new NotificationWindow(); if (notificationWindow.ShowDialog() == true) { repositoryClass.DeleteComment(comment.Text, NameRest); } }
private void Grid_MouseDown_1(object sender, MouseButtonEventArgs e) { RepositoryClass repository = new RepositoryClass(); NotificationWindow notificationWindow = new NotificationWindow(); if (notificationWindow.ShowDialog() == true) { repository.DeleteRest(Name_Of_Rest.Content.ToString()); } }
private void LoadData() { string time = DateTime.Now.ToShortTimeString(); RepositoryClass repositoryClass = new RepositoryClass(); Stack <Restoran> restorans = repositoryClass.LoadRest(); foreach (Restoran restoran in restorans) { MemoryStream ms = new MemoryStream(restoran.imagedata); System.Drawing.Image newImage = System.Drawing.Image.FromStream(ms); UserControl1 userControl1 = new UserControl1(); string[] vs = time.Split(':'); string[] worktime = restoran.WorkTime.Split('-'); string[] startWork = worktime[0].Split(':'); string[] Endwork = worktime[1].Split(':'); if (Convert.ToInt32(Endwork[0]) < Convert.ToInt32(startWork[0])) { Endwork[0] = (Convert.ToInt32(Endwork[0]) + 24).ToString(); } if (Convert.ToInt32(startWork[0]) <= Convert.ToInt32(vs[0]) && Convert.ToInt32(Endwork[0]) >= Convert.ToInt32(vs[0])) { if (Convert.ToInt32(startWork[1]) <= Convert.ToInt32(vs[1]) && Convert.ToInt32(Endwork[1]) >= Convert.ToInt32(vs[1])) { userControl1.Button_time.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(21, 212, 79)); userControl1.Button_time.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(21, 212, 79)); } } else { userControl1.Button_time.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(237, 17, 17)); userControl1.Button_time.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(237, 17, 17)); userControl1.Clock_name.Text = "Close"; } BitmapImage bi = new BitmapImage(); bi.BeginInit(); MemoryStream ms2 = new MemoryStream(); newImage.Save(ms2, System.Drawing.Imaging.ImageFormat.Bmp); ms2.Seek(0, SeekOrigin.Begin); bi.StreamSource = ms2; bi.EndInit(); userControl1.im.Source = bi; userControl1.Name_Of_Rest.Content = restoran.Name; Wrap.Children.Add(userControl1); } }
public void Find() { RepositoryClass repositoryClass = new RepositoryClass(); Stack <Restoran> restorans = repositoryClass.SearchRest(Text_find.Text); foreach (Restoran restoran in restorans) { MemoryStream ms = new MemoryStream(restoran.imagedata); System.Drawing.Image newImage = System.Drawing.Image.FromStream(ms); UserControl1 userControl1 = new UserControl1(); BitmapImage bi = new BitmapImage(); bi.BeginInit(); MemoryStream ms2 = new MemoryStream(); newImage.Save(ms2, System.Drawing.Imaging.ImageFormat.Bmp); ms2.Seek(0, SeekOrigin.Begin); bi.StreamSource = ms2; bi.EndInit(); userControl1.im.Source = bi; userControl1.Name_Of_Rest.Content = restoran.Name; time = DateTime.Now.ToShortTimeString(); string DBTIME = restoran.WorkTime; if (CheckTime.IsChecked == true) { Time_Work(time, DBTIME); } if (flag) { if (SelectItems == null) { Result_panel.Children.Add(userControl1); } else { if (restoran.Type == SelectItems) { Result_panel.Children.Add(userControl1); } } } flag = true; } }
private void Wrap_Loaded(object sender, RoutedEventArgs e) { RepositoryClass repository = new RepositoryClass(); Stack <Restoran> restorans = repository.LoadRest(); foreach (Restoran r in restorans) { MemoryStream ms = new MemoryStream(r.imagedata); System.Drawing.Image newImage = System.Drawing.Image.FromStream(ms); UserControl1 userControl1 = new UserControl1(); BitmapImage bi = new BitmapImage(); bi.BeginInit(); MemoryStream ms2 = new MemoryStream(); newImage.Save(ms2, System.Drawing.Imaging.ImageFormat.Bmp); ms2.Seek(0, SeekOrigin.Begin); bi.StreamSource = ms2; bi.EndInit(); userControl1.im.Source = bi; userControl1.Name_Of_Rest.Content = r.Name; Result_panel.Children.Add(userControl1); } }
public void Find() { RepositoryClass repositoryClass = new RepositoryClass(); Stack <Restoran> restorans = repositoryClass.SearchRest(Name_Of_Rest.Content.ToString()); foreach (Restoran restoran in restorans) { PagesofRest pagesofRest = new PagesofRest(); pagesofRest.Images.Source = this.im.Source; pagesofRest.Images.HorizontalAlignment = HorizontalAlignment.Left; pagesofRest.Rest_name.Content = restoran.Name; pagesofRest.Location.Text = restoran.Street; pagesofRest.Discription_blok.Text = restoran.Disk; string type = restoran.Type; pagesofRest.Types.Source = new BitmapImage(new Uri(ChoiceIconf(type), UriKind.Relative)); pagesofRest.Price.Text = restoran.Price; pagesofRest.time_of_work.Text = restoran.WorkTime; string time = DateTime.Now.ToShortTimeString(); Time_Work(time, pagesofRest.time_of_work.Text); string Cordinate = restoran.Cord; string[] Cordinatesplit = Cordinate.Split(','); CultureInfo et = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); double x = double.Parse(Cordinatesplit[0]); Thread.CurrentThread.CurrentCulture = et; CultureInfo et2 = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); double y = double.Parse(Cordinatesplit[1]); Thread.CurrentThread.CurrentCulture = et; pagesofRest.Second_name.Text = Name_Of_Rest.Content.ToString(); pagesofRest.Loadmap(x, y); MainWindow window = (MainWindow)Application.Current.MainWindow; window.GridMain.Children.Clear(); window.GridMain.Children.Add(pagesofRest); } }
public void LoadMap(double x, double y) { GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache; // choose your provider here mapView.MapProvider = GMapProviders.GoogleMap; mapView.Position = new PointLatLng(x, y); mapView.MinZoom = 12; mapView.MaxZoom = 17; GMapMarker gMapMarker; RepositoryClass repository = new RepositoryClass(); Stack <Restoran> restorans = repository.LoadRest(); foreach (Restoran r in restorans) { string time = DateTime.Now.ToShortTimeString(); UserControl1 userControl1 = new UserControl1(); string[] vs = time.Split(':'); string[] worktime = r.WorkTime.Split('-'); string[] startWork = worktime[0].Split(':'); string[] Endwork = worktime[1].Split(':'); if (Convert.ToInt32(Endwork[0]) < Convert.ToInt32(startWork[0])) { Endwork[0] = (Convert.ToInt32(Endwork[0]) + 24).ToString(); } if (Convert.ToInt32(startWork[0]) <= Convert.ToInt32(vs[0]) && Convert.ToInt32(Endwork[0]) >= Convert.ToInt32(vs[0])) { if (Convert.ToInt32(startWork[1]) <= Convert.ToInt32(vs[1]) && Convert.ToInt32(Endwork[1]) >= Convert.ToInt32(vs[1])) { userControl1.Button_time.Foreground = new SolidColorBrush(Color.FromRgb(21, 212, 79)); userControl1.Button_time.BorderBrush = new SolidColorBrush(Color.FromRgb(21, 212, 79)); } } else { userControl1.Button_time.Foreground = new SolidColorBrush(Color.FromRgb(237, 17, 17)); userControl1.Button_time.BorderBrush = new SolidColorBrush(Color.FromRgb(237, 17, 17)); userControl1.Clock_name.Text = "Close"; } MemoryStream ms = new MemoryStream(r.imagedata); System.Drawing.Image newImage = System.Drawing.Image.FromStream(ms); BitmapImage bi = new BitmapImage(); bi.BeginInit(); MemoryStream ms2 = new MemoryStream(); newImage.Save(ms2, System.Drawing.Imaging.ImageFormat.Bmp); ms2.Seek(0, SeekOrigin.Begin); bi.StreamSource = ms2; bi.EndInit(); userControl1.im.Source = bi; userControl1.Name_Of_Rest.Content = r.Name; userControl1.MainGrid.Width = 250; userControl1.MainGrid.Height = 250; Thickness thickness = new Thickness(0, 0, 0, 0); userControl1.MainGrid.Margin = thickness; string[] cord = r.Cord.Split(','); CultureInfo et = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); double Lang = double.Parse(cord[0]); Thread.CurrentThread.CurrentCulture = et; CultureInfo et2 = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); double Lant = double.Parse(cord[1]); Thread.CurrentThread.CurrentCulture = et; gMapMarker = new GMapMarker(new PointLatLng(Lang, Lant)); marker marker = new marker(); marker.Stack.Children.Add(userControl1); marker.NameRest.Text = r.Name; gMapMarker.Shape = marker; mapView.Markers.Add(gMapMarker); } // whole world zoom mapView.Zoom = 17; if (flag) { // lets the map use the mousewheel to zoom mapView.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter; // lets the user drag the map mapView.CanDragMap = true; // lets the user drag the map with the left mouse button mapView.DragButton = MouseButton.Left; } }