コード例 #1
0
        public void InsertTask(BeetleClasses.Task ts, Project pr, User usr)
        {
            BugTrackingLogger.Logger.Information("Insert task.");
            try
            {
                BTQueryString = String.Format("INSERT INTO Task(theme, typeOfTask, priority, description, projectID) values (\"{0}\",\"{1}\",{2},\"{3}\",\"{4}\");",
                                              ts.Theme, ts.TypeOfTask, ts.Priority, ts.Description, pr.ProjectID);
                BugTrackingLogger.Logger.Debug("ProjectID = {4} \n Theme = {0} \n TypeOfTask = {1} \n Priority = {2} \n Description = {3}",
                                               ts.Theme, ts.TypeOfTask, ts.Priority, ts.Description, pr.ProjectID);
                BTCommand = new SQLiteCommand(BTQueryString, BTConnection);
                BTCommand.ExecuteNonQuery();

                BTQueryString = @"select last_insert_rowid()";
                BTCommand     = new SQLiteCommand(BTQueryString, BTConnection);
                long lastId = (long)BTCommand.ExecuteScalar();
                BugTrackingLogger.Logger.Debug("TaskID of last inserted task = {0}", lastId);

                BTQueryString = String.Format("INSERT INTO UserTaskCon(uID,tID) values ({0},{1});",
                                              usr.UserID, lastId);
                BugTrackingLogger.Logger.Debug("UserID = {0} \n TaskID = {1}",
                                               usr.UserID, lastId);
                BTCommand = new SQLiteCommand(BTQueryString, BTConnection);
                BTCommand.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                BugTrackingLogger.Logger.Error("{0} Exception caught.", e);
            }
        }
コード例 #2
0
 public void DeleteTask(ref BeetleClasses.Task tsk)
 {
     BugTrackingLogger.Logger.Information("Delete task.");
     try
     {
         BTQueryString = String.Format("DELETE FROM Task WHERE TaskID={0};", tsk.TaskID);
         BugTrackingLogger.Logger.Debug("Theme = {0} \n TypeOfTask = {1} \n Priority = {2} \n Description = {3}",
                                        tsk.Theme, tsk.TypeOfTask, tsk.Priority, tsk.Description);
         BTCommand = new SQLiteCommand(BTQueryString, BTConnection);
         BTCommand.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         BugTrackingLogger.Logger.Error("{0} Exception caught.", e);
     }
 }
コード例 #3
0
        public int FillTable()
        {
            BugTrackingLogger.Logger.Debug("Fill table.");
            try
            {
                Project pr = new Project
                {
                    ProjectName = "My Project"
                };
                User us = new User();
                us.FIO        = "Иванов Иван Иванович";
                us.Post       = "Программист";
                us.Department = "Отдел разработки ПО";
                this.InsertProject(ref pr);

                BTQueryString = @"select last_insert_rowid()";
                BTCommand     = new SQLiteCommand(BTQueryString, BTConnection);
                long prID = (long)BTCommand.ExecuteScalar();
                pr.ProjectID = (int)prID;

                this.InsertUser(ref us);

                BTQueryString = @"select last_insert_rowid()";
                BTCommand     = new SQLiteCommand(BTQueryString, BTConnection);
                long lastId = (long)BTCommand.ExecuteScalar();
                us.UserID = (int)lastId;

                BeetleClasses.Task ts = new BeetleClasses.Task();
                ts.Theme       = "Разработка системы отслеживания задач";
                ts.Priority    = 1;
                ts.TypeOfTask  = "Разработка ПО";
                ts.Description = "Необходимо разработать систему по отслеживанию задач/ошибок (bug tracking system)";
                this.InsertTask(ts, pr, us);
            }
            catch (Exception e)
            {
                BugTrackingLogger.Logger.Error("{0} Exception caught.", e);
                return(1);
            }
            return(0);
        }
コード例 #4
0
        private void BtnTskAddWindow_Click(object sender, RoutedEventArgs e)
        {
            _addtask    = new BeetleClasses.Task();
            _adduser    = new User();//maybe it is solve the problem
            _addproject = new Project();
            if (CmbBoxProject.SelectedIndex != -1)
            {
                _addproject = (Project)CmbBoxProject.Items[CmbBoxProject.SelectedIndex];
            }
            else
            {
                MessageBox.Show("Вы не выбрали проект, к которому будет прикреплена задача!", "Ошибка");
                return;
            }

            if (CmbBoxUser.SelectedIndex != -1)
            {
                _adduser = (User)CmbBoxUser.Items[CmbBoxUser.SelectedIndex];
            }
            else
            {
                MessageBox.Show("Вы не выбрали пользователя, к которому будет прикреплена задача!", "Ошибка");
                return;
            }
            try
            {
                _addtask.Theme      = LblTaskTheme.Text;
                _addtask.TypeOfTask = LblTaskType.Text;
                _addtask.Priority   = int.Parse(LblTaskPriority.Text);//замена по просьбе

                _addtask.Description = LblTaskDescription.Text;
                MainWindow.dd.InsertTask(_addtask, _addproject, _adduser);
            }
            catch (Exception ee)
            {
                BugTrackingLogger.Logger.Error("{0} Exception caught.", ee);
                MessageBox.Show("Ошибка при заполнении полей данными", "Ошибка");
            }
            this.Close();
        }
コード例 #5
0
 private void BtnDelTask_Click(object sender, RoutedEventArgs e)
 {
     BeetleClasses.Task tsk = DGridTask.SelectedItem as BeetleClasses.Task;
     dd.DeleteTask(ref tsk);
     UpdateTasks();
 }