protected void developing(object sender, EventArgs e)
        {
            //Get the query string parameters.
            string projectTitle = Session["ProjectTitle"].ToString();
            int projectCode = Int32.Parse(Session["ProjectCode"].ToString());

            //Create a project and look for the one we are being asked.
            ProjectBE project = new ProjectBE();
            project.Code = projectCode;
            project = project.getByCode();

            //We get the user who wants to develop.
            UserBE user = new UserBE();
            user.Email = Session["UserEmail"].ToString();
            user = user.getUserByEmail();

            DateTime date = DateTime.Now;
            String gitUrl = "none";
            int votes = 0;

            DevelopmentBE develop = new DevelopmentBE(project, user, date, gitUrl, votes);

            develop.create();

            developFeedback.ForeColor = System.Drawing.Color.Red;
            developFeedback.Text = "Accepted";
        }
示例#2
0
 /// <summary>
 /// Copy Constructor.
 /// Creates a new development business entity by copying the fields
 /// of another development BE.
 /// </summary>
 /// <param name="development"></param>
 public DevelopmentBE(DevelopmentBE development)
 {
     this.project = development.project;
     this.user = development.user;
     this.date = development.date;
     this.gitBranch = development.gitBranch;
     this.ups = development.ups;
 }
示例#3
0
 /* ****************************************************************** */
 /* Constructors                                                       */
 /* ****************************************************************** */
 public NewsBE()
 {
     title = "";
     content = "";
     author = new UserBE();
     code = -1;
     publicationDate = new DateTime();
     topic = new DevelopmentBE();
     project = new ProjectBE();
 }
示例#4
0
 public NewsBE(string title, string content, int code,
     UserBE author, DateTime publicationDate,
     DevelopmentBE topic, ProjectBE project)
 {
     this.code = code;
     this.title = title;
     this.content = content;
     this.author = author;
     this.publicationDate = publicationDate;
     this.topic = topic;
     this.project = project;
 }
示例#5
0
 public List<NewsBE> getNewsByTopic(DevelopmentBE author)
 {
     List<NewsBE> newsitems = new List<NewsBE>();
     // Do stuff here
     return newsitems;
 }
示例#6
0
        /// <summary>
        /// Development Update.
        /// Updates the database register which matches the given
        /// development replacing all the database fields with
        /// the ones of the provided development.
        /// </summary>
        /// <param name="contribution">The development that will be used to 
        ///     update the register.</param>
        public void update(DevelopmentBE development)
        {
            SqlConnection c = new SqlConnection(connection);

            try
            {
                c.Open();

                SqlParameter project = new SqlParameter();
                project.ParameterName = "@project";
                project.Value = development.Project.Code;
                SqlParameter usr = new SqlParameter();
                usr.ParameterName = "@usr";
                usr.Value = development.User.Email;
                SqlParameter date = new SqlParameter();
                date.ParameterName = "@date";
                date.Value = development.Date.ToString("G");
                SqlParameter gitbranch = new SqlParameter();
                gitbranch.ParameterName = "@gitbranch";
                gitbranch.Value = development.GitBranch;
                SqlParameter ups = new SqlParameter();
                ups.ParameterName = "@ups";
                ups.Value = development.Ups.ToString();

                SqlCommand com = new SqlCommand("UPDATE developments " +
                    "SET project=@project , usr=@usr , date=@date , gitbranch=@gitbranch , ups=@ups " +
                    "WHERE project=@project AND usr=@usr AND date=@date", c);

                com.Parameters.Add(project);
                com.Parameters.Add(usr);
                com.Parameters.Add(date);
                com.Parameters.Add(gitbranch);
                com.Parameters.Add(ups);

                com.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                // Show message box
            }
            finally
            {
                c.Close();
            }
        }
示例#7
0
        // /////////////////////////////////////////////////////////////////////
        // Methods /////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Development Insertion.
        /// Inserts the given development in the database building the adequate
        /// query and handling the possible SQL errors that can occur when inserting.
        /// </summary>
        /// <param name="contribution">The development to be inserted.</param>
        /// <returns>A string which contains an error/success message.</returns>
        public string insert(DevelopmentBE development)
        {
            string result = "The development has been succesfully added!";
            SqlConnection c = new SqlConnection(connection);

            try
            {
                c.Open();

                SqlParameter project = new SqlParameter();
                project.ParameterName = "@project";
                project.Value = development.Project.Code;
                SqlParameter usr = new SqlParameter();
                usr.ParameterName = "@usr";
                usr.Value = development.User.Email;
                SqlParameter date = new SqlParameter();
                date.ParameterName = "@date";
                date.Value = development.Date.ToString("G");
                SqlParameter gitbranch = new SqlParameter();
                gitbranch.ParameterName = "@gitbranch";
                gitbranch.Value = development.GitBranch;
                SqlParameter ups = new SqlParameter();
                ups.ParameterName = "@ups";
                ups.Value = development.Ups.ToString();

                SqlCommand com = new SqlCommand("INSERT INTO developments (project, usr, date, gitbranch, ups) " +
                    "VALUES (@project, @usr, @date, @gitbranch, @ups)", c);

                com.Parameters.Add(project);
                com.Parameters.Add(usr);
                com.Parameters.Add(date);
                com.Parameters.Add(gitbranch);
                com.Parameters.Add(ups);

                com.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                if (ex.Message.Contains("PRIMARY KEY"))
                    result = "ERROR: A development has already been made today for that project.";
            }
            catch (Exception ex)
            {
                // Show message box
            }
            finally
            {
                c.Close();
            }

            return result;
        }
示例#8
0
        /// <summary>
        /// Development Removal
        /// Deletes a development from the database given all the required
        /// files to identify the development.
        /// </summary>
        /// <param name="contribution">The development that will be removed.</param>
        public void delete(DevelopmentBE development)
        {
            SqlConnection c = new SqlConnection(connection);

            try
            {
                c.Open();

                SqlParameter project = new SqlParameter();
                project.ParameterName = "@project";
                project.Value = development.Project.Code;
                SqlParameter usr = new SqlParameter();
                usr.ParameterName = "@usr";
                usr.Value = development.User.Email;
                SqlParameter date = new SqlParameter();
                date.ParameterName = "@date";
                date.Value = development.Date.ToString("G");

                SqlCommand com = new SqlCommand("DELETE FROM developments " +
                    "WHERE project=@project AND usr=@usr AND date=@date", c);

                com.Parameters.Add(project);
                com.Parameters.Add(usr);
                com.Parameters.Add(date);

                com.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                // Show message box
            }
            finally
            {
                c.Close();
            }
        }