Exemple #1
0
        public static Boolean InsertUpdateSupervisor(clsSupervisor objSupervisor)
        {
            bool   isAdded = false;
            string SpName  = "usp_InsertUpdateSupervisor";

            try
            {
                using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"]))
                {
                    db.Execute(SpName, objSupervisor, commandType: CommandType.StoredProcedure);
                }
                isAdded = true;
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLogging(ex, false);
                ErrorHandler.ReadError();
            }
            return(isAdded);
        }
Exemple #2
0
        public static clsSupervisor SelectSupervisorById(int?SupervisorId)
        {
            clsSupervisor objSupervisor = new clsSupervisor();
            bool          isnull        = true;
            string        SpName        = "usp_SelectSupervisor";
            var           objPar        = new DynamicParameters();

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

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

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