Example #1
0
        //==============================================================
        /// <summary>
        /// Returns top recent bugs reported by the given user.
        /// </summary>
        /// <param name="aUserID">The ID of the user</param>
        /// <param name="aErrorStr">The description of a DB error</param>
        /// <returns>
        /// </returns>
        public List <BugInfo> GetRecentBugs(string aUserID,
                                            ref string aErrorStr)
        {
            List <BugInfo> bugs    = new List <BugInfo>();
            string         connStr = GetConfigValue("ConnString");

            if (connStr == null)
            {
                aErrorStr = "No connection string specified";
                return(bugs);
            }

            SqlConnection connection = new SqlConnection(connStr);

            try
            {
                connection.Open();

                string query = "SELECT TOP 10 [ID], Title, Description, Status"
                               + " FROM Bugs"
                               + " WHERE UserID = "
                               + aUserID
                               + " ORDER BY [ID] DESC";
                SqlCommand    command    = new SqlCommand(query, connection);
                SqlDataReader dataReader = command.ExecuteReader();

                // Fill the bug info
                while (dataReader.Read())
                {
                    int     bugID          = dataReader.GetInt32(0);
                    string  bugTitle       = dataReader.GetString(1);
                    string  bugDescription = dataReader.GetString(2);
                    string  bugStatus      = dataReader.GetString(3);
                    BugInfo bugInfo        = new BugInfo(bugID, bugTitle, bugDescription, bugStatus);
                    bugs.Add(bugInfo);
                }

                dataReader.Close();
                command.Dispose();
            }
            catch (Exception ex)
            {
                aErrorStr = ex.Message;
            }
            finally
            {
                try
                {
                    connection.Close();
                }
                catch (Exception ex)
                {
                    aErrorStr += ex.Message;
                }
            }

            return(bugs);
        }
Example #2
0
        //==============================================================
        /// <summary>
        /// Returns the bug data, given a bug ID.
        /// </summary>
        /// <param name="aBugId">The ID of the bug</param>
        /// <param name="aErrorStr">The description of a DB error</param>
        /// <returns>
        /// The bug title, dscription, etc. if the bug is in the DB,
        /// null otherwise.
        /// </returns>
        public BugInfo GetBugInfo(string aBugID,
                                  ref string aErrorStr)
        {
            BugInfo bug     = null;
            string  connStr = GetConfigValue("ConnString");

            if (connStr == null)
            {
                aErrorStr = "No connection string specified";
                return(bug);
            }

            SqlConnection connection = new SqlConnection(connStr);

            try
            {
                connection.Open();

                string query = "SELECT [ID], Title, Description, Status"
                               + " FROM Bugs"
                               + " WHERE [ID] = " + aBugID;

                SqlCommand    command    = new SqlCommand(query, connection);
                SqlDataReader dataReader = command.ExecuteReader();

                // Fill the bug info
                if (dataReader.Read())
                {
                    int    bugID          = dataReader.GetInt32(0);
                    string bugTitle       = dataReader.GetString(1);
                    string bugDescription = dataReader.GetString(2);
                    string bugStatus      = dataReader.GetString(3);
                    bug = new BugInfo(bugID, bugTitle, bugDescription, bugStatus);
                }

                dataReader.Close();
                command.Dispose();
            }
            catch (Exception ex)
            {
                aErrorStr = ex.Message;
            }
            finally
            {
                try
                {
                    connection.Close();
                }
                catch (Exception ex)
                {
                    aErrorStr += ex.Message;
                }
            }

            return(bug);
        }
Example #3
0
        //==============================================================
        /// <summary>
        /// Modifies the data for the existing bug in the DB.
        /// </summary>
        /// <param name="aBugInfo">The data about the bug</param>
        /// <param name="aErrorStr">The description of a DB error</param>
        public void SaveBugInfo(BugInfo aBugInfo,
                                ref string aErrorStr)
        {
            string connStr = GetConfigValue("ConnString");

            if (connStr == null)
            {
                aErrorStr = "No connection string specified";
                return;
            }

            SqlConnection connection = new SqlConnection(connStr);

            try
            {
                connection.Open();

                string query = "UPDATE Bugs SET Title = '"
                               + aBugInfo.Title.Replace("'", "''")
                               + "', Description = '"
                               + aBugInfo.Description.Replace("'", "''")
                               + "', Status = '"
                               + aBugInfo.Status + "' WHERE [ID] = " + aBugInfo.ID;

                SqlCommand command = new SqlCommand(query, connection);
                command.ExecuteNonQuery();

                command.Dispose();
            }
            catch (Exception ex)
            {
                aErrorStr = ex.Message;
            }
            finally
            {
                try
                {
                    connection.Close();
                }
                catch (Exception ex)
                {
                    aErrorStr += ex.Message;
                }
            }
        }
Example #4
0
        protected void Page_Load(object aSender, EventArgs aEventArgs)
        {
            bugIDStr = Request["BugId"];

            if (IsPostBack)
            {
                return;
            }

            statusColorData = new Dictionary <string, Color>();
            statusColorData.Add("Reported", Color.FromArgb(0xff, 0x50, 0x50));
            statusColorData.Add("In Progress", Color.FromArgb(0xff, 0xff, 0x66));
            statusColorData.Add("Fixed", Color.FromArgb(0x66, 0xff, 0x66));
            string selectedStatus = "Reported";

            if (bugIDStr != null)
            {
                string  errorMsg = "";
                BugInfo bug      = DBUtility.Instance().GetBugInfo(bugIDStr, ref errorMsg);

                if (errorMsg.Length > 0)
                {
                    Response.Write(errorMsg);
                }

                if (bug != null)
                {
                    BugTitle.Text       = bug.Title;
                    BugDescription.Text = bug.Description;
                    selectedStatus      = bug.Status;
                }
            }

            BugStatus.Text      = selectedStatus;
            BugStatus.BackColor = statusColorData[selectedStatus];

            BugTitle.Focus();
        }