Exemple #1
0
        private void SaveProjectBut_Click(object sender, RoutedEventArgs e)
        {
            string Datapath = $"Data Source= " + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\PawloCore\" + _identity + @"_user_data" + @"\DynamicsData\dynamics.sqlite";


            if (string.IsNullOrWhiteSpace(TaskNametxt.Text) || StartTaskTimeDP == null || FinishTaskTimeDP == null)
            {
                correctnessbq.Visibility     = Visibility.Visible;
                FieldsErrorLbl.Visibility    = Visibility.Visible;
                DateRangeErrorLbl.Visibility = Visibility.Hidden;
            }
            else
            {
                DateTime StartDate  = Convert.ToDateTime(StartTaskTimeDP.Text);
                DateTime FinishDate = Convert.ToDateTime(FinishTaskTimeDP.Text);

                if (DateTime.Compare(StartDate, FinishDate) > 0 || DateTime.Compare(Convert.ToDateTime(InfoList[1]), StartDate) > 0 ||
                    DateTime.Compare(FinishDate, Convert.ToDateTime(InfoList[2])) > 0)
                {
                    correctnessbq.Visibility     = Visibility.Visible;
                    DateRangeErrorLbl.Visibility = Visibility.Visible;
                    FieldsErrorLbl.Visibility    = Visibility.Hidden;
                }
                else
                {
                    correctnessbq.Visibility     = Visibility.Hidden;
                    DateRangeErrorLbl.Visibility = Visibility.Hidden;
                    FieldsErrorLbl.Visibility    = Visibility.Hidden;
                    string query = $"INSERT INTO TASKS(TASK_NAME, DATE_START, DATE_FINISH, DESCRIPTION, FK_ID) VALUES('{TaskNametxt.Text}', '{StartDate.ToShortDateString()}', '{FinishDate.ToShortDateString()}', '{DescriptionTasktxt.Text}', {_projectID});";
                    EX_Query(query, Datapath);

                    query = $"SELECT * FROM TASKS WHERE FK_ID = {_projectID} ORDER BY ID DESC LIMIT 1";

                    InfoList = GetInfo(query, Datapath);
                    _IPHelper.AddTask(InfoList, _projectID);


                    MessageBox.Show("Dodano zadanie");
                    main.Items.Clear();
                    ProjectClass ListHelp = new ProjectClass();
                    ListHelp.GetTaskList(_projectID, _identity, main);
                    this.Close();
                }
            }
        }
Exemple #2
0
        private void SaveProjectBut_Click(object sender, RoutedEventArgs e)
        {
            DateTime StartDate  = Convert.ToDateTime(NewStartTaskTimeDP.Text);
            DateTime FinishDate = Convert.ToDateTime(NewFinishTaskTimeDP.Text);

            Datapath = $"Data Source= " + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\PawloCore\" + _identity + @"_user_data" + @"\DynamicsData\dynamics.sqlite";
            string query = $"UPDATE TASKS SET TASK_NAME = '{NewTaskNametxt.Text}', DATE_START = '{StartDate.ToShortDateString()}', DATE_FINISH = '{FinishDate.ToShortDateString()}', DESCRIPTION = '{NewDescriptionTasktxt.Text}' WHERE ID = {Int32.Parse(_taskID)}";

            InfoList = new List <string>();
            EX_Query(query, Datapath);
            query    = $"SELECT * FROM TASKS WHERE FK_ID = {_projectID} ORDER BY ID DESC LIMIT 1";
            InfoList = GetInfo(query, Datapath);
            _IPHelper.DeleteTask(_taskID, _projectID);
            _IPHelper.AddTask(InfoList, _projectID);
            _Update.Close();
            _Data.TaskView.Items.Clear();
            ProjectClass Helper = new ProjectClass();

            Helper.GetTaskList(_projectID, _identity, _Data.TaskView);
            MessageBox.Show("Zaktualizowano dane");
        }