Esempio n. 1
0
        public void SaveEduData(EducationItem myItem)
        {
            using (var db = DBConnection.CreateConnection())
            {
                db.Open();

                var sql = "dbo.spInsertEducation";
                var cmd = new SqlCommand(sql, db);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@EMP_ID", myItem._EMP_ID));
                cmd.Parameters.Add(new SqlParameter("@EDU_LEVEL", myItem._EDU_LEVEL));
                cmd.Parameters.Add(new SqlParameter("@EDU_SCHOOL_NAME", myItem._EDU_SCHOOL_NAME));
                cmd.Parameters.Add(new SqlParameter("@EDU_SCHOOL_ADDRESS", myItem._EDU_SCHOOL_ADDRESS));
                cmd.Parameters.Add(new SqlParameter("@EDU_DATE_GRADUATED", myItem._EDU_DATE_GRADUATED));
                cmd.Parameters.Add(new SqlParameter("@EDU_DEGREE_EARNED", (string.IsNullOrEmpty(myItem._EDU_DEGREE_EARNED) ? DBNull.Value.ToString() : myItem._EDU_DEGREE_EARNED)));

                cmd.ExecuteNonQuery();
                db.Close();
            }
        }
Esempio n. 2
0
        public List <EducationItem> RetreiveEmpEducation(string employeeID)
        {
            var itemList = new List <EducationItem>();

            using (var db = DBConnection.CreateConnection())
            {
                db.Open();

                var sql = "dbo.GetSpecificEducation";
                var cmd = new SqlCommand(sql, db);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@EMP_ID", employeeID));
                var reader = cmd.ExecuteReader();

                if (!reader.HasRows)
                {
                    return(null);
                }

                while (reader.Read())
                {
                    var item = new EducationItem();
                    item._EDU_LEVEL          = (string)reader["EDU_LEVEL"];
                    item._EMP_ID             = (string)reader["EMP_ID"];
                    item._EDU_SCHOOL_NAME    = (string)reader["EDU_SCHOOL_NAME"];
                    item._EDU_SCHOOL_ADDRESS = (string)reader["EDU_SCHOOL_ADDRESS"];
                    item._EDU_DATE_GRADUATED = (string)reader["EDU_DATE_GRADUATED"];
                    item._EDU_DEGREE_EARNED  = (string)reader["EDU_DEGREE_EARNED"];

                    itemList.Add(item);
                }

                db.Close();

                return(itemList);
            }
        }