Пример #1
0
        public static Boolean InsertUpdateTrainingCourse(clsTrainingCourse objTrainingCourse)
        {
            bool   isAdded = false;
            string SpName  = "usp_InsertUpdateTrainingCourse";

            try
            {
                using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"]))
                {
                    db.Execute(SpName, objTrainingCourse, commandType: CommandType.StoredProcedure);
                }
                isAdded = true;
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLogging(ex, false);
                ErrorHandler.ReadError();
            }
            return(isAdded);
        }
Пример #2
0
        public static clsTrainingCourse SelectTrainingCourseById(int?TrainingCourseAppId)
        {
            clsTrainingCourse objTrainingCourse = new clsTrainingCourse();
            bool   isnull = true;
            string SpName = "usp_SelectTrainingCourse";
            var    objPar = new DynamicParameters();

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

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

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