public string ToBib()
        {
            var bib = new StringBuilder("");

            if (listBox.SelectedItems.Count == 0)
            {
                MessageBox.Show("Select an article/s!");
            }

            foreach (Articles a in listBox.SelectedItems)
            {
                bib.Append("@article{");
                bib.Append(GetKey(a));
                bib.Append(",");
                bib.Append(LineFeed);
                bib.Append(Retract);
                bib.Append("author = {");
                var str = DbDataAccess.GetAuthorsOfArticle(a.Id);
                foreach (Authors au in str)
                {
                    bib.Append(au.Author);
                }
                bib.Append("},");
                bib.Append(LineFeed);
                bib.Append(Retract);
                bib.Append("title = {");
                bib.Append(a.Title);
                bib.Append("},");
                bib.Append(LineFeed);
                bib.Append(Retract);
                bib.Append("journal = {");
                bib.Append(a.Journal);
                bib.Append("},");
                bib.Append(LineFeed);
                bib.Append(Retract);
                bib.Append("year = ");
                bib.Append(a.Year.ToString());
                bib.Append(",");
                bib.Append(LineFeed);
                bib.Append(Retract);
                bib.Append("number = ");
                bib.Append(a.Number.ToString());
                bib.Append(",");
                bib.Append(LineFeed);
                bib.Append(Retract);
                bib.Append("pages = {");
                bib.Append(a.Pages.ToString());
                bib.Append("},");
                bib.Append(LineFeed);
                bib.Append(Retract);
                bib.Append("volume = ");
                bib.Append(a.Volume.ToString());
                bib.Append("");
                bib.Append(LineFeed);
                bib.Append("}");
                bib.Append(LineFeed);
            }

            return(bib.ToString());
        }
Esempio n. 2
0
        private void SourceDots_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog();

            o.Filter = "PDF Files | *.pdf";
            if (o.ShowDialog().ToString().Equals("OK"))
            {
                string destPath = System.Environment.CurrentDirectory + "\\Articles";
                if (!Directory.Exists(destPath))
                {
                    Directory.CreateDirectory(destPath);
                }

                File.Text   = o.FileName;
                Destin.Text = System.IO.Path.Combine(destPath, System.IO.Path.GetFileName(File.Text));
            }
            // Sprawdzanie czy plik jest już w bazie
            List <Files> filesList = new List <Files>(DbDataAccess.GetFilesList());

            if (filesList.Exists(x => x.Filename == System.IO.Path.GetFileName(File.Text)))
            {
                System.Windows.MessageBox.Show("The selected article already exists. Please choose another one.");
                File.Clear();
                Destin.Clear();
            }
            ;
        }
Esempio n. 3
0
        private void BtnDeleteTask_Click(object sender, RoutedEventArgs e)
        {
            TaskModel task = lbTasksToDo.SelectedItem as TaskModel;

            DbDataAccess.DeleteTask(task);
            loadTasksToDo(dpShowTasks.SelectedDate.Value);
        }
Esempio n. 4
0
        private void SaveInfo_Click(object sender, RoutedEventArgs e)
        {
            // Po wykryciu pustego pola zwracana jest wartość true, a następnie zostaje przerwane wykonywanie dalszych instrukcji
            if (CheckAllFields())
            {
                return;
            }
            worker.RunWorkerAsync();
            System.Windows.MessageBox.Show("File " + File.Text + " copied successfully");

            Articles a = new Articles()
            {
                Title   = ATitle.Text,
                Volume  = int.Parse(Volume.Text),
                Journal = Journal.Text,
                Year    = int.Parse(Year.Text),
                //Month= int.Parse(Month.Text),
                Pages  = int.Parse(Pages.Text),
                Number = int.Parse(Number.Text),
            };

            DbDataAccess.SaveArticle(a);
            DbDataAccess.SaveFile(DbDataAccess.GetLastArticleId(), System.IO.Path.GetFileName(File.Text));
            DbDataAccess.MatchAuthorsToArticles(DbDataAccess.GetLastArticleId(), SelectedAuthors);
            DbDataAccess.MatchKeywordsToArticle(DbDataAccess.GetLastArticleId(), SelectedKeywords);

            MainWindow.AppWindow.LoadArticlesToList();
            this.Close();
        }
Esempio n. 5
0
        // GET: Computer/Confirm
        public ActionResult Confirm()
        {
            ConfirmModel model  = new ConfirmModel();
            string       action = Request.Cookies["action"].Value;

            if (action == "loan")
            {
                ViewBag.DropdownMessage  = "Vælg en computer";
                ViewBag.DropdownButton   = "Udlån";
                model.AvailableComputers = DbDataAccess.GetData <SelectComputerModel>("GetAvailableComputers", null).Select(s => new SelectListItem {
                    Value = s.Id.ToString(), Text = s.Name
                }).ToList();
            }
            else if (action == "return")
            {
                ViewBag.DropdownMessage = "Indlever din PC";
                ViewBag.DropdownButtong = "Aflever";
                Dapper.DynamicParameters parameters = new Dapper.DynamicParameters();
                parameters.Add("@username", Request.Cookies["username"].Value);
                model.AvailableComputers = DbDataAccess.GetData <SelectComputerModel>("GetLentComputer", parameters).Select(s => new SelectListItem {
                    Value = s.Id.ToString(), Text = s.Name
                }).ToList();
            }
            return(View(model));
        }
Esempio n. 6
0
        // GET: Admin/Delete/5
        public ActionResult Delete(int id)
        {
            List <ComputerModel> computers = DbDataAccess.GetData <ComputerModel>("GetAllComputers", null).ToList();

            ComputerModel computer = computers.Where(c => c.Id == id).First();

            return(View(computer));
        }
Esempio n. 7
0
        public ActionResult Create()
        {
            var nModel = new NewTrainigModel();

            nModel.Users = new List <User>(DbDataAccess.GetUsers());
            nModel.NewTraining.TrainingDate = DateTime.Today;

            return(View(nModel));
        }
Esempio n. 8
0
 private void AddComm_Click(object sender, RoutedEventArgs e)
 {
     if (CheckCommentField())
     {
         return;
     }
     DbDataAccess.AddComment(MainWindow.SelectedArticle.Id, CName.Text, Message.Text);
     MainWindow.AppWindow.LoadCommentToList();
     this.Close();
 }
        public MainWindow()
        {
            InitializeComponent();
            AppWindow             = this;
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            DbDataAccess.CreateDB();

            // Wczytanie artykułów do listy
            LoadArticlesToList();
        }
Esempio n. 10
0
        public ActionResult Edit(decimal Id, FormCollection col)
        {
            var t = DbDataAccess.GetTrainingById(Id);

            if (TryUpdateModel(t))
            {
                DbDataAccess.SaveOrUpdateTraining(t);
                return(RedirectToAction("ViewTrainings"));
            }
            return(View(t));
        }
Esempio n. 11
0
        public ActionResult Delete(decimal Id)
        {
            try
            {
                DbDataAccess.DeleteTraining(Id);
            }
            catch (Exception e)
            {
            }

            return(RedirectToAction("ViewTrainings"));
        }
Esempio n. 12
0
        public string GetKey(Articles a)
        {
            var    str  = DbDataAccess.GetAuthorsOfArticle(a.Id);
            string auth = "";

            foreach (Authors au in str)
            {
                auth = string.Concat(auth, (au.Author.Substring(0, 1)));
            }
            string key = string.Concat(auth, a.Title.Substring(0, 2), a.Year.ToString());

            return(key.ToLower());
        }
        private void AddNewKeywordBtn_Click(object sender, RoutedEventArgs e)
        {
            if (CheckKeywordField())
            {
                return;
            }
            Keywords k = new Keywords()
            {
                Keyword = KName.Text
            };

            DbDataAccess.SaveKeyword(k);
            ListOfKeywords.ItemsSource = DbDataAccess.GetKeywords();
            KName.Clear();
        }
        private void AddAuthorBtn_Click(object sender, RoutedEventArgs e)
        {
            if (CheckAuthorField())
            {
                return;
            }
            Authors a = new Authors()
            {
                Author = AName.Text
            };

            DbDataAccess.SaveAuthor(a);
            ListOfAutors.ItemsSource = DbDataAccess.GetAuthors();
            AName.Clear();
        }
        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = (ListBox)sender;

            // Zapisanie wybranego artykułu do zmiennej
            SelectedArticle      = (Articles)item.SelectedItem;
            SelectedArticle.File = new Files {
                Filename = DbDataAccess.GetFileName(SelectedArticle.Id)
            };
            fileNameBox.Text = SelectedArticle.File.Filename;

            OpenFileBtn.IsEnabled = true;
            AddComm.IsEnabled     = true;

            LoadCommentToList();
        }
Esempio n. 16
0
        public ActionResult Delete(int id, ComputerModel model)
        {
            try
            {
                Dapper.DynamicParameters parameters = new Dapper.DynamicParameters();
                parameters.Add("@id", id);

                DbDataAccess.SetData("[DeavtivateComputer]", parameters);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(model));
            }
        }
Esempio n. 17
0
        private void BtnAddTask_Click(object sender, RoutedEventArgs e)
        {
            TaskModel task;

            if (!isEdited)
            {
                task = new TaskModel();
            }
            else
            {
                task = (TaskModel)lbTasksToDo.SelectedItem;
            }

            task.DateOfTask  = dpDateOfTask.SelectedDate.Value;
            task.Description = tbTaskDesc.Text;

            DbDataAccess.SaveTask(task);
            loadTasksToDo(DateTime.Today);
            isEdited = false;
        }
Esempio n. 18
0
        public ActionResult Create(ComputerModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                Dapper.DynamicParameters parameters = new Dapper.DynamicParameters();
                parameters.Add("@name", model.Name);
                parameters.Add("@state", model.SelectedState);

                DbDataAccess.SetData("CreateComputer", parameters);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(model));
            }
        }
Esempio n. 19
0
        public ActionResult Login(LoginModel model, string name)
        {
            bool isValid = model.ValidateUser();


            if (isValid)
            {
                Response.Cookies["username"].Value = model.username.ToString();
                //model.username = DbDataAccess.GetData<LoginModel>("CheckUserExists", parameters).Select(s => new SelectListItem { Value = s.username, Text = s.username });

                Dapper.DynamicParameters parameters = new Dapper.DynamicParameters();
                parameters.Add(@"name", Request.Cookies["username"].Value);

                List <LoginModel> users = DbDataAccess.GetData <LoginModel>("CheckUserExists", parameters).ToList();

                if (users[0] == null)
                {
                    DbDataAccess.SetData("AddUser", parameters);
                }

                model.GetInformation();
                ViewBag.FailedLogin = null;
                string requestName = Request.Cookies["action"].Value;


                if (requestName == "loan")
                {
                    return(RedirectToAction("Confirm", "Computer"));
                }
                else if (requestName == "return")
                {
                    return(RedirectToAction("Confirm", "Computer"));
                }
            }
            ViewBag.FailedLogin = "******";
            return(View());
        }
Esempio n. 20
0
 public Export()
 {
     InitializeComponent();
     WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
     listBox.ItemsSource   = DbDataAccess.LoadArticleList();
 }
Esempio n. 21
0
 private void loadTasksToDo(DateTime dateTime)
 {
     listOfTasksToDo         = null;
     listOfTasksToDo         = DbDataAccess.LoadTasksFromDB(dateTime);
     lbTasksToDo.ItemsSource = listOfTasksToDo;
 }
 // Wczytanie artykułów do listy
 public void LoadArticlesToList()
 {
     lstBox.ItemsSource = DbDataAccess.LoadArticleList();
 }
 // Wczytanie komentarzy do listy
 public void LoadCommentToList()
 {
     commentsBox.ItemsSource = DbDataAccess.GetCommentsToArticles(SelectedArticle.Id);
 }
Esempio n. 24
0
 // GET: Users
 public async Task <ActionResult> Index()
 {
     return(View(DbDataAccess.GetUsers()));
 }
Esempio n. 25
0
        private void Upload(List <string> l)
        {
            string uAuthor  = "Not found";
            string uTitle   = "Not found";
            string uJournal = "Not found";
            int    uYear    = 0000;
            int    uNumber  = 0;
            int    uPages   = 0;
            int    uVolume  = 0;

            foreach (string line in l)
            {
                if (line.StartsWith("\tauthor", StringComparison.InvariantCultureIgnoreCase))
                {
                    uAuthor = line.Substring(line.LastIndexOf("{") + 1, (line.LastIndexOf("}") - line.LastIndexOf("{") - 1));
                }
                else if (line.StartsWith("\ttitle", StringComparison.InvariantCultureIgnoreCase))
                {
                    uTitle = line.Substring(line.LastIndexOf("{") + 1, (line.LastIndexOf("}") - line.LastIndexOf("{") - 1));
                }
                else if (line.StartsWith("\tjournal", StringComparison.InvariantCultureIgnoreCase))
                {
                    uJournal = line.Substring(line.LastIndexOf("{") + 1, (line.LastIndexOf("}") - line.LastIndexOf("{") - 1));
                }
                else if (line.StartsWith("\tyear", StringComparison.InvariantCultureIgnoreCase))
                {
                    uYear = int.Parse(line.Substring(line.LastIndexOf("=") + 2, 4));
                }
                else if (line.StartsWith("\tnumber", StringComparison.InvariantCultureIgnoreCase))
                {
                    uNumber = int.Parse(line.Substring(line.LastIndexOf("=") + 2, 1));
                }
                else if (line.StartsWith("\tpages", StringComparison.InvariantCultureIgnoreCase))
                {
                    uPages = int.Parse(line.Substring(line.LastIndexOf("{") + 1, (line.LastIndexOf("}") - line.LastIndexOf("{") - 1)));
                }
                else if (line.StartsWith("\tvolume", StringComparison.InvariantCultureIgnoreCase))
                {
                    uVolume = int.Parse(line.Substring(line.LastIndexOf("=") + 2, 1));
                }
            }
            Articles = DbDataAccess.LoadArticleList();
            int index = Articles.FindIndex(item => item.Title == uTitle);

            if (index >= 0)
            {
                System.Windows.MessageBox.Show("Article with this title already exist in database!", "File already exist");
            }
            else
            {
                Articles a = new Articles()
                {
                    Title   = uTitle,
                    Journal = uJournal,
                    Year    = uYear,
                    Number  = uNumber,
                    Pages   = uPages,
                    Volume  = uVolume
                };
                DbDataAccess.SaveArticle(a);
                Authors aut = new Authors()
                {
                    Author = uAuthor
                };
                Auts.Add(aut);
                System.Windows.MessageBox.Show($"{Auts[0].Author}");
                DbDataAccess.SaveAuthor(aut);
                DbDataAccess.MatchAuthorsToArticles(DbDataAccess.GetLastArticleId(), Auts);
            }
        }
        public List <string>[] GetData()
        {
            DbDataAccess dbData = new DbDataAccess();

            return(dbData.GetUserTypesFromDb());
        }
Esempio n. 27
0
 public ActionResult Edit(decimal Id)
 {
     return(View(DbDataAccess.GetTrainingById(Id)));
 }
Esempio n. 28
0
 public ActionResult Create(Training tr)
 {
     DbDataAccess.SaveOrUpdateTraining(tr);
     return(RedirectToAction("ViewTrainings"));
 }
 public AddKeyword()
 {
     InitializeComponent();
     WindowStartupLocation      = System.Windows.WindowStartupLocation.CenterScreen;
     ListOfKeywords.ItemsSource = DbDataAccess.GetKeywords();
 }
Esempio n. 30
0
 public ActionResult ViewTrainings(decimal?Id = 0)
 {
     return(View(DbDataAccess.GetUserWithTrainingsByUserId(Id)));
 }