Esempio n. 1
0
        /// <summary>
        /// Update the TIP Status in the database
        /// </summary>
        /// <param name="model"></param>
        public void UpdateTipStatus(TipStatusModel model)
        {
            SqlCommand cmd = new SqlCommand("[TIP].[UpdateStatus]");
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@PROGRAMID ", model.ProgramId);
            cmd.Parameters.AddWithValue("@TIMEPERIODID ", model.TimePeriodId);
            cmd.Parameters.AddWithValue("@TIPYEAR ", model.TipYear);
            cmd.Parameters.AddWithValue("@CURRENT ", model.IsCurrent);
            cmd.Parameters.AddWithValue("@PENDING ", model.IsPending);
            cmd.Parameters.AddWithValue("@PREVIOUS ", model.IsPrevious);
            cmd.Parameters.AddWithValue("@NOTES ", model.Notes);
            cmd.Parameters.AddWithValue("@ADOPTIONDATE ", model.Adoption != null ? (object)model.Adoption.Value : (object)DBNull.Value);
            cmd.Parameters.AddWithValue("@GOVAPPROVALDATE ", model.GovernorApproval != null ? (object)model.GovernorApproval.Value : (object)DBNull.Value);
            cmd.Parameters.AddWithValue("@PUBLICHEARINGDATE ", model.PublicHearing != null ? (object)model.PublicHearing.Value : (object)DBNull.Value);
            cmd.Parameters.AddWithValue("@DOTDATE ", model.USDOTApproval != null ? (object)model.USDOTApproval.Value : (object)DBNull.Value);
            cmd.Parameters.AddWithValue("@EPADATE ", model.EPAApproval != null ? (object)model.EPAApproval.Value : (object)DBNull.Value);
            cmd.Parameters.AddWithValue("@ShowDelayDate ", !model.ShowDelayDate.Equals(default(DateTime)) ? (object)model.ShowDelayDate : (object)DBNull.Value);

            this.ExecuteNonQuery(cmd);
        }
Esempio n. 2
0
        /// <summary>
        /// Fetches a TipListViewModel that's used on the TipList View
        /// </summary>
        /// <returns></returns>
        public TipListViewModel GetTipListViewModel()
        {
            TipListViewModel model = new TipListViewModel();

            SqlCommand cmd = new SqlCommand("[TIP].[GetPrograms]");
            cmd.CommandType = CommandType.StoredProcedure;

            IList<TipStatusModel> tipPrograms = new List<TipStatusModel>();
            TipStatusModel sm = null;
            using (IDataReader rdr = this.ExecuteReader(cmd))
            {
                //be sure we got a reader
                while(rdr.Read())
                {
                    sm = new TipStatusModel();

                    sm.ProgramId = (int)rdr["ProgramId"];
                    sm.TimePeriodId = Convert.ToInt32(rdr["TimePeriodId"]);
                    sm.TipYear = rdr["TimePeriod"].ToString();
                    sm.Adoption = rdr["AdoptionDate"] != DBNull.Value ? (DateTime?)rdr["AdoptionDate"]:null;
                    sm.EPAApproval = rdr["USEPAApprovalDate"] != DBNull.Value ? (DateTime?)rdr["USEPAApprovalDate"]:null;
                    sm.GovernorApproval = rdr["GovernorApprovalDate"] != DBNull.Value ? (DateTime?)rdr["GovernorApprovalDate"] : null;
                    sm.LastAmended = rdr["LastAmendmentDate"] != DBNull.Value ? (DateTime?)rdr["LastAmendmentDate"] : null;
                    sm.PublicHearing = rdr["PublicHearingDate"] != DBNull.Value ? (DateTime?)rdr["PublicHearingDate"] : null;
                    sm.USDOTApproval = rdr["USDOTApprovalDate"] != DBNull.Value ? (DateTime?)rdr["USDOTApprovalDate"] : null;
                    sm.Notes = rdr["Notes"].ToString();
                    sm.IsCurrent = (bool)rdr["Current"];
                    sm.IsPending = (bool)rdr["Pending"];
                    sm.IsPrevious = (bool)rdr["Previous"];

                    tipPrograms.Add(sm);

                }
            }
            model.TIPs = tipPrograms;
            return model;
        }
Esempio n. 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public StatusViewModel GetTipStatusViewModel(string tipYear)
        {
            StatusViewModel model = new StatusViewModel();

            SqlCommand cmd = new SqlCommand("[TIP].[GetStatus]");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@TIPYEAR", SqlDbType.NVarChar));
            cmd.Parameters[0].Value = tipYear;

            model.TipSummary.TipYear = tipYear;
            var sm = new TipStatusModel();

            using (IDataReader rdr = this.ExecuteReader(cmd))
            {
                if(rdr.Read())
                {
                    sm.ProgramId = (int)rdr["ProgramId"];
                    sm.TimePeriodId = Convert.ToInt32(rdr["TimePeriodId"]);
                    sm.TipYear = rdr["TimePeriod"].ToString();
                    sm.Adoption = rdr["AdoptionDate"] != DBNull.Value ? (DateTime?)rdr["AdoptionDate"] : null;
                    sm.EPAApproval = rdr["USEPAApprovalDate"] != DBNull.Value ? (DateTime?)rdr["USEPAApprovalDate"] : null;
                    sm.GovernorApproval = rdr["GovernorApprovalDate"] != DBNull.Value ? (DateTime?)rdr["GovernorApprovalDate"] : null;
                    sm.LastAmended = rdr["LastAmendmentDate"] != DBNull.Value ? (DateTime?)rdr["LastAmendmentDate"] : null;
                    sm.PublicHearing = rdr["PublicHearingDate"] != DBNull.Value ? (DateTime?)rdr["PublicHearingDate"] : null;
                    sm.USDOTApproval = rdr["USDOTApprovalDate"] != DBNull.Value ? (DateTime?)rdr["USDOTApprovalDate"] : null;
                    sm.Notes = rdr["Notes"].ToString();
                    sm.IsCurrent = (bool)rdr["Current"];
                    sm.IsPending = (bool)rdr["Pending"];
                    sm.IsPrevious = (bool)rdr["Previous"];
                    sm.ShowDelayDate = rdr["ShowDelayDate"] != DBNull.Value ? (DateTime)rdr["ShowDelayDate"] : default(DateTime);
                }
            }

            model.TipStatus = sm;
            return model;
        }