Пример #1
0
        public DepartmentDTO getDepartmentDetail(String id)
        {
            sqlCon = new SqlConnection(stringConn);
            sqlCon.Open();
            DepartmentDTO result = null;

            cmd    = new SqlCommand("SELECT TENKHOA, NAMTHANHLAP FROM KHOA WHERE MAKHOA = '" + id + "'", sqlCon);
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                var name = reader.GetString(0);
                var year = reader.GetInt32(1);
                result = new DepartmentDTO(id, name, year);
            }
            closeConnection();
            return(result);
        }
Пример #2
0
        public bool addDepartment(DepartmentDTO dto)
        {
            bool check = false;

            try
            {
                sqlCon = new SqlConnection(stringConn);
                sqlCon.Open();
                cmd   = new SqlCommand(String.Format("INSERT INTO KHOA VALUES('{0}','{1}','{2}')", dto.Id, dto.Name, dto.Year), sqlCon);
                check = cmd.ExecuteNonQuery() > 0 ? true : false;
                closeConnection();
            }
            catch (Exception e)
            {
            }

            return(check);
        }