Ejemplo n.º 1
0
        public static Boolean InsertUpdateNotice(clsNotice objNotice)
        {
            bool   isAdded = false;
            string SpName  = "usp_InsertUpdateNotice";

            try
            {
                using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"]))
                {
                    db.Execute(SpName, objNotice, commandType: CommandType.StoredProcedure);
                }
                isAdded = true;
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLogging(ex, false);
                ErrorHandler.ReadError();
            }
            return(isAdded);
        }
Ejemplo n.º 2
0
        public static clsNotice SelectNoticeById(int?NoticeId)
        {
            clsNotice objNotice = new clsNotice();
            bool      isnull    = true;
            string    SpName    = "usp_SelectNotice";
            var       objPar    = new DynamicParameters();

            if (String.IsNullOrEmpty(NoticeId.ToString()))
            {
                throw new ArgumentException("Function parameters cannot be blank!");
            }
            else
            {
                try
                {
                    objPar.Add("@NoticeId", NoticeId, dbType: DbType.Int32);

                    using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"]))
                    {
                        objNotice = db.Query <clsNotice>(SpName, objPar, commandType: CommandType.StoredProcedure).SingleOrDefault();
                        isnull    = false;
                    }
                }
                catch (Exception ex)
                {
                    ErrorHandler.ErrorLogging(ex, false);
                    ErrorHandler.ReadError();
                }
            }

            if (isnull)
            {
                return(null);
            }
            else
            {
                return(objNotice);
            }
        }