示例#1
0
        private void AddFinallyBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(NewsNameTb.Text) && !string.IsNullOrEmpty(NewsAboutTb.Text))
            {
                NewsNew = new News
                {
                    Name     = NewsNameTb.Text,
                    About    = NewsAboutTb.Text,
                    DateNews = DateTime.Now,
                    Complex  = CurrentComplex
                };

                if (IsSetImage)
                {
                    NewsNew.Image = Utillity.GetInstance().ImageToByte(openFile.FileName);
                }
            }
            else
            {
                return;
            }

            NewRep.Add(NewsNew);
            Close();
        }
 private void SetNews(List <News> news)
 {
     foreach (var item in news)
     {
         NewsUc      newsUc = new NewsUc();
         BitmapImage image  = new BitmapImage();
         if (item.Image != null)
         {
             if (!PreName.Equals(item.Image.Name))
             {
                 image = new BitmapImage();
                 Uri uri = new Uri(System.IO.Path.GetFullPath(Utillity.GetInstance().ByteToImage(item.Image)));
                 image       = new BitmapImage(uri);
                 PreviousImg = uri;
             }
             else
             {
                 image = new BitmapImage(PreviousImg);
             }
             newsUc.FillialTb.Text      = CurrentComplex.Name + " " + CurrentComplex.Address.City.Name + " " + CurrentComplex.Address.Street.Name + " " + CurrentComplex.Address.House;
             newsUc.ImgNews.ImageSource = image;
             newsUc.NewsName.Text       = item.Name;
             PreName = item.Image.Name;
         }
         else
         {
             newsUc.NewsName.Text         = item.Name;
             newsUc.FormForImg.Visibility = Visibility.Collapsed;
         }
         NewsPanel.Children.Add(newsUc);
     }
 }
        public ScheduleOfOneUc(Schedules schedule)
        {
            DataContext = this;
            InitializeComponent();

            Schedule = schedule;
            BitmapImage bit = new BitmapImage(new Uri(Path.GetFullPath(Utillity.GetInstance().ByteToImage(Schedule.Coach.ProfileImg))));

            ProfileImg.ImageSource = bit;
            ProfileNameTb.Text     = $"{Schedule.Coach.Name} {Schedule.Coach.SurName}";
            TimeStart.Text         = Schedule.TimeStart.ToShortTimeString();
            Duration.Text          = Schedule.Duration.ToString() + ".h";
        }
        private void AddFinallyBtn_Click(object sender, RoutedEventArgs e)
        {
            AddedNews = new News
            {
                Name     = NewsNameTb.Text,
                About    = NewsAboutTb.Text,
                DateNews = DateTime.Now
            };

            if (openFile != null)
            {
                if (!openFile.FileName.Equals(string.Empty))
                {
                    AddedNews.Image = Utillity.GetInstance().ImageToByte(openFile.SafeFileName);
                }
            }
            NewsRepository.GetInstance().Add(AddedNews);
        }
示例#5
0
        private void OpenDashboard()
        {
            SolidColorBrush brush = new SolidColorBrush(Color.FromRgb(244, 67, 54));

            if (emailTb.Text.Equals(string.Empty))
            {
                packIcon1.Foreground = brush;
                packIcon1.Opacity    = 1;
                return;
            }
            else if (passBox.Password.Equals(string.Empty))
            {
                packIcon2.Foreground = brush;
                packIcon2.Opacity    = 1;
                return;
            }
            else
            {
                AccountRepository accountRepository = AccountRepository.GetInstance();
                var account = accountRepository.Get(emailTb.Text);
                if (account != null)
                {
                    if (account.Password.Equals(Utillity.GetInstance().GetHash(passBox.Password)))
                    {
                        Complex cmpl = new Complex();

                        var cmplx = ComplexRepository.GetInstance().GetAll();
                        foreach (var item in cmplx)
                        {
                            var staff = item.Staffs.ToList();
                            foreach (var s in staff)
                            {
                                if (s.Account.Login.Equals(account.Login))
                                {
                                    cmpl = item;
                                    break;
                                }
                            }
                        }

                        Main = new MainWindow {
                            CurrentComplex = cmpl
                        };
                        Main.StatusBar.Items.Add(new TextBlock
                        {
                            Text = $"{cmpl.Name + " " + cmpl.Address.City.Name + " " + cmpl.Address.Street.Name + " " + cmpl.Address.House}",
                            HorizontalAlignment = HorizontalAlignment.Right,
                            Margin = new Thickness(500, 0, 0, 0)
                        });
                        Main.Show();
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Wrong password!\nPlease try again", "Error", MessageBoxButton.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Wrong email!\nPlease try again", "Error", MessageBoxButton.OK);
                }
            }
        } //открытие главного окна
        protected override void Seed(DBContext context)
        {
            {
                #region Инициализация комплекса полностью


                Position position = new Position
                {
                    Name = "Тренер"
                };

                Position position2 = new Position
                {
                    Name = "Администартор"
                };



                City city = new City
                {
                    Name = "Днепр"
                };

                City city2 = new City
                {
                    Name = "Киев"
                };

                StreetType streetType = new StreetType
                {
                    NameType = "Проспект"
                };

                streetType = new StreetType
                {
                    NameType = "Улица"
                };

                Streets street = new Streets
                {
                    Name       = "Дмитрия Яворницкого",
                    StreetType = streetType
                };
                context.Entry(city).State       = EntityState.Added;
                context.Entry(city2).State      = EntityState.Added;
                context.Entry(streetType).State = EntityState.Added;
                context.Entry(street).State     = EntityState.Added;
                context.SaveChanges();

                Complex complex = new Complex
                {
                    Name               = "Sport Fit",
                    Images             = new List <Images>(),
                    News               = new List <News>(),
                    AdditionalServices = new List <AdditionalServices>(),
                    Address            = new Address
                    {
                        City   = city,
                        Street = street,
                        House  = "3"
                    }
                };

                Images images = new Images();

                string   path = @"gym.ipg";
                FileInfo fi   = new FileInfo(path);

                images.Name      = fi.Name.Substring(0, fi.Name.LastIndexOf('.'));
                images.Extension = fi.Extension;

                byte[] img;
                using (FileStream fs = new FileStream("gym.jpg", FileMode.Open))
                {
                    img = new byte[fs.Length];
                    fs.Read(img, 0, img.Length);
                }

                images.Link = img;

                complex.Images.Add(images);
                context.Entry(complex).State = EntityState.Added;
                context.SaveChanges();

                #endregion

                #region Инициализация сотрудников

                var pass = Utillity.GetInstance().GetHash("admin");

                Staff admin = new Staff
                {
                    Name           = "Павел",
                    SurName        = "Дуров",
                    PhoneNumber    = "0950505055",
                    WorkExperience = 1.5f,
                    Position       = position2,
                    Account        = new Accounts
                    {
                        Login    = "******",
                        Password = pass
                    },
                    Complex = complex
                };
                context.Entry(admin).State = EntityState.Added;
                context.SaveChanges();

                Staff coach = new Staff
                {
                    Name           = "Oleg",
                    SurName        = "Melnik",
                    PhoneNumber    = "0505555551",
                    WorkExperience = 10,
                    Position       = position,
                    Account        = new Accounts
                    {
                        Login    = "******",
                        Password = "******"
                    },
                    Complex    = complex,
                    ProfileImg = Utillity.GetInstance().ImageToByte(Path.GetFullPath("prof1.jpg"))
                };
                context.Entry(coach).State = EntityState.Added;
                context.SaveChanges();

                coach = new Staff
                {
                    Name           = "Kirill",
                    SurName        = "Goyda",
                    PhoneNumber    = "0505555553",
                    WorkExperience = 2,
                    Position       = position,
                    Account        = new Accounts
                    {
                        Login    = "******",
                        Password = "******"
                    },
                    Complex    = complex,
                    ProfileImg = Utillity.GetInstance().ImageToByte(Path.GetFullPath("prof.jpg"))
                };
                context.Entry(coach).State = EntityState.Added;
                context.SaveChanges();

                AdditionalServices additionalServices = new AdditionalServices
                {
                    Name  = "Pool",
                    Price = 150
                };
                AdditionalServices additionalServices1 = new AdditionalServices
                {
                    Name  = "Yoga",
                    Price = 150
                };
                AdditionalServices additionalServices2 = new AdditionalServices
                {
                    Name  = "Fitnes",
                    Price = 150
                };
                AdditionalServices additionalServices3 = new AdditionalServices
                {
                    Name  = "SPA",
                    Price = 150
                };
                AdditionalServices additionalServices4 = new AdditionalServices
                {
                    Name  = "Sauna",
                    Price = 250
                };
                AdditionalServices additionalServices5 = new AdditionalServices
                {
                    Name  = "Pilates",
                    Price = 255
                };

                context.Entry(additionalServices).State  = EntityState.Added;
                context.Entry(additionalServices1).State = EntityState.Added;
                context.Entry(additionalServices2).State = EntityState.Added;
                context.Entry(additionalServices3).State = EntityState.Added;
                context.Entry(additionalServices4).State = EntityState.Added;
                context.Entry(additionalServices5).State = EntityState.Added;

                context.SaveChanges();

                SubscriptionType subscriptionType = new SubscriptionType
                {
                    Name = "Безлимит"
                };

                Subscriptions subscriptions = new Subscriptions
                {
                    Price            = 350,
                    SubscriptionType = subscriptionType,
                    StartDate        = new DateTime(2018, 12, 04),
                    EndDate          = new DateTime(2019, 01, 04)
                };

                context.Entry(subscriptionType).State = EntityState.Added;
                context.Entry(subscriptions).State    = EntityState.Added;
                context.SaveChanges();

                Schedules schedules = new Schedules
                {
                    TimeStart = new DateTime(2018, 04, 12, 12, 10, 00),
                    Date      = DateTime.Now,
                    Duration  = 1,
                    Coach     = coach,
                    Services  = additionalServices
                };
                context.Entry(schedules).State = EntityState.Added;
                context.SaveChanges();

                schedules = new Schedules
                {
                    TimeStart = new DateTime(2018, 04, 12, 12, 10, 00),
                    Date      = DateTime.Now,
                    Duration  = 1,
                    Coach     = new Staff
                    {
                        Name           = "Oleg",
                        SurName        = "Melnik",
                        PhoneNumber    = "0505555551",
                        WorkExperience = 10,
                        Position       = position,
                        Account        = new Accounts
                        {
                            Login    = "******",
                            Password = "******"
                        },
                        Complex    = complex,
                        ProfileImg = Utillity.GetInstance().ImageToByte(Path.GetFullPath("prof1.jpg"))
                    },
                    Services = additionalServices
                };
                context.Entry(schedules).State = EntityState.Added;
                context.SaveChanges();



                #endregion

                #region Инициализация клиента



                Clients client = new Clients
                {
                    Name        = "Name1",
                    SurName     = "Surname1",
                    PhoneNumber = "05035353535",
                };

                context.Entry(client).State = EntityState.Added;
                context.SaveChanges();



                #endregion

                #region Инициализация Новостей
                Images iMg = Utillity.GetInstance().ImageToByte("gym.jpg");

                context.Entry(iMg).State = EntityState.Added;

                News news = new News
                {
                    Name     = "gick pau",
                    About    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae vestibulum ex. Donec nec ipsum ac ligula pharetra convallis vel at purus. Fusce dignissim ultricies gravida. Duis risus mi, mollis sit amet pulvinar ut, dignissim vitae ex. Vestibulum placerat ligula at aliquam posuere. Nullam vel sagittis libero.",
                    Complex  = complex,
                    DateNews = new DateTime(2018, 12, 05, 13, 11, 00),
                    Image    = iMg
                };
                context.Entry(news).State = EntityState.Added;

                news = new News
                {
                    Name     = "Sale, sale, sale!!!",
                    About    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae vestibulum ex. Donec nec ipsum ac ligula pharetra convallis vel at purus. Fusce dignissim ultricies gravida. Duis risus mi, mollis sit amet pulvinar ut, dignissim vitae ex. Vestibulum placerat ligula at aliquam posuere. Nullam vel sagittis libero.",
                    Complex  = complex,
                    DateNews = new DateTime(2018, 12, 05, 13, 11, 00),
                    Image    = iMg
                };
                context.Entry(news).State = EntityState.Added;

                news = new News
                {
                    Name     = "Sale, sale, sale!!!",
                    About    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae vestibulum ex. Donec nec ipsum ac ligula pharetra convallis vel at purus. Fusce dignissim ultricies gravida. Duis risus mi, mollis sit amet pulvinar ut, dignissim vitae ex. Vestibulum placerat ligula at aliquam posuere. Nullam vel sagittis libero.",
                    Complex  = complex,
                    DateNews = new DateTime(2018, 12, 05, 13, 11, 00),
                    Image    = iMg
                };
                context.Entry(news).State = EntityState.Added;

                context.SaveChanges();
                #endregion

                #region Инициализация Акций
                Stocks stock = new Stocks
                {
                    Name              = "Stock1",
                    AmountOfDiscount  = 25,
                    AdditionalService = additionalServices,
                    About             = "About",
                    StartDate         = new DateTime(2018, 12, 05),
                    EndDate           = new DateTime(2018, 12, 15)
                };
                context.Entry(stock).State = EntityState.Added;
                context.SaveChanges();
                #endregion

                #region Инициализация Заметок
                Tasks task1 = new Tasks
                {
                    Name  = "Task1",
                    About = "About About About About"
                };

                Tasks task2 = new Tasks
                {
                    Name  = "Task2",
                    About = "About About About About About HelloWorld"
                };
                Tasks task3 = new Tasks
                {
                    Name  = "Task3",
                    About = "About About About About About Hello"
                };
                Tasks task4 = new Tasks
                {
                    Name  = "Task4",
                    About = "About About About About About Oleg"
                };
                context.Entry(task1).State = EntityState.Added;
                context.Entry(task2).State = EntityState.Added;
                context.Entry(task3).State = EntityState.Added;
                context.Entry(task4).State = EntityState.Added;
                context.SaveChanges();
                #endregion
                //продолжить инициализацию...
            }
        }
        private void SetCoach()
        {
            CoachesPanel.Children.Clear();
            var schedule = SchedulesRepository.GetInstance().GetAll();

            list      = new List <Schedules>();
            coachList = new List <Staff>();

            foreach (var item in schedule)
            {
                if (item.Date == CalendarSmall.SelectedDate)
                {
                    coachList.Add(item.Coach);
                    list.Add(item);
                }
            }

            foreach (var l in list)
            {
                Expander         exp;
                StackPanel       spCoach = null;
                List <Schedules> listOne;
                foreach (var c in coachList)
                {
                    listOne = list.Where(item => item.Coach.Id == c.Id).ToList();

                    if (l.Coach.Id == c.Id)
                    {
                        if (spCoach is null)
                        {
                            spCoach = new StackPanel {
                                Orientation = Orientation.Horizontal
                            };

                            BitmapImage bitmap;
                            if (File.Exists(c.ProfileImg.Name + c.ProfileImg.Extension))
                            {
                                bitmap = new BitmapImage(new Uri(System.IO.Path.GetFullPath(c.ProfileImg.Name + c.ProfileImg.Extension)));
                            }
                            else
                            {
                                bitmap = new BitmapImage(new Uri(System.IO.Path.GetFullPath(Utillity.GetInstance().ByteToImage(c.ProfileImg))));
                            }

                            spCoach.Children.Add(new Ellipse
                            {
                                Width  = 60,
                                Height = 60,
                                Fill   = new ImageBrush(bitmap)
                            });

                            spCoach.Children.Add(new TextBlock
                            {
                                Text = c.Name + " " + c.SurName,
                                VerticalAlignment = VerticalAlignment.Center,
                                Margin            = new Thickness(15, 0, 0, 0),
                                FontSize          = 18,
                            });
                        }

                        exp = new Expander
                        {
                            Header      = spCoach,
                            Content     = SetGraficOfOne(listOne),
                            DataContext = c.Id
                        };
                        CoachesPanel.Children.Add(exp);
                    }
                }
            }
        }