Example #1
0
        public DatePickerPopup(TLaction action)
        {
            InitializeComponent();
            v_action = action;

            // Initialisation du composant calendar
            if (action.hasDueDate)
                calendar.SelectionStart = action.DueDate;
            else
                this.noDueDate.Checked = true;
        }
Example #2
0
        /// <summary>Constructeur de la fenêtre</summary>
        /// <param name="action">Action à afficher</param>
        public ManipAction(TLaction action)
        {
            InitializeComponent();
            this.Icon = TaskLeader.Properties.Resources.task_coach;

            // On mémorise l'action
            this._action = action;

            // Remplissage de la liste des bases disponibles
            foreach (String dbName in TrayIcon.dbs.Keys)
                dbsBox.Items.Add(dbName);
            dbsBox.Text = _action.dbName;

            if (action.isScratchpad)
                this.Text += "Ajouter une action - TaskLeader";
            else
            {
                this.Text += "Modifier une action - TaskLeader";

                this.dbsBox.Enabled = false;

                if (action.hasDueDate) // Attribut géré à part car pas de valeur par défaut
                    actionDatePicker.Value = action.DueDate;
                else
                    noDueDate.Checked = true;
            }

            // Chargement des widgets
            this.loadWidgets();

            // Affichage des pièces jointes
            for (int i = 0; i < action.PJ.Count; i++)
                this.addPJToView(action.PJ[i],i);

            this.linksView.Visible = (action.PJ.Count > 0);

            // Affichage du descriptif de l'action
            desField.Text = action.Texte;
            desField.Select(desField.Text.Length, 0); // Curseur placé à la fin par défaut
        }
Example #3
0
 // Méthode appelée sur nouveau mail
 private void newActionOutlook(object sender, NewMailEventArgs e)
 {
     if (invokeControl.InvokeRequired)
         invokeControl.Invoke(new NewMailEventHandler(newActionOutlook), new object[] { sender, e });
     else // Demande d'ajout de mail à une action
     {
         TLaction action = new TLaction();
         action.Texte = e.Mail.Titre;
         action.addPJ(e.Mail);
         new ManipAction(action).Show();
     }
 }
Example #4
0
        // Mise à jour du statut d'une action via le menu contextuel
        private void changeStat(object sender, EventArgs e)
        {
            // Récupération de l'action
            TLaction action = new TLaction(
                this.getDataFromRow(grilleData.SelectedRows[0].Index, "id"),
                this.getDataFromRow(grilleData.SelectedRows[0].Index, "DB")
            );

            // On récupère le nouveau statut
            action.Statut = ((ToolStripItem)sender).Text;

            // On met à jour le statut de l'action que s'il a changé
            if (action.statusHasChanged)
                action.save();
        }
Example #5
0
        // Insertion d'une nouvelle action
        // Renvoie l'ID de stockage de l'action
        public String insertAction(TLaction action)
        {
            String actionID;

            using (SQLiteConnection SQLC = new SQLiteConnection(this._connectionString))
            {
                if (File.Exists(this.path))
                    SQLC.Open();
                else
                    throw new Exception("Base inaccessible");

                using (SQLiteTransaction mytransaction = SQLC.BeginTransaction())
                {
                    using (SQLiteCommand SQLCmd = new SQLiteCommand(SQLC))
                    {
                        //Syntaxe: INSERT INTO Actions (nom des colonnes avec ,) VALUES(valeurs avec ' et ,)

                        // Préparation des différents morceaux de la requête
                        String insertPart = "INSERT INTO Actions (";
                        String valuePart = " VALUES (";

                        if (action.Contexte != "")
                        {
                            insertPart += "CtxtID,";
                            valuePart += "(SELECT id FROM Contextes WHERE Titre = " + action.ContexteSQL + "),";
                        }

                        if (action.Sujet != "")
                        {
                            insertPart += "SujtID,";
                            valuePart += "(SELECT id FROM VueSujets WHERE Contexte=" + action.ContexteSQL + " AND Titre=" + action.SujetSQL + "),";
                        }

                        insertPart += "Titre,"; // On a déjà vérifié que la chaîne n'était pas nulle
                        valuePart += action.TexteSQL + ",";

                        if (action.hasDueDate)
                        {
                            insertPart += "DueDate,";
                            valuePart += action.DueDateSQL + ",";
                        }

                        if (action.Destinataire != "")
                        {
                            insertPart += "DestID,";
                            valuePart += "(SELECT id FROM Destinataires WHERE Titre =" + action.DestinataireSQL + "),";
                        }

                        insertPart += "StatID)";
                        valuePart += "(SELECT id FROM Statuts WHERE Titre=" + action.StatutSQL + "))";

                        SQLCmd.CommandText = insertPart + valuePart;
                        SQLCmd.ExecuteNonQuery();

                        SQLCmd.CommandText = "SELECT max(id) FROM Actions;";
                        actionID = SQLCmd.ExecuteScalar().ToString();
                    }
                    mytransaction.Commit();
                }
            }
            this.OnActionEdited(actionID);
            return actionID;
        }
Example #6
0
        // Mise à jour d'une action (flexible)
        public int updateAction(TLaction action)
        {
            // Préparation des sous requêtes
            String ctxtPart = "";
            if (action.ctxtHasChanged)
                ctxtPart = "CtxtID=(SELECT id FROM Contextes WHERE Titre=" + action.ContexteSQL + "),";

            String sujetPart = "";
            if (action.sujetHasChanged)
                sujetPart = "SujtID=(SELECT id FROM Sujets WHERE Titre=" + action.SujetSQL + "),";

            String actionPart = "";
            if (action.texteHasChanged)
                actionPart = "Titre=" + action.TexteSQL + ",";

            String datePart = "";
            if (action.dueDateHasChanged)
            {
                if (action.hasDueDate)
                    datePart = "DueDate=" + action.DueDateSQL + ",";
                else
                    datePart = "DueDate=NULL,";
            }

            String destPart = "";
            if (action.destHasChanged)
                destPart = "DestID=(SELECT id FROM Destinataires WHERE Titre=" + action.DestinataireSQL + "),";

            String statPart = "";
            if (action.statusHasChanged)
                statPart = "StatID=(SELECT id FROM Statuts WHERE Titre=" + action.StatutSQL + "),";
            // Il y a volontairement une virgule à la fin dans le cas où le statut n'a pas été mis à jour

            String updatePart = ctxtPart + sujetPart + actionPart + datePart + destPart + statPart;

            String requete;
            if (updatePart.Length > 0)
            {
                requete = "UPDATE Actions SET " + updatePart.Substring(0, updatePart.Length - 1) + " WHERE id='" + action.ID + "'";

                int result = execSQL(requete);
                this.OnActionEdited(action.ID);
                return result;
            }
            else
                return 0;
        }