Example #1
0
        public IList<Cycle> GetPlanCycles(int timePeriodId)
        {
            IList<Cycle> list = new List<Cycle>();

            try
            {
                using (SqlCommand command = new SqlCommand("[RTP].[GetCurrentPlanCycles]") { CommandType = CommandType.StoredProcedure })
                {
                    command.Parameters.AddWithValue("@TimePeriodId", timePeriodId);

                    using (IDataReader rdr = this.ExecuteReader(command))
                    {
                        while (rdr.Read())
                        {
                            Cycle summary = new Cycle()
                            {
                                Id = rdr["id"].ToString().SmartParse<int>()
                            ,
                                Name = rdr["cycle"].ToString()
                            ,
                                StatusId = rdr["statusId"].ToString().SmartParse<int>()
                            ,
                                Status = rdr["Status"].ToString()
                            };
                            list.Add(summary);
                        }
                    }
                }
            }
            catch
            {

            }

            return list;
        }
        public Cycle GetCycleDetails(int timePeriodId, Enums.RTPCycleStatus status)
        {
            SqlCommand cmd = new SqlCommand("[RTP].[GetCurrentPlanCycle]");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@TimePeriodId", timePeriodId);
            cmd.Parameters.AddWithValue("@StatusId", (int)status);

            var result = new Cycle();

            using (IDataReader rdr = this.ExecuteReader(cmd))
            {
                if (rdr.Read())
                {
                    result.Id = rdr["id"] != DBNull.Value ? rdr["id"].ToString().SmartParse<int>() : default(int);
                    result.Name = rdr["cycle"].ToString();
                    result.StatusId = rdr["statusId"].ToString().SmartParseDefault<int>(default(int));
                }
            }

            return result;
        }
        public Cycle GetProjectCycleInfo(int versionId)
        {
            Cycle result = null;
            using (SqlCommand command = new SqlCommand("[RTP].[GetProjectVersionCycle]") { CommandType = CommandType.StoredProcedure })
            {
                command.Parameters.AddWithValue("@RtpProjectVersion", versionId);

                using (IDataReader rdr = ExecuteReader(command))
                {
                    if (rdr.Read())
                    {
                        result = new Cycle();
                        result.Id = rdr["CycleId"] != DBNull.Value ? (int)rdr["CycleId"] : Int32.MinValue;
                        result.Name = rdr["Cycle"] != DBNull.Value ? rdr["Cycle"].ToString() : String.Empty;
                        result.Status = rdr["Status"] != DBNull.Value ? rdr["Status"].ToString() : String.Empty;
                        result.Reason = rdr["Reason"] != DBNull.Value ? rdr["Reason"].ToString() : String.Empty;
                        result.Date = rdr["Date"] != DBNull.Value ? (DateTime)rdr["Date"] : DateTime.MinValue;
                        result.StatusId = rdr["statusId"].ToString().SmartParseDefault<int>(default(int));
                    }
                }
            }
            return result;
        }