コード例 #1
0
        /// <summary>
        /// Creates a new Deficiency record
        /// </summary>
        public static void Create(DeficiencyDO DO)
        {
            SqlParameter _DeficiencyID = new SqlParameter("DeficiencyID", SqlDbType.Int);
            SqlParameter _Version = new SqlParameter("Version", SqlDbType.SmallInt);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            SqlParameter _Section = new SqlParameter("Section", SqlDbType.VarChar);
            SqlParameter _SubSection = new SqlParameter("SubSection", SqlDbType.VarChar);
            SqlParameter _TOCID = new SqlParameter("TOCID", SqlDbType.Int);
            SqlParameter _DeficiencyStatusID = new SqlParameter("DeficiencyStatusID", SqlDbType.VarChar);
            SqlParameter _DeficiencyTypeID = new SqlParameter("DeficiencyTypeID", SqlDbType.VarChar);
            SqlParameter _DeficiencyStateID = new SqlParameter("DeficiencyStateID", SqlDbType.VarChar);
            SqlParameter _DeficiencyDate = new SqlParameter("DeficiencyDate", SqlDbType.DateTime);
            SqlParameter _UserToken = new SqlParameter("UserToken", SqlDbType.VarChar);
            SqlParameter _Description = new SqlParameter("Description", SqlDbType.VarChar);
            SqlParameter _DeficiencyResponse = new SqlParameter("DeficiencyResponse", SqlDbType.VarChar);
            
            _DeficiencyID.Value = DO.DeficiencyID;
            _Version.Value = DO.Version;
            _PermitKey.Value = DO.PermitKey;
            _Section.Value = DO.Section;
            _SubSection.Value = DO.SubSection;
            _TOCID.Value = DO.TOCID;
            _DeficiencyStatusID.Value = DO.DeficiencyStatusID;
            _DeficiencyTypeID.Value = DO.DeficiencyTypeID;
            _DeficiencyStateID.Value = DO.DeficiencyStateID;
            _DeficiencyDate.Value = DO.DeficiencyDate;
            _UserToken.Value = DO.UserToken;
            _Description.Value = DO.Description;
            _DeficiencyResponse.Value = DO.DeficiencyResponse;
            
            SqlParameter[] _params = new SqlParameter[] {
                _DeficiencyID,
                _Version,
                _PermitKey,
                _Section,
                _SubSection,
                _TOCID,
                _DeficiencyStatusID,
                _DeficiencyTypeID,
                _DeficiencyStateID,
                _DeficiencyDate,
                _UserToken,
                _Description,
                _DeficiencyResponse
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            DataCommon.ExecuteNonQuery("[dbo].[Deficiency_Insert]", _params, pid);
            
        }
コード例 #2
0
        /// <summary>
        /// Selects Deficiency records by DeficiencyPermitKeySection
        /// </summary>
        public static async Task<DeficiencyDO[]> GetByDeficiencyPermitKeySectionAsync(Int32 PermitKey,
 String Section)
        {

            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            SqlParameter _Section = new SqlParameter("Section", SqlDbType.VarChar);
			
            _PermitKey.Value = PermitKey;
            _Section.Value = Section;
			
            SqlParameter[] _params = new SqlParameter[] {
                _PermitKey,
                _Section
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[Deficiency_GetByDeficiencyPermitKeySection]", _params, pid);


            List<DeficiencyDO> objs = new List<DeficiencyDO>();
			
            while(sr.Read())
            {
                DeficiencyDO obj = new DeficiencyDO();
				
                obj.DeficiencyID = sr.GetInt32(sr.GetOrdinal("DeficiencyID"));
                obj.Version = sr.GetInt16(sr.GetOrdinal("Version"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                obj.Section = sr.GetString(sr.GetOrdinal("Section"));
                obj.SubSection = sr.GetString(sr.GetOrdinal("SubSection"));
                obj.TOCID = sr.GetInt32(sr.GetOrdinal("TOCID"));
                obj.DeficiencyStatusID = sr.GetString(sr.GetOrdinal("DeficiencyStatusID"));
                obj.DeficiencyTypeID = sr.GetString(sr.GetOrdinal("DeficiencyTypeID"));
                obj.DeficiencyStateID = sr.GetString(sr.GetOrdinal("DeficiencyStateID"));
                obj.DeficiencyDate = sr.GetDateTime(sr.GetOrdinal("DeficiencyDate"));
                obj.UserToken = sr.GetString(sr.GetOrdinal("UserToken"));
                obj.Description = sr.GetString(sr.GetOrdinal("Description"));
                if (sr.IsDBNull(sr.GetOrdinal("DeficiencyResponse"))) { obj.DeficiencyResponse = null; } else { obj.DeficiencyResponse = sr.GetString(sr.GetOrdinal("DeficiencyResponse")); }

                objs.Add(obj);
            }

            return objs.ToArray();
        }
コード例 #3
0
        /// <summary>
        /// Gets all Deficiency records
        /// </summary>
        public static async Task<DeficiencyDO[]> GetAllAsync()
        {

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[Deficiency_GetAll]", new SqlParameter[] { }, pid);
            
            List<DeficiencyDO> objs = new List<DeficiencyDO>();
            
            while(sr.Read()){

                DeficiencyDO obj = new DeficiencyDO();
                
                obj.DeficiencyID = sr.GetInt32(sr.GetOrdinal("DeficiencyID"));
                obj.Version = sr.GetInt16(sr.GetOrdinal("Version"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                obj.Section = sr.GetString(sr.GetOrdinal("Section"));
                obj.SubSection = sr.GetString(sr.GetOrdinal("SubSection"));
                obj.TOCID = sr.GetInt32(sr.GetOrdinal("TOCID"));
                obj.DeficiencyStatusID = sr.GetString(sr.GetOrdinal("DeficiencyStatusID"));
                obj.DeficiencyTypeID = sr.GetString(sr.GetOrdinal("DeficiencyTypeID"));
                obj.DeficiencyStateID = sr.GetString(sr.GetOrdinal("DeficiencyStateID"));
                obj.DeficiencyDate = sr.GetDateTime(sr.GetOrdinal("DeficiencyDate"));
                obj.UserToken = sr.GetString(sr.GetOrdinal("UserToken"));
                obj.Description = sr.GetString(sr.GetOrdinal("Description"));
                if (sr.IsDBNull(sr.GetOrdinal("DeficiencyResponse"))) { obj.DeficiencyResponse = null; } else { obj.DeficiencyResponse = sr.GetString(sr.GetOrdinal("DeficiencyResponse")); }


                objs.Add(obj);
            }

            return objs.ToArray();
        }
コード例 #4
0
        /// <summary>
        /// Deletes a Deficiency record
        /// </summary>
        public static async Task<int> DeleteAsync(DeficiencyDO DO)
        {
            SqlParameter _DeficiencyID = new SqlParameter("DeficiencyID", SqlDbType.Int);
            SqlParameter _Version = new SqlParameter("Version", SqlDbType.SmallInt);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            
            _DeficiencyID.Value = DO.DeficiencyID;
            _Version.Value = DO.Version;
            _PermitKey.Value = DO.PermitKey;
            
            SqlParameter[] _params = new SqlParameter[] {
                _DeficiencyID,
                _Version,
                _PermitKey
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            return await DataCommon.ExecuteScalarAsync("[dbo].[Deficiency_Delete]", _params, pid);
        }
コード例 #5
0
/// <summary>
        /// Selects Deficiency records by PK
        /// </summary>
        public static DeficiencyDO[] GetByPK(Int32 DeficiencyID,
 Int16 Version,
 Int32 PermitKey)
        {

            SqlParameter _DeficiencyID = new SqlParameter("DeficiencyID", SqlDbType.Int);
            SqlParameter _Version = new SqlParameter("Version", SqlDbType.SmallInt);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
			
            _DeficiencyID.Value = DeficiencyID;
            _Version.Value = Version;
            _PermitKey.Value = PermitKey;
			
            SqlParameter[] _params = new SqlParameter[] {
                _DeficiencyID,
                _Version,
                _PermitKey
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = DataCommon.ExecuteSafeReader("[dbo].[Deficiency_GetByPK]", _params, pid);


            List<DeficiencyDO> objs = new List<DeficiencyDO>();
			
            while(sr.Read())
            {
                DeficiencyDO obj = new DeficiencyDO();
				
                obj.DeficiencyID = sr.GetInt32(sr.GetOrdinal("DeficiencyID"));
                obj.Version = sr.GetInt16(sr.GetOrdinal("Version"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                obj.Section = sr.GetString(sr.GetOrdinal("Section"));
                obj.SubSection = sr.GetString(sr.GetOrdinal("SubSection"));
                obj.TOCID = sr.GetInt32(sr.GetOrdinal("TOCID"));
                obj.DeficiencyStatusID = sr.GetString(sr.GetOrdinal("DeficiencyStatusID"));
                obj.DeficiencyTypeID = sr.GetString(sr.GetOrdinal("DeficiencyTypeID"));
                obj.DeficiencyStateID = sr.GetString(sr.GetOrdinal("DeficiencyStateID"));
                obj.DeficiencyDate = sr.GetDateTime(sr.GetOrdinal("DeficiencyDate"));
                obj.UserToken = sr.GetString(sr.GetOrdinal("UserToken"));
                obj.Description = sr.GetString(sr.GetOrdinal("Description"));
                if (sr.IsDBNull(sr.GetOrdinal("DeficiencyResponse"))) { obj.DeficiencyResponse = null; } else { obj.DeficiencyResponse = sr.GetString(sr.GetOrdinal("DeficiencyResponse")); }

                objs.Add(obj);
            }

            return objs.ToArray();
        }
コード例 #6
0
        public ActionResult NoDeficiency(int PermitKey, int TOCID, NoDeficiencyVM model, FormCollection data)
        {
            if (!ModelState.IsValid)
            {
                NewDeficiencyVM responseModel = GetDeficienciesBySource(PermitKey, model.Source);
                return PartialView(responseModel);
            }

            try
            {

                foreach (string key in data.AllKeys.Where(k => k.StartsWith("rule_")))
                {
                    string section = key.Split('_')[1];
                    string subsection = key.Split('_')[2];
                    DeficiencyDO newDeficiency = new DeficiencyDO()
                    {
                        DeficiencyDate = DateTime.Now,
                        DeficiencyStateID = "Initial",
                        DeficiencyStatusID = ENUMBLL.EnumDescription(ENUMBLL.DeficiencyStatusType.NoDeficiency),
                        DeficiencyTypeID = model.IsCompleteness.Value == true ? "Completeness" : "Acceptability",
                        Description = "No Deficiency",
                        PermitKey = PermitKey,
                        Section = section,
                        SubSection = subsection,
                        TOCID = TOCID,
                        UserToken = myCoalUser.UserToken,
                        Version = 0
                    };

                    DeficiencyBLL.Save(newDeficiency);
                }

                AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.OK, "Your changes have been saved");
                result.Data.Add("TOCID", TOCID);
                result.Data.Add("PermitKey", PermitKey);
                return Json(result);

            }
            catch (Exception ex)
            {
                AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.ERROR, ex.Message);
                return Json(result);
            }
        }
コード例 #7
0
        public ActionResult NewDeficiency(NewDeficiencyVM model, int PermitKey, FormCollection formData)
        {
            if (!ModelState.IsValid)
            {
                DeficienciesBO deficiencies = DeficiencyBLL.GetDeficiencies(model.TOCID, PermitKey);
                NewDeficiencyVM data = new NewDeficiencyVM(deficiencies, model.DeficiencyState);
                data.Description = model.Description;
                data.CheckedRules = formData.AllKeys.Where(k => k.StartsWith("rule")).ToList();
                ViewBag.RuleCount = model.CheckedRules.Count;
                return PartialView(data);
            }

            try
            {

                foreach (string key in formData.AllKeys.Where(k => k.StartsWith("rule_")))
                {
                    string section = key.Split('_')[1];
                    string subsection = key.Split('_')[2];
                    DeficiencyDO newDeficiency = new DeficiencyDO()
                    {
                        DeficiencyDate = DateTime.Now,
                        DeficiencyStateID = model.DeficiencyState,
                        DeficiencyStatusID = "Deficient",
                        DeficiencyTypeID = (model.IsCompleteness.HasValue && model.IsCompleteness.Value == true) ? "Completeness" : "Acceptability",
                        Description = model.Description,
                        PermitKey = PermitKey,
                        Section = section,
                        SubSection = subsection,
                        TOCID = model.TOCID,
                        UserToken = myCoalUser.UserToken,
                        Version = 0
                    };
                    DeficiencyBLL.Save(newDeficiency);

                }

                AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.OK, "The deficiencies have been added");
                return Json(result);

            }
            catch (Exception ex)
            {
                AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.ERROR, ex.Message);
                return Json(result);
            }
        }
コード例 #8
0
        public ActionResult SaveFinalDeficiency(int DeficiencyID, int PermitKey, string Section, string SubSection, ENUMBLL.SubmitType ChecklistType, string finalDeficiency)
        {
            if (!Judge.AllowFinalDeficiencyEntry)
                return Json(new AjaxResult(AjaxResult.AjaxStatus.ERROR, "You are not able to enter final deficiencies at this time"));

            DeficiencyDO final = new DeficiencyDO()
            {
                DeficiencyID = DeficiencyID,
                DeficiencyDate = DateTime.Now,
                DeficiencyStateID = "Final",
                DeficiencyStatusID = ENUMBLL.EnumDescription(ENUMBLL.DeficiencyStatusType.Deficient),
                DeficiencyTypeID = ENUMBLL.EnumDescription(ChecklistType),
                Description = finalDeficiency,
                PermitKey = PermitKey,
                Section = Section,
                SubSection = SubSection,
                TOCID = 0,
                UserToken = myCoalUser.UserToken
            };

            final.Version = DeficiencyBLL.Save(final);

            // Save returns the version, not the id, so we need to look it up again to get the data object
            List<DeficiencyBO> deficiencies = DeficiencyBLL.GetDeficienciesBySubSection(PermitKey, Section, SubSection);
            DeficiencyBO deficiency = deficiencies.Find(d => d.IsFinal == true);
            final = deficiency.Versions.Last();

            AjaxResult result = new AjaxResult(AjaxResult.AjaxStatus.OK, "The final deficiency has been saved");
            result.Data.Add("DeficiencyDO", final);
            result.Data.Add("NewSaveUrl", Url.Action("SaveFinalDeficiency", "ePermitChecklist", new { PermitKey = PermitKey, DeficiencyID = final.DeficiencyID, Section = Section, SubSection = SubSection, ChecklistType = ENUMBLL.EnumDescription(ChecklistType) }));
            result.Data.Add("ResponseType", "FinalDeficiency");

            return Json(result);
        }