Exemple #1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            taskModel.Nazwa          = TaskNameTextBox.Text.Trim();
            taskModel.Kategoria      = CategoryTextBox.Text.Trim();
            taskModel.Opis           = DescriptionTextBox.Text.Trim();
            taskModel.DataUtworzenia = DateTime.Now;
            taskModel.CzyZakonczone  = false;
            taskModel.IDUzytkownika  = (short)IDUser;
            if (TaskNameTextBox.Text == string.Empty || CategoryTextBox.Text == string.Empty ||
                DescriptionTextBox.Text == string.Empty)
            {
                MessageBox.Show("Uzupełnij wszystkiego pola!");
            }
            else
            {
                using (LearningPlannerDataBaseEntities dbmodel = new LearningPlannerDataBaseEntities())
                {
                    if (taskModel.IDZadania == 0)
                    {
                        dbmodel.Tasks.Add(taskModel);
                    }
                    else
                    {
                        dbmodel.Entry(taskModel).State = System.Data.Entity.EntityState.Modified;
                    }

                    dbmodel.SaveChanges();
                }
                FillGrid();
                ClearTextBoxes();
                MessageBox.Show("Pomyślnie dodano zadanie");
            }
        }
        private void findButton_Click(object sender, EventArgs e)
        {
            twitterTweetsTextBox.Clear();
            this.Invalidate();

            var user = User.GetUserFromScreenName(findTextBox.Text);

            if (twitterComboBox.SelectedItem == null)
            {
                twitterComboBox.SelectedIndex = 3;
            }
            try
            {
                var userTimeLine = Timeline.GetUserTimeline(user, twitterComboBox.SelectedIndex + 1);

                followersLabel.Text = user.Name + Environment.NewLine + "Obserwujących: " + Environment.NewLine
                                      + user.FollowersCount;

                var image = user.ProfileImageUrl400x400;
                foundPersonPicture.ImageLocation = image;

                foreach (var item in userTimeLine)
                {
                    twitterTweetsTextBox.AppendText("--- " + item.FullText + " - " + item.CreatedAt
                                                    + Environment.NewLine + Environment.NewLine);
                }

                followersLabel.Visible = true;

                using (LearningPlannerDataBaseEntities model = new LearningPlannerDataBaseEntities())
                {
                    var historyRecord = new TweetsHistory()
                    {
                        IDosoby     = IDUser,
                        TwitterUser = user.Name
                    };



                    model.TweetsHistory.Add(historyRecord);
                    model.SaveChanges();
                }
            }
            catch
            {
                twitterTweetsTextBox.Text     = "Nie wpisano żadnej nazwy lub użytkownik o podanym nicku nie istnieje!";
                twitterComboBox.SelectedIndex = default;
            }
        }
        private void EditTask_Click(object sender, EventArgs e)
        {
            DescriptionInfoRichTextBox.ReadOnly = false;
            using (LearningPlannerDataBaseEntities mod = new LearningPlannerDataBaseEntities())
            {
                DescriptionInfoRichTextBox.TextChanged += DescriptionInfoRichTextBox_TextChanged;

                var selectedRowId = mod.Tasks.Single(u => u.IDZadania == CompletedTasksForm.Id);
                selectedRowId.Opis = DescriptionInfoRichTextBox.Text;

                mod.SaveChanges();
            }
            EditTaskButton.Click += EditTask_Click1;
            Text = ("Szczególy Zadania [Tryb edytowania]");
        }
        private void FinishTask_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Czy napewno chcesz zakończyć to zadanie?", "Koniec Zadania", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                var selectedRowId = TaskForm.Id;

                using (LearningPlannerDataBaseEntities mod = new LearningPlannerDataBaseEntities())
                {
                    var selectedTask = mod.Tasks.Single(z => z.IDZadania == selectedRowId);
                    selectedTask.CzyZakonczone = true;
                    mod.SaveChanges();
                }

                GetFinishData = DateTime.Now.ToString();

                currentForm.FillGrid();
                Close();
            }
        }
        private void AddUserToDataBase()
        {
            Users model = new Users
            {
                Login = Login,
                Haslo = Password
            };

            using (LearningPlannerDataBaseEntities LearningPlannerDataBaseEntities = new LearningPlannerDataBaseEntities())
            {
                if (LearningPlannerDataBaseEntities.Users.Where(u => u.Login == Login).Any())
                {
                    MessageBox.Show("Podana nazwa uzytkownika jest juz zajęta");
                }
                else
                {
                    LearningPlannerDataBaseEntities.Users.Add(model);
                    LearningPlannerDataBaseEntities.SaveChanges();
                    MessageBox.Show("Utworzono konto!");
                    Close();
                }
            }
        }
Exemple #6
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Czy jesteś pewien, że chcesz usunąć to zadanie?", "USUWANIE REKORDU", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    using (LearningPlannerDataBaseEntities dbmodel = new LearningPlannerDataBaseEntities())
                    {
                        var entry = dbmodel.Entry(taskModel);
                        if (entry.State == System.Data.Entity.EntityState.Detached)
                        {
                            dbmodel.Tasks.Attach(taskModel);
                        }
                        dbmodel.Tasks.Remove(taskModel);
                        dbmodel.SaveChanges();

                        MessageBox.Show("Pomyślnie usunięto zadanie");
                    }

                    FillGrid();
                    ClearTextBoxes();
                }
                catch
                {
                    string errorDelete = "Błąd: Nie zaznaczono żadnego rekordu";
                    errorLabel.Visible = true;
                    errorLabel.Text    = errorDelete;
                    Timer exceptionTimer = new Timer
                    {
                        Interval = 7000
                    };
                    exceptionTimer.Tick += ExceptionTimer_Tick;
                    exceptionTimer.Start();
                }
            }
        }