Ejemplo n.º 1
0
        public static bool UpdateOnly(UserAccess ua, int project_id)
        {
            var cm = Constants.GetCachedCountyManager();

            var c = new Comment
            {
                comment           = "",
                update_only       = true,
                project_id        = project_id,
                added_by          = ua.user_name,
                by_county_manager = (ua.employee_id == cm)
            };

            var query = @"
        USE ProjectTracking;

        INSERT INTO Comment
        (project_id, comment, update_only, added_by, by_county_manager)
        VALUES
        (@project_id, @comment, @update_only, @added_by, @by_county_manager)";

            return(Constants.Save_Data <Comment>(query, c));
        }
Ejemplo n.º 2
0
        public bool Update(UserAccess ua, Project existingProject)
        {
            string query = "";

            if (!existingProject.completed && completed)
            {
                // we need to update the completed date too.
                query = @"
        UPDATE project
          SET 
            project_name = @project_name,
            priority = @priority,
            needs_attention = @needs_attention,
            estimated_completion_date = @estimated_completion_date,
            department_id = @department_id,
            funding_id = @funding_id,
            commissioner_share = @commissioner_share,
            infrastructure_share = @infrastructure_share,
            legislative_tracking = @legislative_tracking,
            completed = @completed,
            date_completed = GETDATE()
        WHERE 
          id=@id";
            }
            else
            {
                query = @"
        UPDATE project
          SET 
            project_name = @project_name,
            department_id = @department_id,
            funding_id = @funding_id,
            commissioner_share = @commissioner_share,
            infrastructure_share = @infrastructure_share,
            legislative_tracking = @legislative_tracking,
            completed = @completed,
            priority = @priority,
            needs_attention = @needs_attention,
            estimated_completion_date = @estimated_completion_date            
        WHERE 
          id=@id";
            }
//      query += @"

//        DELETE
//        FROM phase_dates
//        WHERE
//          project_id=@id;

//        INSERT INTO [dbo].[phase_dates]
//          ([project_id]
//          ,[phase_1_name]
//          ,[phase_2_name]
//          ,[phase_3_name]
//          ,[phase_4_name]
//          ,[phase_5_name]
//          ,[phase_1_start]
//          ,[phase_1_completion]
//          ,[phase_2_start]
//          ,[phase_2_completion]
//          ,[phase_3_start]
//          ,[phase_3_completion]
//          ,[phase_4_start]
//          ,[phase_4_completion]
//          ,[phase_5_start]
//          ,[phase_5_completion])
//         VALUES
//          (@id
//          ,@phase_1_name
//          ,@phase_2_name
//          ,@phase_3_name
//          ,@phase_4_name
//          ,@phase_5_name
//          ,@phase_1_start
//          ,@phase_1_completion
//          ,@phase_2_start
//          ,@phase_2_completion
//          ,@phase_3_start
//          ,@phase_3_completion
//          ,@phase_4_start
//          ,@phase_4_completion
//          ,@phase_5_start
//          ,@phase_5_completion);
//";
            // now let's add the comment / milestones
            Comment.Save(ua, id, comment);

            Milestone.SaveAll(id, milestones);
            Phase.SaveAll(id, phases);

            return(Constants.Save_Data <Project>(query, this));
        }
Ejemplo n.º 3
0
        public bool Save(UserAccess ua)
        {
            added_by = ua.user_name;

            var dp = new DynamicParameters();

            dp.Add("@project_id", dbType: DbType.Int32, direction: ParameterDirection.Output);
            dp.Add("@project_name", project_name);
            dp.Add("@department_id", department_id);
            dp.Add("@priority", priority);
            dp.Add("@needs_attention", needs_attention);
            //dp.Add("@estimated_completion_date", estimated_completion_date == DateTime.MinValue ? (DateTime?)null : estimated_completion_date);
            dp.Add("@estimated_completion_date", estimated_completion_date);
            dp.Add("@funding_id", funding_id);
            dp.Add("@timeline", timeline);
            dp.Add("@commissioner_share", commissioner_share);
            dp.Add("@infrastructure_share", infrastructure_share);
            dp.Add("@legislative_tracking", legislative_tracking);
            dp.Add("@completed", completed);
            dp.Add("@added_by", added_by);
            //dp.Add("@phase_1_name", phase_1_name);
            //dp.Add("@phase_2_name", phase_2_name);
            //dp.Add("@phase_3_name", phase_3_name);
            //dp.Add("@phase_4_name", phase_4_name);
            //dp.Add("@phase_5_name", phase_5_name);
            //dp.Add("@phase_1_start", phase_1_start);
            //dp.Add("@phase_1_completion", phase_1_completion);
            //dp.Add("@phase_2_start", phase_2_start);
            //dp.Add("@phase_2_completion", phase_2_completion);
            //dp.Add("@phase_3_start", phase_3_start);
            //dp.Add("@phase_3_completion", phase_3_completion);
            //dp.Add("@phase_4_start", phase_4_start);
            //dp.Add("@phase_4_completion", phase_4_completion);
            //dp.Add("@phase_5_start", phase_5_start);
            //dp.Add("@phase_5_completion", phase_5_completion);

            string query = @"
        INSERT INTO project (
          project_name, 
          priority,
          needs_attention,
          estimated_completion_date,
          department_id, 
          funding_id,
          timeline, 
          commissioner_share, 
          infrastructure_share,
          legislative_tracking,
          completed, 
          added_on, 
          added_by
        )
        VALUES (
          @project_name, 
          @priority,
          @needs_attention,
          @estimated_completion_date,
          @department_id, 
          @funding_id,
          @timeline, 
          @commissioner_share, 
          @infrastructure_share,
          @legislative_tracking,
          @completed, 
          GETDATE(), 
          @added_by
        );";

            //SET @project_id = SCOPE_IDENTITY();

            //INSERT INTO [dbo].[phase_dates]
            //  ([project_id]
            //  ,[phase_1_name]
            //  ,[phase_2_name]
            //  ,[phase_3_name]
            //  ,[phase_4_name]
            //  ,[phase_5_name]
            //  ,[phase_1_start]
            //  ,[phase_1_completion]
            //  ,[phase_2_start]
            //  ,[phase_2_completion]
            //  ,[phase_3_start]
            //  ,[phase_3_completion]
            //  ,[phase_4_start]
            //  ,[phase_4_completion]
            //  ,[phase_5_start]
            //  ,[phase_5_completion])
            // VALUES
            //  (@project_id
            //  ,@phase_1_name
            //  ,@phase_2_name
            //  ,@phase_3_name
            //  ,@phase_4_name
            //  ,@phase_5_name
            //  ,@phase_1_start
            //  ,@phase_1_completion
            //  ,@phase_2_start
            //  ,@phase_2_completion
            //  ,@phase_3_start
            //  ,@phase_3_completion
            //  ,@phase_4_start
            //  ,@phase_4_completion
            //  ,@phase_5_start
            //  ,@phase_5_completion); ";
            int i = Constants.Exec_Query(query, dp);

            if (i == -1)
            {
                return(false);
            }
            id = dp.Get <int>("@project_id");
            // now let's add the comment / milestones
            Comment.Save(ua, id, comment);

            Milestone.SaveAll(id, milestones);
            Phase.SaveAll(id, phases);
            return(true);
        }