예제 #1
0
        /// <summary>
        /// Добавления данных в определённую таблицу БД, ведённых пользователем!!!
        /// </summary>

        private void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_contex.Name))
            {
                errors.AppendLine("Укажите название жанра");
            }

            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }

            if (_contex.id_Genre == 0)
            {
                BusinessLibraryEntities.GetContex().Genre.Add(_contex);
            }

            try
            {
                BusinessLibraryEntities.GetContex().SaveChanges();
                MessageBox.Show("Информацию сохранена!!!");
                AddFrame.frame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #2
0
        /// <summary>
        /// Экспорт в отчёт Excel
        /// </summary>

        private void btn_excel_Click(object sender, RoutedEventArgs e)
        {
            var allusers = BusinessLibraryEntities.GetContex().Avtor.ToList().OrderBy(p => p.Name).ToList();

            var aplication = new Excel.Application();

            aplication.SheetsInNewWorkbook = allusers.Count();

            Excel.Workbook workbook = aplication.Workbooks.Add(Type.Missing);

            int StartRowIndex = 1;

            for (int i = 0; i < allusers.Count(); i++)
            {
                Excel.Worksheet worksheets = aplication.Worksheets.Item[i + 1];
                worksheets.Name = allusers[i].Name;

                worksheets.Cells[1][StartRowIndex] = "Имя Автора";

                StartRowIndex++;

                foreach (var date in BusinessLibraryEntities.GetContex().Avtor)
                {
                    worksheets.Cells[1][StartRowIndex] = date.Name;

                    StartRowIndex++;
                }

                worksheets.Columns.AutoFit();
            }

            aplication.Visible = true;
        }
예제 #3
0
        /// <summary>
        ///  Обновление данных на странице при добавление, удаление, редактирование!!!
        /// </summary>

        private void Page_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (Visibility == Visibility.Visible)
            {
                BusinessLibraryEntities.GetContex().ChangeTracker.Entries().ToList().ForEach(p => p.Reload());
                datagrid.ItemsSource = BusinessLibraryEntities.GetContex().Avtor.ToList();
            }
        }
예제 #4
0
        /// <summary>
        ///  Поиск(фильтрация) данных по Имени поля
        /// </summary>

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            string serch = Txtext.Text;
            List <CourseLibrary.Avtor> avtors = BusinessLibraryEntities.GetContex().Avtor.ToList();

            avtors = avtors.Where(a => a.Name.ToLower().Contains(serch.ToLower())).ToList();
            datagrid.ItemsSource = avtors.ToList();
        }
예제 #5
0
        /// <summary>
        ///  Поиск(фильтрация) данных по Имени поля
        /// </summary>

        private void Txtext_TextChanged(object sender, TextChangedEventArgs e)
        {
            string         serch = Txtext.Text;
            List <Student> stud  = BusinessLibraryEntities.GetContex().Student.ToList();

            stud = stud.Where(a => a.Name.ToLower().Contains(serch.ToLower())).ToList();
            datagrid.ItemsSource = stud.ToList();
        }
예제 #6
0
        /// <summary>
        ///  Поиск(фильтрация) данных по Имени поля
        /// </summary>

        private void Txtext_TextChanged(object sender, TextChangedEventArgs e)
        {
            string serch = Txtext.Text;
            List <CourseLibrary.Avtorization> admin = BusinessLibraryEntities.GetContex().Avtorizations.ToList();

            admin = admin.Where(a => a.Login.ToLower().Contains(serch.ToLower())).ToList();
            datagrid.ItemsSource = admin.ToList();
        }
예제 #7
0
        /// <summary>
        ///  Редактирование записи
        /// </summary>

        private void btn_bild_Click(object sender, RoutedEventArgs e)
        {
            AddFrame.frame.Navigate(new AddPages.PStudent((sender as Button).DataContext as CourseLibrary.Student));
            var ForRemoving = datagrid.SelectedItems.Cast <CourseLibrary.Student>().ToList(); //Выделение полей для удаления

            BusinessLibraryEntities.GetContex().Student.RemoveRange(ForRemoving);
            BusinessLibraryEntities.GetContex().SaveChanges();
        }
예제 #8
0
        /// <summary>
        ///  Поиск(фильтрация) данных по Имени поля
        /// </summary>

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            string      serch = Txtext.Text;
            List <Book> books = BusinessLibraryEntities.GetContex().Books.ToList();

            books = books.Where(a => a.Name.ToLower().Contains(serch.ToLower())).ToList();
            datagrid.ItemsSource = books.ToList();
        }
예제 #9
0
        /// <summary>
        ///  Обьявления экземпляра нужной таблицы из БД, для манипуляциями самих данных
        /// </summary>

        public PStudent(Student selectStud)
        {
            InitializeComponent();

            if (selectStud != null)
            {
                _contex = selectStud;
            }

            DataContext            = _contex;
            CMDaddress.ItemsSource = BusinessLibraryEntities.GetContex().Address.ToList();
            CMDbook.ItemsSource    = BusinessLibraryEntities.GetContex().Books.ToList();
        }
예제 #10
0
        /// <summary>
        ///  Обьявления экземпляра нужной таблицы из БД, для манипуляциями самих данных
        /// </summary>

        public PAvtorization(Avtorization selectedAvtoriz)
        {
            InitializeComponent();

            if (selectedAvtoriz != null)
            {
                selectedAvtoriz = __contex;
            }

            this.DataContext = selectedAvtoriz;

            cmb_profer.ItemsSource = BusinessLibraryEntities.GetContex().Profer.ToList();

            DataContext = __contex;
        }
예제 #11
0
        /// <summary>
        ///  Обьявления экземпляра нужной таблицы из БД, для манипуляциями самих данных
        /// </summary>

        public PAccounting(Accounting selectedAccounting)
        {
            InitializeComponent();

            if (selectedAccounting != null)
            {
                __contex = selectedAccounting;
            }

            cmb_profer.ItemsSource = BusinessLibraryEntities.GetContex().Profer.ToList();
            cmb_stud.ItemsSource   = BusinessLibraryEntities.GetContex().Student.ToList();
            cmb_book.ItemsSource   = BusinessLibraryEntities.GetContex().Books.ToList();

            DataContext = __contex;
        }
예제 #12
0
        /// <summary>
        ///  Обьявления экземпляра нужной таблицы из БД, для манипуляциями самих данных
        /// </summary>

        public Pbook(Book selectedBook)
        {
            InitializeComponent();

            if (selectedBook != null)
            {
                selectedBook = __contex;
            }

            this.DataContext = selectedBook;

            cmb_genre.ItemsSource = BusinessLibraryEntities.GetContex().Genre.ToList();
            cmb_avtor.ItemsSource = BusinessLibraryEntities.GetContex().Avtor.ToList();

            DataContext = __contex;
        }
예제 #13
0
        /// <summary>
        /// Добавления данных в определённую таблицу БД, ведённых пользователем!!!
        /// </summary>

        private void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_contex.Name))
            {
                errors.AppendLine("Укажите Имя");
            }

            if (string.IsNullOrWhiteSpace(_contex.FName))
            {
                errors.AppendLine("Укажите Фамилия");
            }

            if (string.IsNullOrWhiteSpace(_contex.LName))
            {
                errors.AppendLine("Укажите Отчество");
            }

            if (string.IsNullOrWhiteSpace(_contex.Specialty))
            {
                errors.AppendLine("Укажите название Специальности");
            }

            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }

            if (_contex.id_Profer == 0)
            {
                BusinessLibraryEntities.GetContex().Profer.Add(_contex);
            }

            try
            {
                BusinessLibraryEntities.GetContex().SaveChanges();
                MessageBox.Show("Информацию сохранена!!!");
                AddFrame.frame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #14
0
        /// <summary>
        /// Экспорт в отчёт Excel
        /// </summary>

        private void btn_excel_Click(object sender, RoutedEventArgs e)
        {
            var allusers = BusinessLibraryEntities.GetContex().Student.ToList().OrderBy(p => p.FName).ToList();

            var aplication = new Excel.Application();

            aplication.SheetsInNewWorkbook = allusers.Count();

            Excel.Workbook workbook = aplication.Workbooks.Add(Type.Missing);

            int StartRowIndex = 1;

            for (int i = 0; i < allusers.Count(); i++)
            {
                Excel.Worksheet worksheets = aplication.Worksheets.Item[i + 1];
                worksheets.Name = allusers[i].FName;

                worksheets.Cells[1][StartRowIndex] = "Имя";
                worksheets.Cells[2][StartRowIndex] = "Фамилия";
                worksheets.Cells[3][StartRowIndex] = "Очество";
                worksheets.Cells[4][StartRowIndex] = "Серия паспорта";
                worksheets.Cells[5][StartRowIndex] = "Телефон";
                worksheets.Cells[6][StartRowIndex] = "Адрес";
                worksheets.Cells[7][StartRowIndex] = "Книга";

                StartRowIndex++;

                foreach (var date in BusinessLibraryEntities.GetContex().Student)
                {
                    worksheets.Cells[1][StartRowIndex] = date.Name;
                    worksheets.Cells[2][StartRowIndex] = date.FName;
                    worksheets.Cells[3][StartRowIndex] = date.LName;
                    worksheets.Cells[4][StartRowIndex] = date.Pasport_seria;
                    worksheets.Cells[5][StartRowIndex] = date.Telephone;
                    worksheets.Cells[6][StartRowIndex] = date.Address.Strets;
                    worksheets.Cells[7][StartRowIndex] = date.Book.Name;

                    StartRowIndex++;
                }

                worksheets.Columns.AutoFit();
            }

            aplication.Visible = true;
        }
예제 #15
0
        /// <summary>
        /// Добавления данных в определённую таблицу БД, ведённых пользователем!!!
        /// </summary>

        private void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var _contex = new Avtorization();
                BusinessLibraryEntities.GetContex().Avtorizations.Add(_contex);
                _contex.Login    = login.Text;
                _contex.Password = password.Text;
                _contex.Profer   = (Profer)cmb_profer.SelectedItem;
                BusinessLibraryEntities.GetContex().SaveChanges();
                MessageBox.Show("Информацию сохранена!!!");
                AddFrame.frame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #16
0
        /// <summary>
        /// Экспорт в отчёт Excel
        /// </summary>

        private void btn_excel_Click(object sender, RoutedEventArgs e)
        {
            var allusers = BusinessLibraryEntities.GetContex().Accounting.ToList().OrderBy(p => p.DateOfIssue).ToList();

            var aplication = new Excel.Application();

            aplication.SheetsInNewWorkbook = allusers.Count();

            Excel.Workbook workbook = aplication.Workbooks.Add(Type.Missing);

            int StartRowIndex = 1;

            for (int i = 0; i < allusers.Count(); i++)
            {
                Excel.Worksheet worksheets = aplication.Worksheets.Item[i + 1];
                worksheets.Name = allusers[i].NumberOfBooks;

                worksheets.Cells[1][StartRowIndex] = "Руководитель";
                worksheets.Cells[2][StartRowIndex] = "Студент";
                worksheets.Cells[3][StartRowIndex] = "Книга";
                worksheets.Cells[4][StartRowIndex] = "Дата выдачи";
                worksheets.Cells[5][StartRowIndex] = "Дата принятия";
                worksheets.Cells[6][StartRowIndex] = "Количество книг";

                StartRowIndex++;

                foreach (var date in BusinessLibraryEntities.GetContex().Accounting)
                {
                    worksheets.Cells[1][StartRowIndex] = date.Profer.Name;
                    worksheets.Cells[2][StartRowIndex] = date.Student.Name;
                    worksheets.Cells[3][StartRowIndex] = date.Book.Name;
                    worksheets.Cells[4][StartRowIndex] = date.DateOfIssue.ToString("dd.MM.yyyy HH:mm");
                    worksheets.Cells[5][StartRowIndex] = date.DateOfAdoption;
                    worksheets.Cells[6][StartRowIndex] = date.NumberOfBooks;

                    StartRowIndex++;
                }

                worksheets.Columns.AutoFit();
            }

            aplication.Visible = true;
        }
예제 #17
0
        /// <summary>
        /// Добавления данных в определённую таблицу БД, ведённых пользователем!!!
        /// </summary>

        private void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var _contex = new Accounting();
                BusinessLibraryEntities.GetContex().Accounting.Add(_contex);
                _contex.Profer        = (Profer)cmb_profer.SelectedItem;
                _contex.Student       = (Student)cmb_stud.SelectedItem;
                _contex.Book          = (Book)cmb_book.SelectedItem;
                _contex.NumberOfBooks = Numberbook.Text;
                BusinessLibraryEntities.GetContex().SaveChanges();
                MessageBox.Show("Информацию сохранена!!!");
                AddFrame.frame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #18
0
        /// <summary>
        /// Добавления данных в определённую таблицу БД, ведённых пользователем!!!
        /// </summary>

        private void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var _contex = new Book();
                BusinessLibraryEntities.GetContex().Books.Add(_contex);
                _contex.Name          = NameB.Text;
                _contex.Genre         = (Genre)cmb_genre.SelectedItem;
                _contex.Avtor         = (Avtor)cmb_avtor.SelectedItem;
                _contex.NumberOfLines = numberoflines.Text;
                _contex.Amount        = amount.Text;
                BusinessLibraryEntities.GetContex().SaveChanges();
                MessageBox.Show("Информацию сохранена!!!");
                AddFrame.frame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #19
0
        /// <summary>
        ///  Удаление записи
        /// </summary>

        private void Btn_delete_Click(object sender, RoutedEventArgs e)
        {
            var ForRemoving = datagrid.SelectedItems.Cast <CourseLibrary.Avtor>().ToList(); //Выделение полей для удаления

            if (MessageBox.Show($"Вы точно хотите удалить следущие {ForRemoving.Count()} Элементов???", "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                try
                {
                    BusinessLibraryEntities.GetContex().Avtor.RemoveRange(ForRemoving);
                    BusinessLibraryEntities.GetContex().SaveChanges();
                    MessageBox.Show("Данные удалены!!!");

                    datagrid.ItemsSource = BusinessLibraryEntities.GetContex().Avtor.ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
예제 #20
0
        /// <summary>
        /// Экспорт в отчёт Excel
        /// </summary>

        private void btn_excel_Click(object sender, RoutedEventArgs e)
        {
            var allusers = BusinessLibraryEntities.GetContex().Books.ToList().OrderBy(p => p.Name).ToList();

            var aplication = new Excel.Application();

            aplication.SheetsInNewWorkbook = allusers.Count();

            Excel.Workbook workbook = aplication.Workbooks.Add(Type.Missing);

            int StartRowIndex = 1;

            for (int i = 0; i < allusers.Count(); i++)
            {
                Excel.Worksheet worksheets = aplication.Worksheets.Item[i + 1];
                worksheets.Name = allusers[i].Name;

                worksheets.Cells[1][StartRowIndex] = "Имя";
                worksheets.Cells[2][StartRowIndex] = "Жанр";
                worksheets.Cells[3][StartRowIndex] = "Автор";
                worksheets.Cells[4][StartRowIndex] = "Колчиство страниц в книге";
                worksheets.Cells[5][StartRowIndex] = "Количество книг";

                StartRowIndex++;

                foreach (var date in BusinessLibraryEntities.GetContex().Books)
                {
                    worksheets.Cells[1][StartRowIndex] = date.Name;
                    worksheets.Cells[2][StartRowIndex] = date.Genre.Name;
                    worksheets.Cells[3][StartRowIndex] = date.Avtor.Name;
                    worksheets.Cells[4][StartRowIndex] = date.NumberOfLines;
                    worksheets.Cells[5][StartRowIndex] = date.Amount;

                    StartRowIndex++;
                }

                worksheets.Columns.AutoFit();
            }

            aplication.Visible = true;
        }
예제 #21
0
        /// <summary>
        /// Добавления данных в определённую таблицу БД, ведённых пользователем!!!
        /// </summary>

        private void Btn_save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var __contex = new Student();
                BusinessLibraryEntities.GetContex().Student.Add(__contex);
                __contex.Name          = Name.Text;
                __contex.FName         = FName.Text;
                __contex.LName         = LName.Text;
                __contex.Pasport_seria = PsP.Text;
                __contex.Telephone     = Tel.Text;
                __contex.Address       = (Address)CMDaddress.SelectedItem;
                __contex.Book          = (Book)CMDbook.SelectedItem;
                BusinessLibraryEntities.GetContex().SaveChanges();
                MessageBox.Show("Информацию сохранена!!!");
                AddFrame.frame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #22
0
        /// <summary>
        /// Экспорт в отчёт Excel
        /// </summary>

        private void btn_excel_Click(object sender, RoutedEventArgs e)
        {
            var allusers = BusinessLibraryEntities.GetContex().Profer.ToList().OrderBy(p => p.FName).ToList();

            var aplication = new Excel.Application();

            aplication.SheetsInNewWorkbook = allusers.Count();

            Excel.Workbook workbook = aplication.Workbooks.Add(Type.Missing);

            int StartRowIndex = 1;

            for (int i = 0; i < allusers.Count(); i++)
            {
                Excel.Worksheet worksheets = aplication.Worksheets.Item[i + 1];
                worksheets.Name = allusers[i].FName;

                worksheets.Cells[1][StartRowIndex] = "Имя";
                worksheets.Cells[2][StartRowIndex] = "Фамилия";
                worksheets.Cells[3][StartRowIndex] = "Отчество";
                worksheets.Cells[4][StartRowIndex] = "Специальность";

                StartRowIndex++;

                foreach (var date in BusinessLibraryEntities.GetContex().Profer)
                {
                    worksheets.Cells[1][StartRowIndex] = date.Name;
                    worksheets.Cells[2][StartRowIndex] = date.FName;
                    worksheets.Cells[3][StartRowIndex] = date.LName;
                    worksheets.Cells[4][StartRowIndex] = date.Specialty;

                    StartRowIndex++;
                }

                worksheets.Columns.AutoFit();
            }

            aplication.Visible = true;
        }
예제 #23
0
 public Students()
 {
     InitializeComponent();
     datagrid.ItemsSource = BusinessLibraryEntities.GetContex().Student.ToList();
 }
예제 #24
0
 public accountOtch()
 {
     InitializeComponent();
     datagrid.ItemsSource = BusinessLibraryEntities.GetContex().Accounting.ToList();
 }
예제 #25
0
 public Books1()
 {
     InitializeComponent();
     datagrid.ItemsSource = BusinessLibraryEntities.GetContex().Books.ToList();
 }
예제 #26
0
 public Avtor()
 {
     InitializeComponent();
     datagrid.ItemsSource = BusinessLibraryEntities.GetContex().Avtor.ToList();
 }