Beispiel #1
0
        public int deleteRetroType(RetroType retroType)
        {
            int ret = -1;

            using (var conn = new MySqlConnection("server=" + ip + ";database=SSG_POD;userid=" + username + ";password="******";"))
                using (var command = conn.CreateCommand())
                {
                    command.CommandText = "DELETE FROM Retrospective_Type " +
                                          "WHERE ID = @id;";
                    conn.Open();
                    command.Parameters.AddWithValue("@id", retroType.id);

                    try
                    {
                        ret = command.ExecuteNonQuery();
                    }
                    catch (InvalidOperationException)
                    {
                        ret = -1;
                    }
                    conn.Close();
                }

            return(ret);
        }
Beispiel #2
0
        private void retroTypeRenameBtn_Click(object sender, EventArgs e)
        {
            if (retroTypeLB.SelectedItem != null)
            {
                RetroType selRetroType = (RetroType)retroTypeLB.SelectedItem;

                selRetroType.title = retroTypeNameTB.Text;
                selRetroType.code  = retroTypeCodeTB.Text;

                if (!(tableData.updateRetroType(selRetroType) > 0))
                {
                    errorDynLabel.Text = "Error saving Retrospective Type";
                }
            }
            else
            { // adding a new retrospective type
                RetroType retroType = new RetroType();
                retroType.code  = retroTypeCodeTB.Text;
                retroType.title = retroTypeNameTB.Text;

                if ((tableData.addRetroType(retroType) == null))
                {
                    errorDynLabel.Text = "Error saving Retrospective Type";
                }
                else
                {
                    loadRetroTypes();
                    retroTypeCodeTB.Enabled = false;
                }
            }
        }
Beispiel #3
0
        //TODO - convert to Using
        public int insertRetroType(RetroType retroType)
        {
            int          ret     = 0;
            MySqlCommand command = conn2.CreateCommand();

            conn2.Open();
            command.CommandText = "INSERT INTO Retrospective_Type " +
                                  "VALUES (@id, @title, @code);";

            command.Parameters.AddWithValue("@id", retroType.id);
            command.Parameters.AddWithValue("@title", retroType.title);
            command.Parameters.AddWithValue("@code", retroType.code);

            try
            {
                ret = command.ExecuteNonQuery();
            }
            catch (InvalidOperationException)
            {
                ret = -1;
            }

            conn2.Close();

            return(ret);
        }
Beispiel #4
0
        public ArrayList getAllRetroTypes()
        {
            RetroType retroType;
            ArrayList retroTypes = new ArrayList();

            using (var conn = new MySqlConnection("server=" + ip + ";database=SSG_POD;userid=" + username + ";password="******";"))
                using (var command = conn.CreateCommand())
                {
                    command.CommandText = "SELECT * from Retrospective_Type;";
                    conn.Open();

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            retroType = new RetroType();

                            retroType.id    = int.Parse(reader[0].ToString());
                            retroType.title = reader[1].ToString();
                            retroType.code  = reader[2].ToString();

                            retroTypes.Add(retroType);
                        }
                    }
                }

            return(retroTypes);
        }
Beispiel #5
0
        public int removeRetroType(RetroType retroType)
        {
            int ret = query.deleteRetroType(retroType);

            if (ret > 0)
            {
                retroTypes.Remove(retroType);
            }

            return(ret);
        }
Beispiel #6
0
        public RetroType addRetroType(RetroType retroType)
        {
            retroType.id = getNextRetroTypeId();

            int ret = query.insertRetroType(retroType);

            if (ret > 0)
            {
                retroTypes.Add(retroType);
                return(retroType);
            }
            return(null);
        }
Beispiel #7
0
        public int updateRetroType(RetroType updRetroType)
        {
            int ret = query.updateRetroType(updRetroType);

            if (ret > 0)
            {
                for (int i = 0; i < retroTypes.Count; i++)
                {
                    if (((RetroType)retroTypes[i]).id == updRetroType.id)
                    {
                        retroTypes[i] = updRetroType;
                    }
                }
            }
            return(ret);
        }
Beispiel #8
0
 private void retroTypeRemBtn_Click(object sender, EventArgs e)
 {
     if (((RetroType)retroTypeLB.SelectedItem).id == 0)
     {
         errorDynLabel.Text = "Cannot delete type uncategorized";
     }
     else if (retroTypeLB.SelectedItem != null && !(retroTypesAssignLB.Items.Count > 0))
     {
         RetroType remRetroType = (RetroType)retroTypeLB.SelectedItem;
         if (tableData.removeRetroType(remRetroType) > 0)
         {
             loadRetroTypes();
             retroTypeNameTB.Text = "";
             retroTypeCodeTB.Text = "";
         }
     }
     else
     {
         errorDynLabel.Text = "Cannot remove type with retrospectives still assigned to it.";
     }
 }